You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like uniqueItems option with array type is placed in the wrong place when compiled to json. Current formatting places the field within the items field of the property object. But according to the spec: it should be in the root property object.
Create in your proto a repeated string field with annotations like:
repeated string url = 1 [
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
min_length: 1,
max_length: 512,
max_items: 3
unique_items: true,
description: "A cool set of URLs",
example: "[\"https://www.example.com/\", \"https://www.github.com/\"]",
}];
Run the generator
See that the output has:
"url": {
"type": "array",
"example": [
"https://www.example.com/",
"https://www.google.com/"
],
"items": {
"type": "string",
"maxLength": 512,
"minLength": 1
"uniqueItems": true,
},
"description": "a cool set of URLs",
"maxItems": 3
},
Expected behavior
"url": {
"type": "array",
"example": [
"https://www.example.com/",
"https://www.google.com/"
],
"items": {
"type": "string",
"maxLength": 512,
"minLength": 1
},
"uniqueItems": true,
"description": "a cool set of URLs",
"maxItems": 3
},
Using the rendered swagger output in editor.swagger.io I would expect to see an error when I put in two duplicate entries
Actual Behavior
Using the rendered swagger output in editor.swagger.io I see no error when I put in two duplicate entries, manually adjusting the output to the "expected output" I do get an error from editor.swagger.io
Your Environment
Was using grpc gateway 2.19.1
The text was updated successfully, but these errors were encountered:
🐛 Bug Report
This bug relates to protoc-gen-openapiv2.
It looks like
uniqueItems
option with array type is placed in the wrong place when compiled to json. Current formatting places the field within theitems
field of the property object. But according to the spec: it should be in the root property object.The problem is located here: https://github.com/grpc-ecosystem/grpc-gateway/blob/main/protoc-gen-openapiv2/internal/genopenapi/template.go#L2939 - where the unique field is placed within the items object instead of the root object
To Reproduce
Expected behavior
Using the rendered swagger output in editor.swagger.io I would expect to see an error when I put in two duplicate entries
Actual Behavior
Using the rendered swagger output in editor.swagger.io I see no error when I put in two duplicate entries, manually adjusting the output to the "expected output" I do get an error from editor.swagger.io
Your Environment
Was using grpc gateway 2.19.1
The text was updated successfully, but these errors were encountered: