grpc-ecosystem/grpc-gateway
View on GitHubopenapiv2: Field options are not properly rendered for repeated fields
Open
#2531 opened on Feb 9, 2022
buggood first issuehelp wantedopenapi
Description
I need to generate swagger json using proto annotations. generated schema should look like this
"schema": {
"type": "object",
"example": {
"product_id": ["8900099100000113079", "8900099100000082373"]
},
"properties": {
"product_id": {
"type": "array",
"items": {
"type": "string",
"maxLength": 19,
"minLength": 1,
"pattern": "^[0-9]+$"
},
"description": "Only digits are allowed.",
"title": "Provide list of ids"
}
}
}
and the annotation added was something like this
message product {
repeated string product_id=1[(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
pattern: "^[0-9]+$"
max_length: 19
min_length: 1
description: "Only digits are allowed."
}];
}
But the problem is above annotation is generating schema like this
"schema": {
"type": "object",
"example": {
"product_id": ["8900099100000113079", "8900099100000082373"]
},
"properties": {
"product_id": {
"type": "array",
"items": {
"type": "string"
},
"description": "Only digits are allowed.",
"title": "Provide list of ids",
"maxLength": 19,
"minLength": 1,
"pattern": "^[0-9]+$"
}
}
}
which is not correct. We could not find the relevant example in a_bit_of_everything.proto.
Please help in adding the annotations.