-
Notifications
You must be signed in to change notification settings - Fork 61
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
More and complete examples for serialization styles #100
Comments
A good case for a revised Wiki (see OAI/OpenAPI-Specification#1249) |
@slinkydeveloper I attempted to make the serialization rules a subset of RFC 6570's rules. https://tools.ietf.org/html/rfc6570#section-3.2.7 The idea was that you should could use an existing URI Template library to do the serialization for you. Just construct a template based on the operation definitions and "ta-da" no work to do. Let me know if there are places I failed to do that. No-one wants to have to re-write the code to deal with the crazy URL serialization rules if they don't have to. So, if you want to know how a parameter should be serialized, map the styles to prefixes, the explode to the * suffix and the allowReserved to the + prefix and try out the template in your favourite URI Template library. |
Okay i'll give a try thank you so much! |
I've published serialization examples at https://swagger.io/docs/specification/serialization/. Hope it helps! |
That's awesome thank you so much! In the project I'm working on, I've created a "unit test generator" (specific for my project) based on an oas 3 spec. This generator actually takes all operations declared in an oas 3 spec and generates a specific test to validate the correct parsing of parameters on server side. With some small changes this can be a complete server libraries/frameworks compatibility test tool. You are interested to a tool like this? |
@darrelmiller does RFC6570 specify 'prefixes' (specifically, multiple ones) or a single 'operator'? If an |
@MikeRalphson You can only have one prefix and it causes a bunch of issues. And you hit on one of them there. The only workaround is to make bar a required query parameter. This means OAS has more flexibility because we can make a query parameter not required and have it allowReserved. To be honest, I couldn't decide if this was a good or a bad thing. The allowReserved was disallowed from path parameters specifically to prevent the Until we fix the path matching problem we are going to have a mismatch between us and 6570. And we also need to decide if we are going to limit ourselves by what 6570 can't do. |
@darrelmiller thanks, that's helpful. |
@darrelmiller So, if I have a parameter that's If I take this same example and change If that is correct, it would be nice it this was spelled out a little more explicitly in the spec - the first time I read through, I read the description of |
Oh, wait, you can still have lists with RFC 6570 reserved expansions? How can I parse a comma delimited list when it's allowed to have commas in the values? 😢 |
@jwalton Sadly you are in fairly uncharted territory here. The I have done some work in my UriTemplate libary for parsing comma delimited lists and I just extracted the comma list as single value. See here I think it is impossible to tell from a template and the final URL whether the input was BTW, it is awesome that you are digging deep into this stuff. Sorry, it is so painful, but if we can find a clear set of guidance for extracting parameters from URIs based on uri templates that would be great. |
I'm working for a node.js startup in Ottawa. I started looking at OpenAPI 3, then realized there's no node.js support for it and most of the node.js swagger/v2 packages seem to not be actively maintained, so I started looking at 2, then I thought "3 is way better... How hard can it be to write a router and a parameter parser?" And now I'm finding out. :) I was debating making Of course then you couldn't rely on a nice URI Template library to do all the heavy lifting for you... But then the only URI template library I can find for node.js that has support for extracting values hasn't been updated in two years either. -_- |
It's a six-year-old standard and it's not that complex, so how many updates would you really expect? |
We could ask Geraint if he's going to keep maintaining it or would like to hand it off to someone (meaning you, not me, although I'd help out in a pinch). I'm not sure how much he pays attention to GitHub notifications but he responds to email (at the address on the JSON Schema and Relative JSON Pointer specs) |
Since the main question here is more examples, I'm going to un-assign it as I will not have time to add extensive examples in 3.0.4. Although I will leave it in the milestone for now in case someone else feels inspired. This may be better migrated to the learn.openapis.org repo, though. As for the other questions that came up, they are being tracked in other issues or addressed by a variety of PRs:
|
We are moving supplementary examples to the learn.openapis.org site, so I am going to transfer this issue so it's easier to see what issues are for the separate examples like these and what are for the examples embedded in the spec. See this issue for the decision: Obviously the specification PRs and issues listed in the previous comment will stay open here, and will actually cover a lot of what was asked (most notably a lot of detail about RFC6570 equivalence in OAI/OpenAPI-Specification#3818 and percent-encoding in OAI/OpenAPI-Specification#3859). This is just being moved to the Learn site to inform any further documentation that we can add without the difficulties of fitting it into the spec. |
In 3.0 do path parameters serialized with matrix or label style need to be mentioned in the path (as Not obvious, since they don't look like they're building the path (not separated with |
@rafalkrupinski OAS path templating just uses names which match as-is to the Parameter Object with the exact The only place where the RFC6570 expansion needs modifying is when you use I have not see any questions about this after going through all of the issues from the last several years in detail, so I think it's probably OK. We do not, at any point, talk about RFC6570 for the Path Templating notation, which is described in its own section near the top of the spec. |
OAS 3 include more complex serialization styles than Swagger 2.0 . Can you include in the spec more complete examples for every in/serialization style/explode/type combination on how a request is supposed to be done? Also where parameters need to be encoded or not. For example:
Path parameters
Cookie parameters
Query parameters
Of course this examples can be included outside the spec markdown, but they can be really useful for tool implementers. Thank you
The text was updated successfully, but these errors were encountered: