-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Support/standardize semantic linking of input parameters with their output objects #728
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
edit: tl;dr I don't think we need spec changes, see my post below for a PoC. |
It's going to be difficult.
So, semantic linking is going to be an uphill battle! Also, convention is usually a better approach than restriction. Many many bug tickets and discussions start with "I have a reason to do this, but the spec won't let me!" One more issue with an implementation guessing how parameters link to response attributes, is the plenty of cases where it's not clear;
You'll need more than |
I'm cool with settling for convention where alternatives fail. In that event I guess OpenAPI could still add value there by encouraging good conventions. On ambiguities:
|
I do applaud your idea, but I'm not exactly sure whether you are trying to define a filtering spec, or define a mechanism by which a filtering spec may itself be defined? (If the former, then remember that the OpenAPI spec is meant to be API agnostic) |
I'm thinking in terms of 'relevant suggestions' rather than 'filter'. This difference again sounds subtle, but the latter sounds like adding limitations, while I'd think of having better information as enabling rather than limiting. |
On
|
@tycho01 I think the more fundamental issue is deeper than any Consider the docs for the OpenAPI spec itself; "OpenAPI does not require you to rewrite your existing API. It does not require binding any software to a service--the service being described may not even be yours. It does, however, require the capabilities of the service be described in the structure of the OpenAPI Specification." "Linking input parameters with their output objects" sounds to me like potentially a large flexible space. API A might use input parameters in a completely different manner to API B.
This sounds to me like a miniature version of what I've been cross with Swagger/OpenAPI about in the last few months;
Moral of the story? Don't go with Option 2 - that way lies disappointment confusion and anger. If not for the one defining that lovely mechanism, then for every author that comes around and is unable to use it to capture how their API works. |
Thanks, that's a fair point. I'm definitely okay with not covering every single edge case. |
I tried a quick PoC (i.e. I glossed over the complexity of JSON reference/pointer e.g. external/remote files) to demonstrate it's possible to gather the info with just |
PR 654 enabled using
schema
(and therefore$ref
) in non-body parameters, allowing one to$ref
erence definitions to allow sharing them between input parameters and existing definitions for response objects, preventing duplication, as suggested in #301 by @MrTrick and @jasonh-n-austin.Some ways to do that:
"schema": { "$ref": "#/definitions/person_id" }
, with thePerson
definition'sid
property also$ref
ing that."schema": { "$ref": "#/definitions/Person/properties/id" }
. Clear, but verbose.person_id
definition itself be a reference to#/definitions/Person/properties/id
so it could function as a shorthand to$ref
to.I think this in itself is great, and should be encouraged to those upgrading.
And I think especially the clarity of idea 2 would enable an interesting extension: allowing one to semantically link input parameters to such object fields, to allow tools to recognize API endpoint input/output properties as related.
So I'd like to discuss how tooling vendors could reliably (without standardization of
$ref
usage) find semantic links between:User
definition")id
field of aUser
instance")... with the intent of using the above information so as to suggest input information of one API endpoint could be provided by the output of another.
If one considers
$ref
purely as a pointer to be resolved, then the above ideas (even 2) contain one piece of information: anything contained at the path it resolves to.However, this proposed semantic linking essentially requires a bit more information. Note that after resolving
$ref
s, this information goes lost:#/definitions/Person
"./properties/id
"Person
". Note Swagger Editor solves this by injecting these titles into the definitions using their keys, which seems like a fair approach.I'd then wonder if Swagger Editor had solved point 1 as well, so as to relate response objects to their used definitions, which would obviously be similar. From what I can see though, it didn't. (Swagger Editor shows
Product
and its fields in the Uber/products
response, but this is a resolved link, rather than also still being aware of theProduct
definition it took the fields from.)Thoughts?
The text was updated successfully, but these errors were encountered: