-
Notifications
You must be signed in to change notification settings - Fork 251
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
protoc-gen-openapi: path parameters are repeated in the body when using body: "*"
#323
Comments
cc @timburks |
I also find that quite confusing. Is there an opinion on this from the developers? Thanks! |
Hello everyone, I also encountered this problem when switching from protoc-gen-openapiv2 to gnostic. Would it be possible to reprioritize this issue and evaluate istvan-hevele's PR in this regard? Thank you |
When a request has both path parameters and body = "*", the path parameters were being repeated in the body. But according to the docs: the special name `*` is used to define that every field not bound by the path template should be mapped to the request body. This commit does exactly that, when the body is `*` and there are some path parameters, then the a new message schema is created that does not include the path parameters. The name of the schema is the same as the message name, with the `_Body` suffix. fixes google#323
I came across this exact problem and added my own PR to fix it: #444 |
When a request has both path parameters and body = "*", the path parameters were being repeated in the body. But according to the docs: the special name `*` is used to define that every field not bound by the path template should be mapped to the request body. This commit does exactly that, when the body is `*` and there are some path parameters, then the a new message schema is created that does not include the path parameters. The name of the schema is the same as the message name, with the `_Body` suffix. fixes google#323
When a request has both path parameters and body = "*", the path parameters were being repeated in the body. But according to the docs: the special name `*` is used to define that every field not bound by the path template should be mapped to the request body. This commit does exactly that, when the body is `*` and there are some path parameters, then the a new message schema is created that does not include the path parameters. The name of the schema is the same as the message name, with the `_Body` suffix. fixes google#323
When a request has both path parameters and body = "*", the path parameters were being repeated in the body. But according to the docs: the special name `*` is used to define that every field not bound by the path template should be mapped to the request body. This commit does exactly that, when the body is `*` and there are some path parameters, then the a new message schema is created that does not include the path parameters. The name of the schema is the same as the message name, with the `_Body` suffix. fixes google#323
+1 |
When a request has both path parameters and
body: "*"
, the path parameters are being repeated in the body in the resulting OpenAPI spec.Note how the following example has
name
both inparameters
andrequestBody
in the generated openapi spec.protobuf:
openapi spec:
According to use_wildcard_in_body, every field not bound by the path template should be mapped to the request body.
So fields that are bound by the path template shouldn't be in the request body.
Proposal:
In these cases, create a new schema named
{method_name}RequestBody
which doesn't contain the fields bound by the path:There's a PR on my fork that implements this proposal: istvan-hevele#1
The text was updated successfully, but these errors were encountered: