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 all commits
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
1 change: 1 addition & 0 deletions examples/internal/clients/abe/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ go_library(
"client.go",
"configuration.go",
"enum_helper.go",
"model_a_bit_of_everything.go",
"model_a_bit_of_everything_nested.go",
"model_examplepb_a_bit_of_everything.go",
"model_examplepb_a_bit_of_everything_repeated.go",
Expand Down
151 changes: 148 additions & 3 deletions examples/internal/clients/abe/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ paths:
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbABitOfEverything"
$ref: "#/definitions/A bit of everything"
x-exportParamName: "Body"
responses:
200:
Expand Down Expand Up @@ -2353,7 +2353,7 @@ paths:
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbBody"
type: "object"
x-exportParamName: "Body"
responses:
200:
Expand Down Expand Up @@ -2731,7 +2731,8 @@ definitions:
description: "Intentionaly complicated message type to cover many features of\
\ Protobuf."
example:
uuid: "0cf361e1-4b44-483d-a159-54dabdf7e814"
int64_value: 12
double_value: 12.3
examplepbABitOfEverythingRepeated:
type: "object"
properties:
Expand Down Expand Up @@ -3013,6 +3014,150 @@ definitions:
properties:
value:
type: "string"
A bit of everything:
type: "object"
required:
- "doubleValue"
- "floatValue"
- "int64Value"
- "requiredStringViaFieldBehaviorAnnotation"
properties:
singleNested:
$ref: "#/definitions/ABitOfEverythingNested"
nested:
type: "array"
items:
$ref: "#/definitions/ABitOfEverythingNested"
floatValue:
type: "number"
format: "float"
description: "Float value field"
default: 0.2
doubleValue:
type: "number"
format: "double"
int64Value:
type: "string"
format: "int64"
uint64Value:
type: "string"
format: "uint64"
int32Value:
type: "integer"
format: "int32"
fixed64Value:
type: "string"
format: "uint64"
fixed32Value:
type: "integer"
format: "int64"
boolValue:
type: "boolean"
stringValue:
type: "string"
bytesValue:
type: "string"
format: "byte"
pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
uint32Value:
type: "integer"
format: "int64"
enumValue:
$ref: "#/definitions/examplepbNumericEnum"
pathEnumValue:
$ref: "#/definitions/pathenumPathEnum"
nestedPathEnumValue:
$ref: "#/definitions/MessagePathEnumNestedPathEnum"
sfixed32Value:
type: "integer"
format: "int32"
sfixed64Value:
type: "string"
format: "int64"
sint32Value:
type: "integer"
format: "int32"
sint64Value:
type: "string"
format: "int64"
repeatedStringValue:
type: "array"
items:
type: "string"
oneofEmpty:
type: "object"
properties: {}
oneofString:
type: "string"
mapValue:
type: "object"
additionalProperties:
$ref: "#/definitions/examplepbNumericEnum"
mappedStringValue:
type: "object"
additionalProperties:
type: "string"
mappedNestedValue:
type: "object"
additionalProperties:
$ref: "#/definitions/ABitOfEverythingNested"
nonConventionalNameValue:
type: "string"
timestampValue:
type: "string"
format: "date-time"
repeatedEnumValue:
type: "array"
title: "repeated enum value. it is comma-separated in query"
items:
$ref: "#/definitions/examplepbNumericEnum"
repeatedEnumAnnotation:
type: "array"
description: "Repeated numeric enum description."
title: "Repeated numeric enum title"
items:
$ref: "#/definitions/examplepbNumericEnum"
enumValueAnnotation:
description: "Numeric enum description."
title: "Numeric enum title"
$ref: "#/definitions/examplepbNumericEnum"
repeatedStringAnnotation:
type: "array"
description: "Repeated string description."
title: "Repeated string title"
items:
type: "string"
repeatedNestedAnnotation:
type: "array"
description: "Repeated nested object description."
title: "Repeated nested object title"
items:
$ref: "#/definitions/ABitOfEverythingNested"
nestedAnnotation:
description: "Nested object description."
title: "Nested object title"
$ref: "#/definitions/ABitOfEverythingNested"
int64OverrideType:
type: "integer"
format: "int64"
requiredStringViaFieldBehaviorAnnotation:
type: "string"
title: "mark a field as required in Open API definition"
outputOnlyStringViaFieldBehaviorAnnotation:
type: "string"
title: "mark a field as readonly in Open API definition"
readOnly: true
optionalStringValue:
type: "string"
externalDocs:
description: "Find out more about ABitOfEverything"
url: "https://github.com/grpc-ecosystem/grpc-gateway"
title: "A bit of everything"
description: "Intentionaly complicated message type to cover many features of\
\ Protobuf."
example:
int64_value: 12
double_value: 12.3
externalDocs:
description: "More about gRPC-Gateway"
url: "https://github.com/grpc-ecosystem/grpc-gateway"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3341,7 +3341,7 @@ ABitOfEverythingServiceApiService

@return interface{}
*/
func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServicePostWithEmptyBody(ctx context.Context, name string, body ExamplepbBody) (interface{}, *http.Response, error) {
func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServicePostWithEmptyBody(ctx context.Context, name string, body interface{}) (interface{}, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
Expand Down Expand Up @@ -3654,7 +3654,7 @@ ABitOfEverythingServiceApiService

@return interface{}
*/
func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceUpdate(ctx context.Context, uuid string, body ExamplepbABitOfEverything) (interface{}, *http.Response, error) {
func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceUpdate(ctx context.Context, uuid string, body ABitOfEverything) (interface{}, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Put")
localVarPostBody interface{}
Expand Down
63 changes: 63 additions & 0 deletions examples/internal/clients/abe/model_a_bit_of_everything.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* A Bit of Everything
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 1.0
* Contact: [email protected]
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

package abe

import (
"time"
)

// Intentionaly complicated message type to cover many features of Protobuf.
type ABitOfEverything struct {
SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"`
Nested []ABitOfEverythingNested `json:"nested,omitempty"`
// Float value field
FloatValue float32 `json:"floatValue"`
DoubleValue float64 `json:"doubleValue"`
Int64Value string `json:"int64Value"`
Uint64Value string `json:"uint64Value,omitempty"`
Int32Value int32 `json:"int32Value,omitempty"`
Fixed64Value string `json:"fixed64Value,omitempty"`
Fixed32Value int64 `json:"fixed32Value,omitempty"`
BoolValue bool `json:"boolValue,omitempty"`
StringValue string `json:"stringValue,omitempty"`
BytesValue string `json:"bytesValue,omitempty"`
Uint32Value int64 `json:"uint32Value,omitempty"`
EnumValue *ExamplepbNumericEnum `json:"enumValue,omitempty"`
PathEnumValue *PathenumPathEnum `json:"pathEnumValue,omitempty"`
NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nestedPathEnumValue,omitempty"`
Sfixed32Value int32 `json:"sfixed32Value,omitempty"`
Sfixed64Value string `json:"sfixed64Value,omitempty"`
Sint32Value int32 `json:"sint32Value,omitempty"`
Sint64Value string `json:"sint64Value,omitempty"`
RepeatedStringValue []string `json:"repeatedStringValue,omitempty"`
OneofEmpty *interface{} `json:"oneofEmpty,omitempty"`
OneofString string `json:"oneofString,omitempty"`
MapValue map[string]ExamplepbNumericEnum `json:"mapValue,omitempty"`
MappedStringValue map[string]string `json:"mappedStringValue,omitempty"`
MappedNestedValue map[string]ABitOfEverythingNested `json:"mappedNestedValue,omitempty"`
NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"`
TimestampValue time.Time `json:"timestampValue,omitempty"`
RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"`
// Repeated numeric enum description.
RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"`
// Numeric enum description.
EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"`
// Repeated string description.
RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"`
// Repeated nested object description.
RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"`
// Nested object description.
NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"`
Int64OverrideType int64 `json:"int64OverrideType,omitempty"`
RequiredStringViaFieldBehaviorAnnotation string `json:"requiredStringViaFieldBehaviorAnnotation"`
OutputOnlyStringViaFieldBehaviorAnnotation string `json:"outputOnlyStringViaFieldBehaviorAnnotation,omitempty"`
OptionalStringValue string `json:"optionalStringValue,omitempty"`
}
Loading