openapiv2: min_items/max_items not emitted on query parameters for repeated fields
Author: bindaldharaCreated Aug 25, 2026Updated Aug 28, 2026
Bug Report
For repeated fields used as query parameters, openapiv2_field min_items / max_items are not written into the OpenAPI parameter object. unique_items is emitted correctly, but min_items / max_items are dropped.
Cause: openapiParameterObject lacked MaxItems, and query-param mapping in nestedQueryParams only copies UniqueItems from the field schema (not MinItems / MaxItems). These constraints already work for schema/body properties.
To Reproduce
- Define a repeated field with array constraints:
repeated string tags = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
min_items: 1
max_items: 10
unique_items: true
}];- Expose the field as a query parameter (e.g. a GET method with no body, or a field not covered by body).
- Generate OpenAPI with protoc-gen-openapiv2 and inspect the parameter for tags.
Expected behavior
The query parameter object includes all three constraints:
{
"name": "tags",
"in": "query",
"type": "array",
"collectionFormat": "multi",
"minItems": 1,
"maxItems": 10,
"uniqueItems": true
}Actual Behavior
Only uniqueItems appears on the parameter. minItems and maxItems are missing (even though the same annotation correctly emits them on schema/body properties).
Your Environment
grpc-gateway / protoc-gen-openapiv2 (main) macOS (darwin)
Source: grpc-ecosystem/grpc-gateway