Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4614 Unique Items placement #4619

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading