Skip to content

Commit

Permalink
Fix #4614 Unique Items placement (#4619)
Browse files Browse the repository at this point in the history
* fix: unique items location

* updated template_test + corrected UniqueItems type
  • Loading branch information
sebaraj authored Aug 12, 2024
1 parent 9cf3e9f commit 0d3c6d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ func nestedQueryParams(message *descriptor.Message, field *descriptor.Field, pre
Format: schema.Format,
Pattern: schema.Pattern,
Required: required,
UniqueItems: schema.UniqueItems,
extensions: schema.extensions,
Enum: schema.Enum,
}
Expand Down Expand Up @@ -2936,7 +2937,6 @@ func updateswaggerObjectFromJSONSchema(s *openapiSchemaObject, j *openapi_option
s.Items.MinLength = j.GetMinLength()
s.Items.Pattern = j.GetPattern()
s.Items.Default = j.GetDefault()
s.Items.UniqueItems = j.GetUniqueItems()
s.Items.MaxProperties = j.GetMaxProperties()
s.Items.MinProperties = j.GetMinProperties()
s.Items.Required = j.GetRequired()
Expand All @@ -2962,7 +2962,6 @@ func updateswaggerObjectFromJSONSchema(s *openapiSchemaObject, j *openapi_option
s.MinLength = j.GetMinLength()
s.Pattern = j.GetPattern()
s.Default = j.GetDefault()
s.UniqueItems = j.GetUniqueItems()
s.MaxProperties = j.GetMaxProperties()
s.MinProperties = j.GetMinProperties()
s.Required = j.GetRequired()
Expand All @@ -2984,6 +2983,7 @@ func updateswaggerObjectFromJSONSchema(s *openapiSchemaObject, j *openapi_option
s.Format = j.GetFormat()
}
}
s.UniqueItems = j.GetUniqueItems()
s.MaxItems = j.GetMaxItems()
s.MinItems = j.GetMinItems()

Expand Down
4 changes: 2 additions & 2 deletions protoc-gen-openapiv2/internal/genopenapi/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4973,7 +4973,6 @@ func TestSchemaOfField(t *testing.T) {
MaxLength: 10,
MinLength: 3,
Pattern: "[a-z]+",
UniqueItems: true,
MaxProperties: 33,
MinProperties: 22,
Required: []string{"req"},
Expand All @@ -4982,6 +4981,7 @@ func TestSchemaOfField(t *testing.T) {
},
Title: "field title",
Description: "field description",
UniqueItems: true,
MaxItems: 20,
MinItems: 2,
},
Expand Down Expand Up @@ -5019,7 +5019,6 @@ func TestSchemaOfField(t *testing.T) {
MaxLength: 10,
MinLength: 3,
Pattern: "[a-z]+",
UniqueItems: true,
MaxProperties: 33,
MinProperties: 22,
Required: []string{"req"},
Expand All @@ -5028,6 +5027,7 @@ func TestSchemaOfField(t *testing.T) {
},
Title: "field title",
Description: "field description",
UniqueItems: true,
MaxItems: 20,
MinItems: 2,
},
Expand Down
1 change: 1 addition & 0 deletions protoc-gen-openapiv2/internal/genopenapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type openapiParameterObject struct {
Required bool `json:"required" yaml:"required"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Format string `json:"format,omitempty" yaml:"format,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
Items *openapiItemsObject `json:"items,omitempty" yaml:"items,omitempty"`
Enum interface{} `json:"enum,omitempty" yaml:"enum,omitempty"`
CollectionFormat string `json:"collectionFormat,omitempty" yaml:"collectionFormat,omitempty"`
Expand Down

0 comments on commit 0d3c6d6

Please sign in to comment.