Skip to content

Fix path params being in the body #2078

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions examples/internal/clients/abe/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2349,12 +2349,6 @@ paths:
required: true
type: "string"
x-exportParamName: "Name"
- in: "body"
name: "body"
required: true
schema:
type: "object"
x-exportParamName: "Body"
responses:
200:
description: "A successful response."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3337,11 +3337,10 @@ func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceOverwriteResp
ABitOfEverythingServiceApiService
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param name
* @param body

@return interface{}
*/
func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServicePostWithEmptyBody(ctx context.Context, name string, body interface{}) (interface{}, *http.Response, error) {
func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServicePostWithEmptyBody(ctx context.Context, name string) (interface{}, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
Expand Down Expand Up @@ -3375,8 +3374,6 @@ func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServicePostWithEmpty
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
// body params
localVarPostBody = &body
if ctx != nil {
// API Key Authentication
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
Expand Down
398 changes: 199 additions & 199 deletions examples/internal/proto/examplepb/a_bit_of_everything.pb.go

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions examples/internal/proto/examplepb/a_bit_of_everything.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions examples/internal/proto/examplepb/a_bit_of_everything.proto
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,7 @@ service ABitOfEverythingService {
}
rpc PostWithEmptyBody(Body) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/v2/example/postwithemptybody/{name}",
body: "*"
post: "/v2/example/postwithemptybody/{name}"
};
}
rpc CheckGetQueryParams(ABitOfEverything) returns (ABitOfEverything) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3062,14 +3062,6 @@
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
}
],
"tags": [
Expand Down
7 changes: 5 additions & 2 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,14 +986,17 @@ func renderServices(services []*descriptor.Service, paths openapiPathsObject, re
}
}
if len(bodyExcludedFields) != 0 {
schema = renderMessageAsDefinition(meth.RequestType, reg, customRefs, bodyExcludedFields)
msgDef := renderMessageAsDefinition(meth.RequestType, reg, customRefs, bodyExcludedFields)
if msgDef.Properties == nil || len(*msgDef.Properties) == 0 {
return fmt.Errorf("not possible to create a schema for object with 0 properties for message: %s", *meth.RequestType)
}
schema = msgDef
} else {
err := schema.setRefFromFQN(meth.RequestType.FQMN(), reg)
if err != nil {
return err
}
}

} else {
schema.schemaCore = wknSchemaCore

Expand Down