Skip to content

Commit

Permalink
openapi3: reference originating locations in YAML specs - step 1 (#1007)
Browse files Browse the repository at this point in the history
* add origin - step 1

* delete origin from content

* point to Origin

* make include origin configurable

* generic unmarshalStringMap

* add origin to more components

* revert comments

* use const originKey

* comment to Scopes

* test more specs

* Fix Discriminator

* update docs

* test on a decent set of dedicated specs

* remove trainling spaces

* add comments

* remove trailing whitespace

* update docs

* dedicated tests

* update docs

* remove whitespace

* rm empty line

* rm last newline

* add tests

* rm unused test files

* update deps

* fix paths test

* test components/security

* fix LF

* include origin in unmarshal maps

* move component unmarshallers to respective files

* fix test (json-schema 301)

* Add github.com/pb33f/libopenapi (#1004)

* Add github.com/pb33f/libopenapi

it looks like a reasonable alternative

* Update README.md

---------

Co-authored-by: Pierre Fenoll <[email protected]>

* Introduce an option to override the regex implementation (#1006)

* make form required field order deterministic (#1008)

* openapi2: fix un/marshalling discriminator field (#1011)

* fix: issue unmarshalling when discriminator field is set in openapi2.0

* revert original approach

* update with different approach

* Revert "update with different approach"

This reverts commit 2db2b39.

* v2 schema with discriminator field set as string

* update ref link and comment

* run docs.sh

* README: add Fuego to dependents (#1017)

* openapi3: skip a test in CI to avoid 403s from some remote server (#1019)

Signed-off-by: Pierre Fenoll <[email protected]>

* revert fix test (json-schema 301)

* openapi3: introduce StringMap type to enable unmarshalling of maps with Origin (#1018)

* add origin to more components

* Fix Discriminator

* update docs

* update doccs

* merge with stringmap

* remove unused Scopes

---------

Signed-off-by: Pierre Fenoll <[email protected]>
Co-authored-by: Jille Timmermans <[email protected]>
Co-authored-by: Pierre Fenoll <[email protected]>
Co-authored-by: Alexander Bakker <[email protected]>
Co-authored-by: Justin Sherrill <[email protected]>
Co-authored-by: Jay Shah <[email protected]>
Co-authored-by: Ewen Quimerc'h <[email protected]>
  • Loading branch information
7 people authored Oct 21, 2024
1 parent 56505dc commit c333b34
Show file tree
Hide file tree
Showing 43 changed files with 816 additions and 14 deletions.
89 changes: 88 additions & 1 deletion .github/docs/openapi3.txt

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module github.com/getkin/kin-openapi

go 1.20
go 1.22.5

replace gopkg.in/yaml.v3 => github.com/oasdiff/yaml3 v0.0.0-20240920135353-c185dc6ea7c6

replace github.com/invopop/yaml => github.com/oasdiff/yaml v0.0.0-20240920191703-3e5a9fb5bdf3

require (
github.com/go-openapi/jsonpointer v0.21.0
Expand Down
14 changes: 9 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kO
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=
github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/oasdiff/yaml v0.0.0-20240920191703-3e5a9fb5bdf3 h1:nqCxALSUgWobWkFGIrhLRzR/bpImQdGj+3JS4/scTJo=
github.com/oasdiff/yaml v0.0.0-20240920191703-3e5a9fb5bdf3/go.mod h1:AOyUNV9ElKz7EEZeBm/48U54UtjtgCMT9fFbZEsClQc=
github.com/oasdiff/yaml3 v0.0.0-20240920135353-c185dc6ea7c6 h1:+ZsuDTdapTJxfMQk7SOJiNMg0v36pui01L7FEO615r8=
github.com/oasdiff/yaml3 v0.0.0-20240920135353-c185dc6ea7c6/go.mod h1:lqlOfJRrYpgeWHQj+ky2tf7UJ3PzgHTHRQEpc90nbp0=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -26,7 +31,6 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
11 changes: 11 additions & 0 deletions maps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ func (${name} ${type}) UnmarshalJSON(data []byte) (err error) {
continue
}
if k == originKey {
var data []byte
if data, err = json.Marshal(v); err != nil {
return
}
if err = json.Unmarshal(data, &x.Origin); err != nil {
return
}
continue
}
var data []byte
if data, err = json.Marshal(v); err != nil {
return
Expand Down
7 changes: 7 additions & 0 deletions openapi3/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object
type Callback struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

m map[string]*PathItem
}
Expand Down Expand Up @@ -52,3 +53,9 @@ func (callback *Callback) Validate(ctx context.Context, opts ...ValidationOption

return validateExtensions(ctx, callback.Extensions)
}

// UnmarshalJSON sets Callbacks to a copy of data.
func (callbacks *Callbacks) UnmarshalJSON(data []byte) (err error) {
*callbacks, _, err = unmarshalStringMapP[CallbackRef](data)
return
}
2 changes: 2 additions & 0 deletions openapi3/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#components-object
type Components struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

Schemas Schemas `json:"schemas,omitempty" yaml:"schemas,omitempty"`
Parameters ParametersMap `json:"parameters,omitempty" yaml:"parameters,omitempty"`
Expand Down Expand Up @@ -94,6 +95,7 @@ func (components *Components) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)
delete(x.Extensions, originKey)
delete(x.Extensions, "schemas")
delete(x.Extensions, "parameters")
delete(x.Extensions, "headers")
Expand Down
3 changes: 3 additions & 0 deletions openapi3/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#contact-object
type Contact struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

Name string `json:"name,omitempty" yaml:"name,omitempty"`
URL string `json:"url,omitempty" yaml:"url,omitempty"`
Expand Down Expand Up @@ -50,6 +51,8 @@ func (contact *Contact) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)

delete(x.Extensions, originKey)
delete(x.Extensions, "name")
delete(x.Extensions, "url")
delete(x.Extensions, "email")
Expand Down
6 changes: 6 additions & 0 deletions openapi3/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,9 @@ func (content Content) Validate(ctx context.Context, opts ...ValidationOption) e
}
return nil
}

// UnmarshalJSON sets Content to a copy of data.
func (content *Content) UnmarshalJSON(data []byte) (err error) {
*content, _, err = unmarshalStringMapP[MediaType](data)
return
}
3 changes: 3 additions & 0 deletions openapi3/discriminator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminator-object
type Discriminator struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

PropertyName string `json:"propertyName" yaml:"propertyName"` // required
Mapping StringMap `json:"mapping,omitempty" yaml:"mapping,omitempty"`
Expand Down Expand Up @@ -44,6 +45,8 @@ func (discriminator *Discriminator) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)

delete(x.Extensions, originKey)
delete(x.Extensions, "propertyName")
delete(x.Extensions, "mapping")
if len(x.Extensions) == 0 {
Expand Down
3 changes: 3 additions & 0 deletions openapi3/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#encoding-object
type Encoding struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"`
Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty"`
Expand Down Expand Up @@ -80,6 +81,8 @@ func (encoding *Encoding) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)

delete(x.Extensions, originKey)
delete(x.Extensions, "contentType")
delete(x.Extensions, "headers")
delete(x.Extensions, "style")
Expand Down
6 changes: 6 additions & 0 deletions openapi3/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,9 @@ func (example *Example) Validate(ctx context.Context, opts ...ValidationOption)

return validateExtensions(ctx, example.Extensions)
}

// UnmarshalJSON sets Examples to a copy of data.
func (examples *Examples) UnmarshalJSON(data []byte) (err error) {
*examples, _, err = unmarshalStringMapP[ExampleRef](data)
return
}
2 changes: 2 additions & 0 deletions openapi3/external_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#external-documentation-object
type ExternalDocs struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

Description string `json:"description,omitempty" yaml:"description,omitempty"`
URL string `json:"url,omitempty" yaml:"url,omitempty"`
Expand Down Expand Up @@ -49,6 +50,7 @@ func (e *ExternalDocs) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)
delete(x.Extensions, originKey)
delete(x.Extensions, "description")
delete(x.Extensions, "url")
if len(x.Extensions) == 0 {
Expand Down
6 changes: 6 additions & 0 deletions openapi3/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ func (header *Header) Validate(ctx context.Context, opts ...ValidationOption) er
}
return nil
}

// UnmarshalJSON sets Headers to a copy of data.
func (headers *Headers) UnmarshalJSON(data []byte) (err error) {
*headers, _, err = unmarshalStringMapP[HeaderRef](data)
return
}
2 changes: 2 additions & 0 deletions openapi3/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#info-object
type Info struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

Title string `json:"title" yaml:"title"` // Required
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Expand Down Expand Up @@ -62,6 +63,7 @@ func (info *Info) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)
delete(x.Extensions, originKey)
delete(x.Extensions, "title")
delete(x.Extensions, "description")
delete(x.Extensions, "termsOfService")
Expand Down
2 changes: 2 additions & 0 deletions openapi3/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#license-object
type License struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

Name string `json:"name" yaml:"name"` // Required
URL string `json:"url,omitempty" yaml:"url,omitempty"`
Expand Down Expand Up @@ -45,6 +46,7 @@ func (license *License) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)
delete(x.Extensions, originKey)
delete(x.Extensions, "name")
delete(x.Extensions, "url")
if len(x.Extensions) == 0 {
Expand Down
9 changes: 9 additions & 0 deletions openapi3/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#link-object
type Link struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

OperationRef string `json:"operationRef,omitempty" yaml:"operationRef,omitempty"`
OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"`
Expand Down Expand Up @@ -66,6 +67,8 @@ func (link *Link) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)

delete(x.Extensions, originKey)
delete(x.Extensions, "operationRef")
delete(x.Extensions, "operationId")
delete(x.Extensions, "description")
Expand All @@ -92,3 +95,9 @@ func (link *Link) Validate(ctx context.Context, opts ...ValidationOption) error

return validateExtensions(ctx, link.Extensions)
}

// UnmarshalJSON sets Links to a copy of data.
func (links *Links) UnmarshalJSON(data []byte) (err error) {
*links, _, err = unmarshalStringMapP[LinkRef](data)
return
}
11 changes: 7 additions & 4 deletions openapi3/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type Loader struct {
// IsExternalRefsAllowed enables visiting other files
IsExternalRefsAllowed bool

// IncludeOrigin specifies whether to include the origin of the OpenAPI elements
IncludeOrigin bool

// ReadFromURIFunc allows overriding the any file/URL reading func
ReadFromURIFunc ReadFromURIFunc

Expand Down Expand Up @@ -103,7 +106,7 @@ func (loader *Loader) loadSingleElementFromURI(ref string, rootPath *url.URL, el
if err != nil {
return nil, err
}
if err := unmarshal(data, element); err != nil {
if err := unmarshal(data, element, loader.IncludeOrigin); err != nil {
return nil, err
}

Expand Down Expand Up @@ -139,7 +142,7 @@ func (loader *Loader) LoadFromIoReader(reader io.Reader) (*T, error) {
func (loader *Loader) LoadFromData(data []byte) (*T, error) {
loader.resetVisitedPathItemRefs()
doc := &T{}
if err := unmarshal(data, doc); err != nil {
if err := unmarshal(data, doc, loader.IncludeOrigin); err != nil {
return nil, err
}
if err := loader.ResolveRefsIn(doc, nil); err != nil {
Expand Down Expand Up @@ -168,7 +171,7 @@ func (loader *Loader) loadFromDataWithPathInternal(data []byte, location *url.UR
doc := &T{}
loader.visitedDocuments[uri] = doc

if err := unmarshal(data, doc); err != nil {
if err := unmarshal(data, doc, loader.IncludeOrigin); err != nil {
return nil, err
}

Expand Down Expand Up @@ -422,7 +425,7 @@ func (loader *Loader) resolveComponent(doc *T, ref string, path *url.URL, resolv
if err2 != nil {
return nil, nil, err
}
if err2 = unmarshal(data, &cursor); err2 != nil {
if err2 = unmarshal(data, &cursor, loader.IncludeOrigin); err2 != nil {
return nil, nil, err
}
if cursor, err2 = drill(cursor); err2 != nil || cursor == nil {
Expand Down
33 changes: 33 additions & 0 deletions openapi3/maplike.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ func (responses *Responses) UnmarshalJSON(data []byte) (err error) {
continue
}

if k == originKey {
var data []byte
if data, err = json.Marshal(v); err != nil {
return
}
if err = json.Unmarshal(data, &x.Origin); err != nil {
return
}
continue
}

var data []byte
if data, err = json.Marshal(v); err != nil {
return
Expand Down Expand Up @@ -256,6 +267,17 @@ func (callback *Callback) UnmarshalJSON(data []byte) (err error) {
continue
}

if k == originKey {
var data []byte
if data, err = json.Marshal(v); err != nil {
return
}
if err = json.Unmarshal(data, &x.Origin); err != nil {
return
}
continue
}

var data []byte
if data, err = json.Marshal(v); err != nil {
return
Expand Down Expand Up @@ -387,6 +409,17 @@ func (paths *Paths) UnmarshalJSON(data []byte) (err error) {
continue
}

if k == originKey {
var data []byte
if data, err = json.Marshal(v); err != nil {
return
}
if err = json.Unmarshal(data, &x.Origin); err != nil {
return
}
continue
}

var data []byte
if data, err = json.Marshal(v); err != nil {
return
Expand Down
4 changes: 2 additions & 2 deletions openapi3/marsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func unmarshalError(jsonUnmarshalErr error) error {
return jsonUnmarshalErr
}

func unmarshal(data []byte, v any) error {
func unmarshal(data []byte, v any, includeOrigin bool) error {
var jsonErr, yamlErr error

// See https://github.com/getkin/kin-openapi/issues/680
Expand All @@ -25,7 +25,7 @@ func unmarshal(data []byte, v any) error {
}

// UnmarshalStrict(data, v) TODO: investigate how ymlv3 handles duplicate map keys
if yamlErr = yaml.Unmarshal(data, v); yamlErr == nil {
if yamlErr = yaml.UnmarshalWithOrigin(data, v, includeOrigin); yamlErr == nil {
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions openapi3/media_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
// See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#media-type-object
type MediaType struct {
Extensions map[string]any `json:"-" yaml:"-"`
Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"`

Schema *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"`
Example any `json:"example,omitempty" yaml:"example,omitempty"`
Expand Down Expand Up @@ -101,6 +102,7 @@ func (mediaType *MediaType) UnmarshalJSON(data []byte) error {
return unmarshalError(err)
}
_ = json.Unmarshal(data, &x.Extensions)
delete(x.Extensions, originKey)
delete(x.Extensions, "schema")
delete(x.Extensions, "example")
delete(x.Extensions, "examples")
Expand Down
Loading

0 comments on commit c333b34

Please sign in to comment.