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

Fix #201: Exclude path params from body schemas. #1145

Closed
Closed
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/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
137 changes: 135 additions & 2 deletions examples/clients/abe/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,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 @@ -1792,7 +1792,7 @@ paths:
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbBody"
type: "object"
x-exportParamName: "Body"
responses:
200:
Expand Down Expand Up @@ -2388,6 +2388,139 @@ definitions:
properties:
value:
type: "string"
A bit of everything:
johanbrandhorst marked this conversation as resolved.
Show resolved Hide resolved
type: "object"
required:
- "double_value"
- "int64_value"
properties:
single_nested:
$ref: "#/definitions/ABitOfEverythingNested"
nested:
type: "array"
items:
$ref: "#/definitions/ABitOfEverythingNested"
float_value:
type: "number"
format: "float"
description: "Float value field"
default: 0.2
double_value:
type: "number"
format: "double"
int64_value:
type: "string"
format: "int64"
uint64_value:
type: "string"
format: "uint64"
int32_value:
type: "integer"
format: "int32"
fixed64_value:
type: "string"
format: "uint64"
fixed32_value:
type: "integer"
format: "int64"
bool_value:
type: "boolean"
format: "boolean"
string_value:
type: "string"
bytes_value:
type: "string"
format: "byte"
pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
uint32_value:
type: "integer"
format: "int64"
enum_value:
$ref: "#/definitions/examplepbNumericEnum"
path_enum_value:
$ref: "#/definitions/pathenumPathEnum"
nested_path_enum_value:
$ref: "#/definitions/MessagePathEnumNestedPathEnum"
sfixed32_value:
type: "integer"
format: "int32"
sfixed64_value:
type: "string"
format: "int64"
sint32_value:
type: "integer"
format: "int32"
sint64_value:
type: "string"
format: "int64"
repeated_string_value:
type: "array"
items:
type: "string"
oneof_empty:
type: "object"
properties: {}
oneof_string:
type: "string"
map_value:
type: "object"
additionalProperties:
$ref: "#/definitions/examplepbNumericEnum"
mapped_string_value:
type: "object"
additionalProperties:
type: "string"
mapped_nested_value:
type: "object"
additionalProperties:
$ref: "#/definitions/ABitOfEverythingNested"
nonConventionalNameValue:
type: "string"
timestamp_value:
type: "string"
format: "date-time"
repeated_enum_value:
type: "array"
title: "repeated enum value. it is comma-separated in query"
items:
$ref: "#/definitions/examplepbNumericEnum"
repeated_enum_annotation:
type: "array"
description: "Repeated numeric enum description."
title: "Repeated numeric enum title"
items:
$ref: "#/definitions/examplepbNumericEnum"
enum_value_annotation:
description: "Numeric enum description."
title: "Numeric enum title"
$ref: "#/definitions/examplepbNumericEnum"
repeated_string_annotation:
type: "array"
description: "Repeated string description."
title: "Repeated string title"
items:
type: "string"
repeated_nested_annotation:
type: "array"
description: "Repeated nested object description."
title: "Repeated nested object title"
items:
$ref: "#/definitions/ABitOfEverythingNested"
nested_annotation:
description: "Nested object description."
title: "Nested object title"
$ref: "#/definitions/ABitOfEverythingNested"
int64_override_type:
type: "integer"
format: "int64"
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:
uuid: "0cf361e1-4b44-483d-a159-54dabdf7e814"
externalDocs:
description: "More about gRPC-Gateway"
url: "https://github.com/grpc-ecosystem/grpc-gateway"
Expand Down
4 changes: 2 additions & 2 deletions examples/clients/abe/api_a_bit_of_everything_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ ABitOfEverythingServiceApiService

@return interface{}
*/
func (a *ABitOfEverythingServiceApiService) PostWithEmptyBody(ctx context.Context, name string, body ExamplepbBody) (interface{}, *http.Response, error) {
func (a *ABitOfEverythingServiceApiService) PostWithEmptyBody(ctx context.Context, name string, body interface{}) (interface{}, *http.Response, error) {
johanbrandhorst marked this conversation as resolved.
Show resolved Hide resolved
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
Expand Down Expand Up @@ -2810,7 +2810,7 @@ ABitOfEverythingServiceApiService

@return interface{}
*/
func (a *ABitOfEverythingServiceApiService) Update(ctx context.Context, uuid string, body ExamplepbABitOfEverything) (interface{}, *http.Response, error) {
func (a *ABitOfEverythingServiceApiService) Update(ctx context.Context, uuid string, body ABitOfEverything) (interface{}, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Put")
localVarPostBody interface{}
Expand Down
60 changes: 60 additions & 0 deletions examples/clients/abe/model_a_bit_of_everything.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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 {
johanbrandhorst marked this conversation as resolved.
Show resolved Hide resolved
SingleNested *ABitOfEverythingNested `json:"single_nested,omitempty"`
Nested []ABitOfEverythingNested `json:"nested,omitempty"`
// Float value field
FloatValue float32 `json:"float_value,omitempty"`
DoubleValue float64 `json:"double_value"`
Int64Value string `json:"int64_value"`
Uint64Value string `json:"uint64_value,omitempty"`
Int32Value int32 `json:"int32_value,omitempty"`
Fixed64Value string `json:"fixed64_value,omitempty"`
Fixed32Value int64 `json:"fixed32_value,omitempty"`
BoolValue bool `json:"bool_value,omitempty"`
StringValue string `json:"string_value,omitempty"`
BytesValue string `json:"bytes_value,omitempty"`
Uint32Value int64 `json:"uint32_value,omitempty"`
EnumValue *ExamplepbNumericEnum `json:"enum_value,omitempty"`
PathEnumValue *PathenumPathEnum `json:"path_enum_value,omitempty"`
NestedPathEnumValue *MessagePathEnumNestedPathEnum `json:"nested_path_enum_value,omitempty"`
Sfixed32Value int32 `json:"sfixed32_value,omitempty"`
Sfixed64Value string `json:"sfixed64_value,omitempty"`
Sint32Value int32 `json:"sint32_value,omitempty"`
Sint64Value string `json:"sint64_value,omitempty"`
RepeatedStringValue []string `json:"repeated_string_value,omitempty"`
OneofEmpty *interface{} `json:"oneof_empty,omitempty"`
OneofString string `json:"oneof_string,omitempty"`
MapValue map[string]ExamplepbNumericEnum `json:"map_value,omitempty"`
MappedStringValue map[string]string `json:"mapped_string_value,omitempty"`
MappedNestedValue map[string]ABitOfEverythingNested `json:"mapped_nested_value,omitempty"`
NonConventionalNameValue string `json:"nonConventionalNameValue,omitempty"`
TimestampValue time.Time `json:"timestamp_value,omitempty"`
RepeatedEnumValue []ExamplepbNumericEnum `json:"repeated_enum_value,omitempty"`
// Repeated numeric enum description.
RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeated_enum_annotation,omitempty"`
// Numeric enum description.
EnumValueAnnotation *ExamplepbNumericEnum `json:"enum_value_annotation,omitempty"`
// Repeated string description.
RepeatedStringAnnotation []string `json:"repeated_string_annotation,omitempty"`
// Repeated nested object description.
RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeated_nested_annotation,omitempty"`
// Nested object description.
NestedAnnotation *ABitOfEverythingNested `json:"nested_annotation,omitempty"`
Int64OverrideType int64 `json:"int64_override_type,omitempty"`
}
Loading