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

Turn off UseProtoNames in default marshaler #1376

Merged
merged 2 commits into from
May 22, 2020
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
376 changes: 187 additions & 189 deletions examples/internal/clients/abe/api/swagger.yaml

Large diffs are not rendered by default.

272 changes: 136 additions & 136 deletions examples/internal/clients/abe/api_a_bit_of_everything_service.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,46 @@ import (

// Intentionaly complicated message type to cover many features of Protobuf.
type ExamplepbABitOfEverything struct {
SingleNested *ABitOfEverythingNested `json:"single_nested,omitempty"`
SingleNested *ABitOfEverythingNested `json:"singleNested,omitempty"`
Uuid string `json:"uuid"`
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"`
FloatValue float32 `json:"floatValue,omitempty"`
DoubleValue float64 `json:"doubleValue,omitempty"`
Int64Value string `json:"int64Value,omitempty"`
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:"timestamp_value,omitempty"`
RepeatedEnumValue []ExamplepbNumericEnum `json:"repeated_enum_value,omitempty"`
TimestampValue time.Time `json:"timestampValue,omitempty"`
RepeatedEnumValue []ExamplepbNumericEnum `json:"repeatedEnumValue,omitempty"`
// Repeated numeric enum description.
RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeated_enum_annotation,omitempty"`
RepeatedEnumAnnotation []ExamplepbNumericEnum `json:"repeatedEnumAnnotation,omitempty"`
// Numeric enum description.
EnumValueAnnotation *ExamplepbNumericEnum `json:"enum_value_annotation,omitempty"`
EnumValueAnnotation *ExamplepbNumericEnum `json:"enumValueAnnotation,omitempty"`
// Repeated string description.
RepeatedStringAnnotation []string `json:"repeated_string_annotation,omitempty"`
RepeatedStringAnnotation []string `json:"repeatedStringAnnotation,omitempty"`
// Repeated nested object description.
RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeated_nested_annotation,omitempty"`
RepeatedNestedAnnotation []ABitOfEverythingNested `json:"repeatedNestedAnnotation,omitempty"`
// Nested object description.
NestedAnnotation *ABitOfEverythingNested `json:"nested_annotation,omitempty"`
Int64OverrideType int64 `json:"int64_override_type,omitempty"`
NestedAnnotation *ABitOfEverythingNested `json:"nestedAnnotation,omitempty"`
Int64OverrideType int64 `json:"int64OverrideType,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
package abe

type ExamplepbABitOfEverythingRepeated struct {
PathRepeatedFloatValue []float32 `json:"path_repeated_float_value,omitempty"`
PathRepeatedDoubleValue []float64 `json:"path_repeated_double_value,omitempty"`
PathRepeatedInt64Value []string `json:"path_repeated_int64_value,omitempty"`
PathRepeatedUint64Value []string `json:"path_repeated_uint64_value,omitempty"`
PathRepeatedInt32Value []int32 `json:"path_repeated_int32_value,omitempty"`
PathRepeatedFixed64Value []string `json:"path_repeated_fixed64_value,omitempty"`
PathRepeatedFixed32Value []int64 `json:"path_repeated_fixed32_value,omitempty"`
PathRepeatedBoolValue []bool `json:"path_repeated_bool_value,omitempty"`
PathRepeatedStringValue []string `json:"path_repeated_string_value,omitempty"`
PathRepeatedBytesValue []string `json:"path_repeated_bytes_value,omitempty"`
PathRepeatedUint32Value []int64 `json:"path_repeated_uint32_value,omitempty"`
PathRepeatedEnumValue []ExamplepbNumericEnum `json:"path_repeated_enum_value,omitempty"`
PathRepeatedSfixed32Value []int32 `json:"path_repeated_sfixed32_value,omitempty"`
PathRepeatedSfixed64Value []string `json:"path_repeated_sfixed64_value,omitempty"`
PathRepeatedSint32Value []int32 `json:"path_repeated_sint32_value,omitempty"`
PathRepeatedSint64Value []string `json:"path_repeated_sint64_value,omitempty"`
PathRepeatedFloatValue []float32 `json:"pathRepeatedFloatValue,omitempty"`
PathRepeatedDoubleValue []float64 `json:"pathRepeatedDoubleValue,omitempty"`
PathRepeatedInt64Value []string `json:"pathRepeatedInt64Value,omitempty"`
PathRepeatedUint64Value []string `json:"pathRepeatedUint64Value,omitempty"`
PathRepeatedInt32Value []int32 `json:"pathRepeatedInt32Value,omitempty"`
PathRepeatedFixed64Value []string `json:"pathRepeatedFixed64Value,omitempty"`
PathRepeatedFixed32Value []int64 `json:"pathRepeatedFixed32Value,omitempty"`
PathRepeatedBoolValue []bool `json:"pathRepeatedBoolValue,omitempty"`
PathRepeatedStringValue []string `json:"pathRepeatedStringValue,omitempty"`
PathRepeatedBytesValue []string `json:"pathRepeatedBytesValue,omitempty"`
PathRepeatedUint32Value []int64 `json:"pathRepeatedUint32Value,omitempty"`
PathRepeatedEnumValue []ExamplepbNumericEnum `json:"pathRepeatedEnumValue,omitempty"`
PathRepeatedSfixed32Value []int32 `json:"pathRepeatedSfixed32Value,omitempty"`
PathRepeatedSfixed64Value []string `json:"pathRepeatedSfixed64Value,omitempty"`
PathRepeatedSint32Value []int32 `json:"pathRepeatedSint32Value,omitempty"`
PathRepeatedSint64Value []string `json:"pathRepeatedSint64Value,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ package abe

type ExamplepbUpdateV2Request struct {
Abe *ExamplepbABitOfEverything `json:"abe,omitempty"`
UpdateMask *ProtobufFieldMask `json:"update_mask,omitempty"`
UpdateMask *ProtobufFieldMask `json:"updateMask,omitempty"`
}
2 changes: 1 addition & 1 deletion examples/internal/clients/abe/model_protobuf_any.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package abe
// `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message. Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type. Example 1: Pack and unpack a message in C++. Foo foo = ...; Any any; any.PackFrom(foo); ... if (any.UnpackTo(&foo)) { ... } Example 2: Pack and unpack a message in Java. Foo foo = ...; Any any = Any.pack(foo); ... if (any.is(Foo.class)) { foo = any.unpack(Foo.class); } Example 3: Pack and unpack a message in Python. foo = Foo(...) any = Any() any.Pack(foo) ... if any.Is(Foo.DESCRIPTOR): any.Unpack(foo) ... Example 4: Pack and unpack a message in Go foo := &pb.Foo{...} any, err := ptypes.MarshalAny(foo) ... foo := &pb.Foo{} if err := ptypes.UnmarshalAny(any, foo); err != nil { ... } The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example \"foo.bar.com/x/y.z\" will yield type name \"y.z\". JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example: package google.profile; message Person { string first_name = 1; string last_name = 2; } { \"@type\": \"type.googleapis.com/google.profile.Person\", \"firstName\": <string>, \"lastName\": <string> } If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]): { \"@type\": \"type.googleapis.com/google.protobuf.Duration\", \"value\": \"1.212s\" }
type ProtobufAny struct {
// A URL/resource name that uniquely identifies the type of the serialized protocol buffer message. This string must contain at least one \"/\" character. The last segment of the URL's path must represent the fully qualified name of the type (as in `path/google.protobuf.Duration`). The name should be in a canonical form (e.g., leading \".\" is not accepted). In practice, teams usually precompile into the binary all types that they expect it to use in the context of Any. However, for URLs which use the scheme `http`, `https`, or no scheme, one can optionally set up a type server that maps type URLs to message definitions as follows: * If no scheme is provided, `https` is assumed. * An HTTP GET on the URL must yield a [google.protobuf.Type][] value in binary format, or produce an error. * Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.) Note: this functionality is not currently available in the official protobuf release, and it is not used for type URLs beginning with type.googleapis.com. Schemes other than `http`, `https` (or the empty scheme) might be used with implementation specific semantics.
TypeUrl string `json:"type_url,omitempty"`
TypeUrl string `json:"typeUrl,omitempty"`
// Must be a valid serialized protocol buffer of the above specified type.
Value string `json:"value,omitempty"`
}
18 changes: 9 additions & 9 deletions examples/internal/clients/echo/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ paths:
type: "string"
format: "int64"
x-exportParamName: "Num"
- name: "line_num"
- name: "lineNum"
in: "query"
required: false
type: "string"
Expand Down Expand Up @@ -132,7 +132,7 @@ paths:
required: true
type: "string"
x-exportParamName: "Lang"
- name: "line_num"
- name: "lineNum"
in: "query"
required: false
type: "string"
Expand Down Expand Up @@ -181,7 +181,7 @@ paths:
description: "An unexpected error response"
schema:
$ref: "#/definitions/rpcStatus"
/v1/example/echo1/{id}/{line_num}/{status.note}:
/v1/example/echo1/{id}/{lineNum}/{status.note}:
get:
tags:
- "EchoService"
Expand All @@ -195,7 +195,7 @@ paths:
required: true
type: "string"
x-exportParamName: "Id"
- name: "line_num"
- name: "lineNum"
in: "path"
required: true
type: "string"
Expand Down Expand Up @@ -276,7 +276,7 @@ paths:
format: "int64"
x-exportParamName: "Num"
x-optionalDataType: "String"
- name: "line_num"
- name: "lineNum"
in: "query"
required: false
type: "string"
Expand Down Expand Up @@ -362,7 +362,7 @@ paths:
format: "int64"
x-exportParamName: "Num"
x-optionalDataType: "String"
- name: "line_num"
- name: "lineNum"
in: "query"
required: false
type: "string"
Expand Down Expand Up @@ -439,7 +439,7 @@ definitions:
num:
type: "string"
format: "int64"
line_num:
lineNum:
type: "string"
format: "int64"
lang:
Expand All @@ -456,8 +456,8 @@ definitions:
"no":
note: "note"
progress: "progress"
line_num: "line_num"
num: "num"
lineNum: "lineNum"
en: "en"
id: "id"
lang: "lang"
Expand All @@ -467,7 +467,7 @@ definitions:
protobufAny:
type: "object"
properties:
type_url:
typeUrl:
type: "string"
description: "A URL/resource name that uniquely identifies the type of the\
\ serialized\nprotocol buffer message. This string must contain at least\n\
Expand Down
12 changes: 6 additions & 6 deletions examples/internal/clients/echo/api_echo_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (a *EchoServiceApiService) EchoServiceEcho2(ctx context.Context, id string,
localVarFormParams := url.Values{}

if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() {
localVarQueryParams.Add("line_num", parameterToString(localVarOptionals.LineNum.Value(), ""))
localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.Lang.IsSet() {
localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), ""))
Expand Down Expand Up @@ -315,7 +315,7 @@ func (a *EchoServiceApiService) EchoServiceEcho3(ctx context.Context, id string,
localVarFormParams := url.Values{}

if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() {
localVarQueryParams.Add("line_num", parameterToString(localVarOptionals.LineNum.Value(), ""))
localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() {
localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), ""))
Expand Down Expand Up @@ -442,9 +442,9 @@ func (a *EchoServiceApiService) EchoServiceEcho4(ctx context.Context, id string,
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/v1/example/echo1/{id}/{line_num}/{status.note}"
localVarPath := a.client.cfg.BasePath + "/v1/example/echo1/{id}/{lineNum}/{status.note}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
localVarPath = strings.Replace(localVarPath, "{"+"line_num"+"}", fmt.Sprintf("%v", lineNum), -1)
localVarPath = strings.Replace(localVarPath, "{"+"lineNum"+"}", fmt.Sprintf("%v", lineNum), -1)
localVarPath = strings.Replace(localVarPath, "{"+"status.note"+"}", fmt.Sprintf("%v", statusNote), -1)

localVarHeaderParams := make(map[string]string)
Expand Down Expand Up @@ -592,7 +592,7 @@ func (a *EchoServiceApiService) EchoServiceEcho5(ctx context.Context, noNote str
localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() {
localVarQueryParams.Add("line_num", parameterToString(localVarOptionals.LineNum.Value(), ""))
localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.Lang.IsSet() {
localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), ""))
Expand Down Expand Up @@ -833,7 +833,7 @@ func (a *EchoServiceApiService) EchoServiceEchoDelete(ctx context.Context, local
localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() {
localVarQueryParams.Add("line_num", parameterToString(localVarOptionals.LineNum.Value(), ""))
localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.Lang.IsSet() {
localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ExamplepbSimpleMessage struct {
// Id represents the message identifier.
Id string `json:"id,omitempty"`
Num string `json:"num,omitempty"`
LineNum string `json:"line_num,omitempty"`
LineNum string `json:"lineNum,omitempty"`
Lang string `json:"lang,omitempty"`
Status *ExamplepbEmbedded `json:"status,omitempty"`
En string `json:"en,omitempty"`
Expand Down
Loading