Skip to content

Commit

Permalink
fix usage of repeated and map fields constraints with protovalidate
Browse files Browse the repository at this point in the history
  • Loading branch information
sudorandom committed Sep 4, 2024
1 parent cfe061c commit 329a657
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 70 deletions.
Binary file modified internal/converter/fixtures/fileset.binpb
Binary file not shown.
30 changes: 16 additions & 14 deletions internal/converter/fixtures/output/protovalidate.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1946,37 +1946,36 @@
"type": "array",
"items": {
"type": "string",
"title": "repeated_min_items",
"minItems": 2
"title": "repeated_min_items"
}
},
"repeatedMaxItems": {
"type": "array",
"items": {
"type": "string",
"title": "repeated_max_items",
"maxItems": 3
"title": "repeated_max_items"
}
},
"repeatedUnique": {
"type": "array",
"items": {
"type": "string",
"title": "repeated_unique",
"uniqueItems": true
"title": "repeated_unique"
}
},
"repeatedItems": {
"type": "array",
"items": {
"type": "string",
"title": "repeated_items"
"title": "repeated_items",
"maxLength": 10,
"minLength": 3
}
},
"mapMinPairs": {
"type": "object",
"title": "map_min_pairs",
"minItems": 2,
"minProperties": 2,
"additionalProperties": {
"type": "string",
"title": "value"
Expand All @@ -1985,7 +1984,7 @@
"mapMaxPairs": {
"type": "object",
"title": "map_max_pairs",
"maxItems": 3,
"maxProperties": 3,
"additionalProperties": {
"type": "string",
"title": "value"
Expand All @@ -1994,8 +1993,6 @@
"mapKeys": {
"type": "object",
"title": "map_keys",
"maxLength": 10,
"minLength": 3,
"additionalProperties": {
"type": "string",
"title": "value"
Expand All @@ -2004,11 +2001,11 @@
"mapValues": {
"type": "object",
"title": "map_values",
"maxLength": 20,
"minLength": 5,
"additionalProperties": {
"type": "string",
"title": "value",
"maxLength": 20,
"minLength": 5
"title": "value"
}
},
"anyIn": {
Expand Down Expand Up @@ -2073,6 +2070,11 @@
}
},
"title": "LotsOfValidationRules",
"maxLength": 10,
"minLength": 3,
"maxItems": 3,
"minItems": 2,
"uniqueItems": true,
"required": [
"requiredField"
],
Expand Down
20 changes: 11 additions & 9 deletions internal/converter/fixtures/output/protovalidate.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1309,54 +1309,51 @@ components:
items:
type: string
title: repeated_min_items
minItems: 2
repeatedMaxItems:
type: array
items:
type: string
title: repeated_max_items
maxItems: 3
repeatedUnique:
type: array
items:
type: string
title: repeated_unique
uniqueItems: true
repeatedItems:
type: array
items:
type: string
title: repeated_items
maxLength: 10
minLength: 3
mapMinPairs:
type: object
title: map_min_pairs
minItems: 2
minProperties: 2
additionalProperties:
type: string
title: value
mapMaxPairs:
type: object
title: map_max_pairs
maxItems: 3
maxProperties: 3
additionalProperties:
type: string
title: value
mapKeys:
type: object
title: map_keys
maxLength: 10
minLength: 3
additionalProperties:
type: string
title: value
mapValues:
type: object
title: map_values
maxLength: 20
minLength: 5
additionalProperties:
type: string
title: value
maxLength: 20
minLength: 5
anyIn:
$ref: '#/components/schemas/google.protobuf.Any'
anyNotIn:
Expand Down Expand Up @@ -1398,6 +1395,11 @@ components:
timestampGtNow:
$ref: '#/components/schemas/google.protobuf.Timestamp'
title: LotsOfValidationRules
maxLength: 10
minLength: 3
maxItems: 3
minItems: 2
uniqueItems: true
required:
- requiredField
additionalProperties: false
Expand Down
Loading

0 comments on commit 329a657

Please sign in to comment.