Skip to content

Commit

Permalink
Revert "Use collectionFormat multi for query params of repeated fields (
Browse files Browse the repository at this point in the history
#902)"

This reverts commit 2b6cab6. It was found
to have introduced a swagger spec violation, see #906.
  • Loading branch information
johanbrandhorst committed Mar 13, 2019
1 parent 7aca14d commit d294104
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 147 deletions.
8 changes: 4 additions & 4 deletions examples/clients/abe/a_bit_of_everything_service_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,20 +595,20 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, si
localVarQueryParams.Add("sfixed64_value", a.Configuration.APIClient.ParameterToString(sfixed64Value, ""))
localVarQueryParams.Add("sint32_value", a.Configuration.APIClient.ParameterToString(sint32Value, ""))
localVarQueryParams.Add("sint64_value", a.Configuration.APIClient.ParameterToString(sint64Value, ""))
var repeatedStringValueCollectionFormat = "multi"
var repeatedStringValueCollectionFormat = "csv"
localVarQueryParams.Add("repeated_string_value", a.Configuration.APIClient.ParameterToString(repeatedStringValue, repeatedStringValueCollectionFormat))

localVarQueryParams.Add("oneof_string", a.Configuration.APIClient.ParameterToString(oneofString, ""))
localVarQueryParams.Add("nonConventionalNameValue", a.Configuration.APIClient.ParameterToString(nonConventionalNameValue, ""))
localVarQueryParams.Add("timestamp_value", a.Configuration.APIClient.ParameterToString(timestampValue, ""))
var repeatedEnumValueCollectionFormat = "multi"
var repeatedEnumValueCollectionFormat = "csv"
localVarQueryParams.Add("repeated_enum_value", a.Configuration.APIClient.ParameterToString(repeatedEnumValue, repeatedEnumValueCollectionFormat))

var repeatedEnumAnnotationCollectionFormat = "multi"
var repeatedEnumAnnotationCollectionFormat = "csv"
localVarQueryParams.Add("repeated_enum_annotation", a.Configuration.APIClient.ParameterToString(repeatedEnumAnnotation, repeatedEnumAnnotationCollectionFormat))

localVarQueryParams.Add("enum_value_annotation", a.Configuration.APIClient.ParameterToString(enumValueAnnotation, ""))
var repeatedStringAnnotationCollectionFormat = "multi"
var repeatedStringAnnotationCollectionFormat = "csv"
localVarQueryParams.Add("repeated_string_annotation", a.Configuration.APIClient.ParameterToString(repeatedStringAnnotation, repeatedStringAnnotationCollectionFormat))

localVarQueryParams.Add("nested_annotation.name", a.Configuration.APIClient.ParameterToString(nestedAnnotationName, ""))
Expand Down
81 changes: 27 additions & 54 deletions examples/proto/examplepb/a_bit_of_everything.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
},
{
"name": "oneof_string",
Expand Down Expand Up @@ -362,8 +361,7 @@
"ZERO",
"ONE"
]
},
"collectionFormat": "multi"
}
},
{
"name": "repeated_enum_annotation",
Expand All @@ -377,8 +375,7 @@
"ZERO",
"ONE"
]
},
"collectionFormat": "multi"
}
},
{
"name": "enum_value_annotation",
Expand All @@ -400,8 +397,7 @@
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
},
{
"name": "nested_annotation.name",
Expand Down Expand Up @@ -1530,8 +1526,7 @@
"type": "array",
"items": {
"$ref": "#/definitions/ABitOfEverythingNested"
},
"collectionFormat": "multi"
}
},
"float_value": {
"type": "number",
Expand Down Expand Up @@ -1610,8 +1605,7 @@
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
},
"oneof_empty": {
"properties": {}
Expand Down Expand Up @@ -1649,17 +1643,15 @@
"items": {
"$ref": "#/definitions/examplepbNumericEnum"
},
"title": "repeated enum value. it is comma-separated in query",
"collectionFormat": "multi"
"title": "repeated enum value. it is comma-separated in query"
},
"repeated_enum_annotation": {
"type": "array",
"items": {
"$ref": "#/definitions/examplepbNumericEnum"
},
"description": "Repeated numeric enum description.",
"title": "Repeated numeric enum title",
"collectionFormat": "multi"
"title": "Repeated numeric enum title"
},
"enum_value_annotation": {
"$ref": "#/definitions/examplepbNumericEnum",
Expand All @@ -1672,17 +1664,15 @@
"type": "string"
},
"description": "Repeated string description.",
"title": "Repeated string title",
"collectionFormat": "multi"
"title": "Repeated string title"
},
"repeated_nested_annotation": {
"type": "array",
"items": {
"$ref": "#/definitions/ABitOfEverythingNested"
},
"description": "Repeated nested object description.",
"title": "Repeated nested object title",
"collectionFormat": "multi"
"title": "Repeated nested object title"
},
"nested_annotation": {
"$ref": "#/definitions/ABitOfEverythingNested",
Expand Down Expand Up @@ -1724,126 +1714,110 @@
"type": "number",
"format": "float"
},
"title": "repeated values. they are comma-separated in path",
"collectionFormat": "multi"
"title": "repeated values. they are comma-separated in path"
},
"path_repeated_double_value": {
"type": "array",
"items": {
"type": "number",
"format": "double"
},
"collectionFormat": "multi"
}
},
"path_repeated_int64_value": {
"type": "array",
"items": {
"type": "string",
"format": "int64"
},
"collectionFormat": "multi"
}
},
"path_repeated_uint64_value": {
"type": "array",
"items": {
"type": "string",
"format": "uint64"
},
"collectionFormat": "multi"
}
},
"path_repeated_int32_value": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"collectionFormat": "multi"
}
},
"path_repeated_fixed64_value": {
"type": "array",
"items": {
"type": "string",
"format": "uint64"
},
"collectionFormat": "multi"
}
},
"path_repeated_fixed32_value": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"collectionFormat": "multi"
}
},
"path_repeated_bool_value": {
"type": "array",
"items": {
"type": "boolean",
"format": "boolean"
},
"collectionFormat": "multi"
}
},
"path_repeated_string_value": {
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
},
"path_repeated_bytes_value": {
"type": "array",
"items": {
"type": "string",
"format": "byte"
},
"collectionFormat": "multi"
}
},
"path_repeated_uint32_value": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"collectionFormat": "multi"
}
},
"path_repeated_enum_value": {
"type": "array",
"items": {
"$ref": "#/definitions/examplepbNumericEnum"
},
"collectionFormat": "multi"
}
},
"path_repeated_sfixed32_value": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"collectionFormat": "multi"
}
},
"path_repeated_sfixed64_value": {
"type": "array",
"items": {
"type": "string",
"format": "int64"
},
"collectionFormat": "multi"
}
},
"path_repeated_sint32_value": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"collectionFormat": "multi"
}
},
"path_repeated_sint64_value": {
"type": "array",
"items": {
"type": "string",
"format": "int64"
},
"collectionFormat": "multi"
}
}
},
"title": "ABitOfEverythingRepeated is used to validate repeated path parameter functionality"
Expand Down Expand Up @@ -1893,8 +1867,7 @@
"items": {
"type": "string"
},
"description": "The set of field mask paths.",
"collectionFormat": "multi"
"description": "The set of field mask paths."
}
},
"description": "paths: \"f.a\"\n paths: \"f.b.d\"\n\nHere `f` represents a field in some root message, `a` and `b`\nfields in the message found in `f`, and `d` a field found in the\nmessage in `f.b`.\n\nField masks are used to specify a subset of fields that should be\nreturned by a get operation or modified by an update operation.\nField masks also have a custom JSON encoding (see below).\n\n# Field Masks in Projections\n\nWhen used in the context of a projection, a response message or\nsub-message is filtered by the API to only contain those fields as\nspecified in the mask. For example, if the mask in the previous\nexample is applied to a response message as follows:\n\n f {\n a : 22\n b {\n d : 1\n x : 2\n }\n y : 13\n }\n z: 8\n\nThe result will not contain specific values for fields x,y and z\n(their value will be set to the default, and omitted in proto text\noutput):\n\n\n f {\n a : 22\n b {\n d : 1\n }\n }\n\nA repeated field is not allowed except at the last position of a\npaths string.\n\nIf a FieldMask object is not present in a get operation, the\noperation applies to all fields (as if a FieldMask of all fields\nhad been specified).\n\nNote that a field mask does not necessarily apply to the\ntop-level response message. In case of a REST get operation, the\nfield mask applies directly to the response, but in case of a REST\nlist operation, the mask instead applies to each individual message\nin the returned resource list. In case of a REST custom method,\nother definitions may be used. Where the mask applies will be\nclearly documented together with its declaration in the API. In\nany case, the effect on the returned resource/resources is required\nbehavior for APIs.\n\n# Field Masks in Update Operations\n\nA field mask in update operations specifies which fields of the\ntargeted resource are going to be updated. The API is required\nto only change the values of the fields as specified in the mask\nand leave the others untouched. If a resource is passed in to\ndescribe the updated values, the API ignores the values of all\nfields not covered by the mask.\n\nIf a repeated field is specified for an update operation, new values will\nbe appended to the existing repeated field in the target resource. Note that\na repeated field is only allowed in the last position of a `paths` string.\n\nIf a sub-message is specified in the last position of the field mask for an\nupdate operation, then new value will be merged into the existing sub-message\nin the target resource.\n\nFor example, given the target message:\n\n f {\n b {\n d: 1\n x: 2\n }\n c: [1]\n }\n\nAnd an update message:\n\n f {\n b {\n d: 10\n }\n c: [2]\n }\n\nthen if the field mask is:\n\n paths: [\"f.b\", \"f.c\"]\n\nthen the result will be:\n\n f {\n b {\n d: 10\n x: 2\n }\n c: [1, 2]\n }\n\nAn implementation may provide options to override this default behavior for\nrepeated and message fields.\n\nIn order to reset a field's value to the default, the field must\nbe in the mask and set to the default value in the provided resource.\nHence, in order to reset all fields of a resource, provide a default\ninstance of the resource and set all fields in the mask, or do\nnot provide a mask as described below.\n\nIf a field mask is not present on update, the operation applies to\nall fields (as if a field mask of all fields has been specified).\nNote that in the presence of schema evolution, this may mean that\nfields the client does not know and has therefore not filled into\nthe request will be reset to their default. If this is unwanted\nbehavior, a specific service may require a client to always specify\na field mask, producing an error if not.\n\nAs with get operations, the location of the resource which\ndescribes the updated values in the request message depends on the\noperation kind. In any case, the effect of the field mask is\nrequired to be honored by the API.\n\n## Considerations for HTTP REST\n\nThe HTTP kind of an update operation which uses a field mask must\nbe set to PATCH instead of PUT in order to satisfy HTTP semantics\n(PUT must only be used for full updates).\n\n# JSON Encoding of Field Masks\n\nIn JSON, a field mask is encoded as a single string where paths are\nseparated by a comma. Fields name in each path are converted\nto/from lower-camel naming conventions.\n\nAs an example, consider the following message declarations:\n\n message Profile {\n User user = 1;\n Photo photo = 2;\n }\n message User {\n string display_name = 1;\n string address = 2;\n }\n\nIn proto a field mask for `Profile` may look as such:\n\n mask {\n paths: \"user.display_name\"\n paths: \"photo\"\n }\n\nIn JSON, the same mask is represented as below:\n\n {\n mask: \"user.displayName,photo\"\n }\n\n# Field Masks and Oneof Fields\n\nField masks treat fields in oneofs just as regular fields. Consider the\nfollowing message:\n\n message SampleMessage {\n oneof test_oneof {\n string name = 4;\n SubMessage sub_message = 9;\n }\n }\n\nThe field mask can be:\n\n mask {\n paths: \"name\"\n }\n\nOr:\n\n mask {\n paths: \"sub_message\"\n }\n\nNote that oneof type names (\"test_oneof\" in this case) cannot be used in\npaths.\n\n## Field Mask Verification\n\nThe implementation of any API method which has a FieldMask type field in the\nrequest should verify the included field paths, and return an\n`INVALID_ARGUMENT` error if any path is duplicated or unmappable.",
Expand Down
12 changes: 4 additions & 8 deletions examples/proto/examplepb/response_body_service.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"type": "array",
"items": {
"$ref": "#/definitions/examplepbRepeatedResponseBodyOutResponse"
},
"collectionFormat": "multi"
}
}
}
},
Expand Down Expand Up @@ -77,8 +76,7 @@
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
}
}
},
Expand Down Expand Up @@ -114,8 +112,7 @@
"type": "array",
"items": {
"$ref": "#/definitions/examplepbRepeatedResponseBodyOutResponse"
},
"collectionFormat": "multi"
}
}
}
},
Expand All @@ -137,8 +134,7 @@
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
}
}
},
Expand Down
21 changes: 7 additions & 14 deletions examples/proto/examplepb/stream.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
"type": "array",
"items": {
"$ref": "#/definitions/ABitOfEverythingNested"
},
"collectionFormat": "multi"
}
},
"float_value": {
"type": "number",
Expand Down Expand Up @@ -223,8 +222,7 @@
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi"
}
},
"oneof_empty": {
"properties": {}
Expand Down Expand Up @@ -262,17 +260,15 @@
"items": {
"$ref": "#/definitions/examplepbNumericEnum"
},
"title": "repeated enum value. it is comma-separated in query",
"collectionFormat": "multi"
"title": "repeated enum value. it is comma-separated in query"
},
"repeated_enum_annotation": {
"type": "array",
"items": {
"$ref": "#/definitions/examplepbNumericEnum"
},
"description": "Repeated numeric enum description.",
"title": "Repeated numeric enum title",
"collectionFormat": "multi"
"title": "Repeated numeric enum title"
},
"enum_value_annotation": {
"$ref": "#/definitions/examplepbNumericEnum",
Expand All @@ -285,17 +281,15 @@
"type": "string"
},
"description": "Repeated string description.",
"title": "Repeated string title",
"collectionFormat": "multi"
"title": "Repeated string title"
},
"repeated_nested_annotation": {
"type": "array",
"items": {
"$ref": "#/definitions/ABitOfEverythingNested"
},
"description": "Repeated nested object description.",
"title": "Repeated nested object title",
"collectionFormat": "multi"
"title": "Repeated nested object title"
},
"nested_annotation": {
"$ref": "#/definitions/ABitOfEverythingNested",
Expand Down Expand Up @@ -368,8 +362,7 @@
"type": "array",
"items": {
"$ref": "#/definitions/protobufAny"
},
"collectionFormat": "multi"
}
}
}
},
Expand Down
Loading

0 comments on commit d294104

Please sign in to comment.