-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Allow shorthand $ref for parameters and responses #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Isn't that a tooling issue? The output JSON will still have the full $ref, no? |
no, the output JSON right now does not had full |
So right now in the editor, if you have in YAML |
yes. |
I see. I need to investigate JSON Reference a bit more before knowing if it is technically possible, but if it is, sure, I'm all for it. |
Is this shorthand syntax even documented for 2.0? |
I'm not sure what you mean by "shorthand" documentation (I feel may we may be using the same term for a different thing). Basically, whatever is defined by http://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03 should be acceptable. |
We decided to have a non-standard way of doing |
I think the problem with that is that there are several sections of the spec that can be referred to - definitions, securityDefinitions, parameterDefinitions and responseDefinitions. Theoretically, the location of the reference can be inferred from referencing object, but I fear that may overly complicate tools that need to read such specs. I definitely understand the benefits of it, just think we need to weigh in the pros and cons. |
@whitlockjc is writing the tool to resolve all $refs in Swagger Tools. He can talk more about how this impacts tooling. |
From a tooling perspective, supporting it would be confusing and painful in my opinion. If We need to ask ourselves what we're trying to accomplish here. If it's a few less keystrokes, I don't think it's worth it. If it's something else more tangible, we should talk a bit more. |
Agree with @whitlockjc here. Especially with clarity recently added in Closing, as this is pretty old and seems like a non-starter. Re-open if you'd like to debate anything here. |
We just need to remember to put the same restriction in the current version in the next one as well (2.0 explicitly prohibits it, even though it is supported by JSON References). |
@webron JSON Reference allows for adding root-level elements, and referring to them directly (which maybe shouldn't be allowed, but @whitlockjc would probably disagree):
The OP was suggesting something very different, which is to infer |
I believe the author refers to inline vs canonical dereferencing as defined at http://json-schema.org/latest/json-schema-core.html#anchor30 - and we're decided to explicitly support only canonical iirc. |
My agreement depends on what we call a reference. If it's a JSON Reference, then a reference that does not start with a Node.js (url.parse)URL.parse('Pet')
Url {
protocol: null,
slashes: null,
auth: null,
host: null,
port: null,
hostname: null,
hash: null,
search: null,
query: null,
pathname: 'Pet',
path: 'Pet',
href: 'Pet' } Node.js (uri-js)URI.parse('Pet')
{ scheme: undefined,
userinfo: undefined,
host: undefined,
port: undefined,
path: 'Pet',
query: undefined,
fragment: undefined,
reference: 'relative' } |
I do agree with @webron that JSON Schema muddied the waters. |
This is 2.1 proposal
In 2.0 we have a shorthand definition for schemas. If user do not provide
#/definitions/
prefix, we will prepend it to their value in$ref
if it's aschema
value.This should work for
parameters
andresponses
tooExample:
Resolver should understand the context of
$ref
and look in proper object.Related to #132
The text was updated successfully, but these errors were encountered: