-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Message format 'wrappers' #555
Comments
@darrelmiller is probably more qualified to comment on this, but I'd like to suggest addressing what I believe are gaps in the spec:
Just throwing an ideas out here for problem # 1 based on the pet store example, please excuse if its a bit contrived /pets:
get:
description: description....
operationId: findPets
parameters:
- name: tags
in: query
description: tags to filter by
required: false
type: array
collectionFormat: csv
items:
type: string
- name: limit
in: query
description: maximum number of results to return
required: false
type: integer
format: int32
responses:
200:
description: pet response
headers:
# Location in the case of create resource
- name: "Location"
description: Location of created resource
type: string
# Pagination headers
- name: "totalPages"
description: total number of pages
type: integer
format: int32
body:
type: array
items:
$ref: '#/definitions/Pet'
# each link is a urlRef to another Path object, with a specific method
links:
- rel: "create"
$urlRef: "#paths/pet"
method: "post"
- rel: "delete"
$urlRef: "#paths/pet"
method: "delete"
... Also I find it odd, that we're trying to describe other rich media types within swagger. inception? 😄 If an api is using json-api or HAL, CJ, Apiary's Api Blue Print etc. for that matter; is there a need to describe it via swagger as well? I suspect there will be transformers for those cases in the future. The second problem is a subtly different issue, but it also centers around media types. Take for e.g. people wanting to document an |
On links: the only trouble with your example is that there is not a consistent link structure to rely on, as proposed. Resource a passion structures as in stormpath.com don't fit the 'rel' format. It really seems like additional types, beyond 'object', would be required to resolve these wrappers. On alternate media types beyond JSON, I'd propose that we tackle that discussion in a separate issue, to keep focused on the frequently discussed JSON based formats. |
By "Resource a passion" I presume you mean "Resource Expansion"? :) Not sure what you mean by additional types, beyond 'object' example?. But like you said its worth breaking this issue into smaller focused issues
|
I'm having a real hard time creating a response to this. Let me start with some low hanging fruit. @dilipkrish In the example you show, you are not really describing Link Relation Types, instead you are declaring what Link Relation Types might be present in a response. That's a valid piece of information but not quite the same as describing link relation types. Maybe I'm just being pedantic. It has been known to happen :-) I've always thought OpenAPI would best be able to describe Link Relation Types by defining a notion of OperationClass where the definition can be reused by Operations. But that's an idea for another thread. @jasonh-n-austin I have two thoughts about this issue.
It is interesting to note that this wrapper/model distinction parallels the formats/profiles distinction that the hypermedia folks talk about, and have been talking about for years, without a whole lot of success. |
@darrelmiller Want to make sure I understand your comment
My intent was to do both So, going back to the example above, //snip
- rel: "delete"
$urlRef: "#paths/pet"
method: "delete"
//snip What that is describing is that there is a "delete" link relation; and that it is further described by another swagger operation ( Probably a better example would've been to make it concrete like so? //snip
- rel: "delete-pet" //<------
$urlRef: "#paths/pet"
method: "delete"
//snip Hope that makes sense. thoughts? |
I'm keenly interested in describing link relations associated with resources (and their response schema). I think that should be a separate topic, so as to not get side tracked from the OP on wrapper objects. However, in @dilipkrish last response, link relation That is, the names of the link relations are defined by the API context, not determined by the (Open API) description/structure and its namespace constraints. |
parent issue #586 |
I am evaluating this as a possible use case for overlays, OAI/Overlay-Specification#9. I don't think overlays would be useful here, links are part of openapi3 now and there is also workflow SIG. |
This has been solved in OAS 3.1 by using dynamic references to define generic types. |
Some existing hypermedia formats (such as JSON API, HAL, JSON Collection) define a standard 'wrapper' for responses (not unlike the old SOAP envelope, in some ways).
Current OpenAPI conventions are inconvenient and very redundant in describing these formats. An OpenAPI method of describing APIs with these formats would produce specs that are much DRYer.
#136
#519
#522
#476
Solutions are not described here yet, but this should serve as a point to consolidate concepts from prior feedback when evaluating potential solutions.
@darrelmiller input here would be great.
The text was updated successfully, but these errors were encountered: