Skip to content
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

Support for repeated path parameters #741

Closed
maros7 opened this issue Aug 29, 2018 · 3 comments
Closed

Support for repeated path parameters #741

maros7 opened this issue Aug 29, 2018 · 3 comments

Comments

@maros7
Copy link

maros7 commented Aug 29, 2018

I wonder if you would consider adding support for repeated path parameters á la "collectionFormat": "csv" from Swagger/OpenAPI? See e.g. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#path-item-object-example. I would be interested in submitting a PR myself.

@johanbrandhorst
Copy link
Collaborator

Path parameters largely just need to be compatible with the http.proto HttpRule definition: https://github.com/googleapis/api-common-protos/blob/master/google/api/http.proto#L45. If your proposal can be described using that, I don't see why not :).

@maros7
Copy link
Author

maros7 commented Aug 29, 2018

Ideally I’d like to follow the OpenAPI 2.0 standard which allows csv (default), ssv, tsv, pipe and multi. The latter is only for query params though. But I don’t see how it would be possible to specify a ”separator” using the http annotation. As I see it I can implement/hard code csv and my assumption is that it would be sufficient for most people. The http annotation documentation also seems to state that this should be the way to do it if I interperet it and RFC 6570 (https://tools.ietf.org/html/rfc6570#section-3.2.2) correctly. On the other hand I guess it could be possible to have a custom annotation, like you have for the swagger generator (https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-swagger/options/annotations.proto) to support specifying the ”separator” type. Yet another option could be to make it configureable via a parameter provided to the plug-in, e.g. ”repeated_field_separator=csv”. What is your take?

@maros7
Copy link
Author

maros7 commented Aug 30, 2018

Sadly swagger-codgen doesn't support arrays as path parameters, even if the 2.0 spec says that it is supported. See https://github.com/swagger-api/swagger-codegen/blob/v2.2.2/modules/swagger-codegen/src/main/resources/go/api.mustache#L45. It will only generate correct code for arrays as query parameters. See https://github.com/swagger-api/swagger-codegen/blob/v2.2.2/modules/swagger-codegen/src/main/resources/go/api.mustache#L85-L86. Nonetheless, I'll submit a PR for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants