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

protoc-gen-openapi: remove duplicate body params #1

Conversation

jagobagascon
Copy link
Collaborator

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.

Original PR from main gnostic repository: google#444


The only code that I modified was the cmd/protoc-gen-openapi/generator/generator.go file. The rest of the changes were autogenerated.

@jagobagascon jagobagascon force-pushed the feature/remove-path-parameters-from-body branch from f32e5e9 to da89488 Compare June 12, 2024 10:03
@jagobagascon
Copy link
Collaborator Author

It looks like yesterday's protoc-gen-go release generates code that is not compatible with the used Go 1.12 version. I changed the COMPILE-PROTOS.sh script to remove the @latest tag and use a fixed version.

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
@jagobagascon jagobagascon force-pushed the feature/remove-path-parameters-from-body branch from da89488 to 96fb53b Compare June 12, 2024 10:14
@jagobagascon jagobagascon merged commit 4d1a027 into saltosystems:main Jun 26, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants