-
Notifications
You must be signed in to change notification settings - Fork 762
Fixing support for matrix parameters when not present in the path definition #1218
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @ilgrosso! In order to get this merged, some reworking needs to happen.
The exports in parameter-builders.js
correspond to valid parameter in
values defined by the OpenAPI specification (see their usage here, here, and here). Since matrix
is a style
value, it's actually handled in the OAS3 Style Serializer (specifically here, here, here, and here).
Beyond that, your PR needs to include new or modified tests for your changes. There are already some style: matrix
tests for path parameters (the only type of parameter that uses matrix) here, so modifying those would be a good starting point.
Lastly, you'll also need to modify your code style to be compliant with our linter, as you'll notice in the failing CI report from your first commit. You can run npm run lint
to get a linter report locally as you make your changes, or install an ESLint integration into your code editor.
Thanks again!
Thanks for your indications @shockey and clarifications about the matrix parameter support in OAS3 - the current work was produced under bad supposition, it seems. |
@ilgrosso no worries! there’s a lot of nuance in the code, it’s not hard to miss 😄 feel free to ping me here if you need any help. |
Please take a look @shockey - now |
Ok, now it should be working, please @shockey have a look... |
@shockey as you can see from Travis CI, the checks on Node.js 6.9 went green but the ones on Node.js 4.7 failed because the distribution could not be downloaded |
@ilgrosso thanks for the heads up, I just requeued the 4.7 one; looks like nodes.org was having some trouble yesterday. |
thx @shockey - now all is green it seems :-) |
Thanks @ilgrosso! One last request - can you add some tests? See my review above for some pointers 😄 |
@shockey test added, sorry for overlooking this. |
Hi @shockey, what's missing to accept this PR? |
Hi @ilgrosso! The test cases you added illuminated what you meant in your PR title: It's my fault for not digging into that earlier in the process. From the 3.0.0 Definitions section:
and from the Parameter Object section:
I reached out to an OpenAPI TSC (the committee that writes the OpenAPI Specification) member, and they confirmed for me that path parameters must be referenced in the path key name in order to be used - path parameter values should not be concatenated to request URLs if the parameter is not referenced in the path itself. As a result, the changes you want to make would go against the specification. Again, my apologies for not addressing this earlier in the PR process! All of that being said, I'd be happy to accept any improvements to how we generate matrix path parameters when the parameter is being used in the path name. |
I see: then it seems there is a bigger problem as, being constrained to be just a "style" of path parameters, matrix parameters do not have yet an adequate definition in OpenAPI v3. As far as I can tell, in fact, matrix parameters are used by JAX-RS as an optional part of the URL (similarly to query parameters), while path parameters are a mandatory part of the URL. When I saw OAI/OpenAPI-Specification#69 closed, I though that finally the vexata quaestio was solved, and that people writing REST in Java could finally use freely matrix parameters; unfortunately, it seems we are not yet to that point. Thanks for clarification, @shockey and sorry for the rant. I am closing this PR now. |
@ilgrosso, I see where you're coming from. I don't really see a way to get around this, since as you mentioned (a) path parameters must be required and (b) required parameters can't provide a default value. The only way to do this, then, would be to always manually provide an empty value. As I'm sure you know, there's not much we can do about that here. Consider raising this issue over at the specification repo - since matrix is supported now, I'd imagine this usability issue would get some attention. |
…ot get accepted, let's go back to local patch for Swagger UI
…ot get accepted, let's go back to local patch for Swagger UI
Description
While already part of the OpanApi Spec 3.0, Matrix parameters are currently ignored by swagger-js and, by consequence, by swagger-ui.
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
package.json
)Checklist: