diff --git a/.github/docs/openapi3.txt b/.github/docs/openapi3.txt index cfccb97a..eddcbfbd 100644 --- a/.github/docs/openapi3.txt +++ b/.github/docs/openapi3.txt @@ -400,8 +400,8 @@ func (content Content) Validate(ctx context.Context, opts ...ValidationOption) e type Discriminator struct { Extensions map[string]any `json:"-" yaml:"-"` - PropertyName string `json:"propertyName" yaml:"propertyName"` // required - Mapping map[string]string `json:"mapping,omitempty" yaml:"mapping,omitempty"` + PropertyName string `json:"propertyName" yaml:"propertyName"` // required + Mapping StringMap `json:"mapping,omitempty" yaml:"mapping,omitempty"` } Discriminator is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminator-object @@ -873,10 +873,10 @@ type NumberFormatValidator = FormatValidator[float64] type OAuthFlow struct { Extensions map[string]any `json:"-" yaml:"-"` - AuthorizationURL string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"` - TokenURL string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"` - RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"` - Scopes map[string]string `json:"scopes" yaml:"scopes"` // required + AuthorizationURL string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"` + TokenURL string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"` + RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"` + Scopes StringMap `json:"scopes" yaml:"scopes"` // required } OAuthFlow is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauth-flow-object @@ -1983,6 +1983,10 @@ func NewRegexpFormatValidator(pattern string) StringFormatValidator NewRegexpFormatValidator creates a new FormatValidator that uses a regular expression to validate the value. +type StringMap map[string]string + StringMap is a map[string]string that ignores the origin in the underlying + json representation. + type T struct { Extensions map[string]any `json:"-" yaml:"-"` diff --git a/README.md b/README.md index 41335937..d135ffe9 100644 --- a/README.md +++ b/README.md @@ -295,6 +295,9 @@ for _, path := range doc.Paths.InMatchingOrder() { ## CHANGELOG: Sub-v1 breaking API changes +### v0.129.0 +* `openapi3.Discriminator.Mapping` and `openapi3.OAuthFlow.Scopes` fields went from a `map[string]string` to the new type `StringMap` + ### v0.127.0 * Downgraded `github.com/gorilla/mux` dep from `1.8.1` to `1.8.0`. diff --git a/openapi3/discriminator.go b/openapi3/discriminator.go index e8193bd9..16d24400 100644 --- a/openapi3/discriminator.go +++ b/openapi3/discriminator.go @@ -10,8 +10,8 @@ import ( type Discriminator struct { Extensions map[string]any `json:"-" yaml:"-"` - PropertyName string `json:"propertyName" yaml:"propertyName"` // required - Mapping map[string]string `json:"mapping,omitempty" yaml:"mapping,omitempty"` + PropertyName string `json:"propertyName" yaml:"propertyName"` // required + Mapping StringMap `json:"mapping,omitempty" yaml:"mapping,omitempty"` } // MarshalJSON returns the JSON encoding of Discriminator. diff --git a/openapi3/security_scheme.go b/openapi3/security_scheme.go index b5c94b61..b37a6eda 100644 --- a/openapi3/security_scheme.go +++ b/openapi3/security_scheme.go @@ -317,10 +317,10 @@ func (flows *OAuthFlows) Validate(ctx context.Context, opts ...ValidationOption) type OAuthFlow struct { Extensions map[string]any `json:"-" yaml:"-"` - AuthorizationURL string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"` - TokenURL string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"` - RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"` - Scopes map[string]string `json:"scopes" yaml:"scopes"` // required + AuthorizationURL string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"` + TokenURL string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"` + RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"` + Scopes StringMap `json:"scopes" yaml:"scopes"` // required } // MarshalJSON returns the JSON encoding of OAuthFlow. diff --git a/openapi3/stringmap.go b/openapi3/stringmap.go new file mode 100644 index 00000000..3819851c --- /dev/null +++ b/openapi3/stringmap.go @@ -0,0 +1,4 @@ +package openapi3 + +// StringMap is a map[string]string that ignores the origin in the underlying json representation. +type StringMap map[string]string