Repository: swaggest/openapi-go
Pull request #14 (2020-10-05 10:49:58)

Generate tests for schema entities

codecov[bot]: # [Codecov](https://codecov.io/gh/swaggest/openapi-go/pull/14?src=pr&el=h1) Report
> Merging [#14](https://codecov.io/gh/swaggest/openapi-go/pull/14?src=pr&el=desc) into [master](https://codecov.io/gh/swaggest/openapi-go/commit/9994473f5f8a3bfbd833e14436b826cb433c30b7?el=desc) will **increase** coverage by `23.67%`.
> The diff coverage is `50.86%`.

[![Impacted file tree graph](https://codecov.io/gh/swaggest/openapi-go/pull/14/graphs/tree.svg?width=650&height=150&src=pr&token=3uETjeijpQ)](https://codecov.io/gh/swaggest/openapi-go/pull/14?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           master      #14       +/-   ##
===========================================
+ Coverage   13.29%   36.96%   +23.67%     
===========================================
  Files           5        5               
  Lines        3370     3457       +87     
===========================================
+ Hits          448     1278      +830     
+ Misses       2864     1895      -969     
- Partials       58      284      +226     
```

| Flag | Coverage Δ | |
|---|---|---|
| #unittests | `36.96% <50.86%> (+23.67%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/swaggest/openapi-go/pull/14?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [openapi3/entities.go](https://codecov.io/gh/swaggest/openapi-go/pull/14/diff?src=pr&el=tree#diff-b3BlbmFwaTMvZW50aXRpZXMuZ28=) | `31.43% <50.86%> (+27.91%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/swaggest/openapi-go/pull/14?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/swaggest/openapi-go/pull/14?src=pr&el=footer). Last update [9994473...be8235e](https://codecov.io/gh/swaggest/openapi-go/pull/14?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/Makefile b/Makefile
index e40c762..a5e3a24 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 GOLANGCI_LINT_VERSION := "v1.31.0"
-JSON_CLI_VERSION := "v1.7.7"
+JSON_CLI_VERSION := "v1.8.0"
 
 # The head of Makefile determines location of dev-go to include standard targets.
 GO ?= go
@@ -39,5 +39,5 @@ test: test-unit
 ## Generate entities from schema
 gen:
 	@test -s $(GOPATH)/bin/json-cli-$(JSON_CLI_VERSION) || (curl -sSfL https://github.com/swaggest/json-cli/releases/download/$(JSON_CLI_VERSION)/json-cli -o $(GOPATH)/bin/json-cli-$(JSON_CLI_VERSION) && chmod +x $(GOPATH)/bin/json-cli-$(JSON_CLI_VERSION))
-	@cd resources/schema/ && $(GOPATH)/bin/json-cli-$(JSON_CLI_VERSION) gen-go openapi3.json --output ../../openapi3/entities.go --package-name openapi3 --with-zero-values --fluent-setters --root-name Spec
-	@gofmt -w ./openapi3/entities.go
+	@cd resources/schema/ && $(GOPATH)/bin/json-cli-$(JSON_CLI_VERSION) gen-go openapi3.json --output ../../openapi3/entities.go --package-name openapi3 --with-tests --with-zero-values --validate-required --fluent-setters --root-name Spec
+	@gofmt -w ./openapi3/entities.go ./openapi3/entities_test.go
diff --git a/openapi3/entities.go b/openapi3/entities.go
index cf6dee2..9eb21da 100644
--- a/openapi3/entities.go
+++ b/openapi3/entities.go
@@ -1,4 +1,4 @@
-// Code generated by github.com/swaggest/json-cli v1.7.7, DO NOT EDIT.
+// Code generated by github.com/swaggest/json-cli v1.8.0, DO NOT EDIT.
 
 // Package openapi3 contains JSON mapping structures.
 package openapi3
@@ -1388,7 +1388,7 @@ type Parameter struct {
 	Content          map[string]MediaType    `json:"content,omitempty"`
 	Example          *interface{}            `json:"example,omitempty"`
 	Examples         map[string]ExampleOrRef `json:"examples,omitempty"`
-	SchemaXORContent *HasContent             `json:"-"`
+	SchemaXORContent *SchemaXORContent       `json:"-"`
 	Location         *ParameterLocation      `json:"-"`
 	MapOfAnything    map[string]interface{}  `json:"-"` // Key must match pattern: `^x-`.
 }
@@ -1503,15 +1503,15 @@ func (p *Parameter) WithExamplesItem(key string, val ExampleOrRef) *Parameter {
 }
 
 // WithSchemaXORContent sets SchemaXORContent value.
-func (p *Parameter) WithSchemaXORContent(val HasContent) *Parameter {
+func (p *Parameter) WithSchemaXORContent(val SchemaXORContent) *Parameter {
 	p.SchemaXORContent = &val
 	return p
 }
 
 // SchemaXORContentEns ensures returned SchemaXORContent is not nil.
-func (p *Parameter) SchemaXORContentEns() *HasContent {
+func (p *Parameter) SchemaXORContentEns() *SchemaXORContent {
 	if p.SchemaXORContent == nil {
-		p.SchemaXORContent = new(HasContent)
+		p.SchemaXORContent = new(SchemaXORContent)
 	}
 
 	return p.SchemaXORContent
@@ -3200,8 +3200,8 @@ func (h *Header) UnmarshalJSON(data []byte) error {
 		rawMap = nil
 	}
 
-	if v, ok := rawMap["style"]; !ok || string(v) != `"simple"` {
-		return fmt.Errorf(`bad or missing const value for "style" ("simple" expected, %s received)`, v)
+	if v, exists := rawMap["style"]; exists && string(v) != `"simple"` {
+		return fmt.Errorf(`bad const value for "style" ("simple" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "style")
@@ -3257,22 +3257,81 @@ func (h *Header) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constHeader is unconditionally added to JSON.
-var constHeader = json.RawMessage(`{"style":"simple"}`)
+var (
+	// constHeader is unconditionally added to JSON.
+	constHeader = json.RawMessage(`{"style":"simple"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (h Header) MarshalJSON() ([]byte, error) {
 	return marshalUnion(constHeader, marshalHeader(h), h.MapOfAnything)
 }
 
+// HasSchema structure is generated from "#/definitions/SchemaXORContent/oneOf/0".
+//
+// Has Schema.
+type HasSchema struct {
+	Schema interface{} `json:"schema"` // Required.
+}
+
+// WithSchema sets Schema value.
+func (h *HasSchema) WithSchema(val interface{}) *HasSchema {
+	h.Schema = val
+	return h
+}
+
+type marshalHasSchema HasSchema
+
+var requireKeysHasSchema = []string{
+	"schema",
+}
+
+// UnmarshalJSON decodes JSON.
+func (h *HasSchema) UnmarshalJSON(data []byte) error {
+	var err error
+
+	mh := marshalHasSchema(*h)
+
+	err = json.Unmarshal(data, &mh)
+	if err != nil {
+		return err
+	}
+
+	var rawMap map[string]json.RawMessage
+
+	err = json.Unmarshal(data, &rawMap)
+	if err != nil {
+		rawMap = nil
+	}
+
+	for _, key := range requireKeysHasSchema {
+		if _, found := rawMap[key]; !found {
+			return errors.New("required key missing: " + key)
+		}
+	}
+
+	*h = HasSchema(mh)
+
+	return nil
+}
+
 // HasContent structure is generated from "#/definitions/SchemaXORContent/oneOf/1".
 //
 // Has Content.
 //
 // Some properties are not allowed if content is present.
 type HasContent struct {
+	Content interface{} `json:"content"` // Required.
+}
+
+// WithContent sets Content value.
+func (h *HasContent) WithContent(val interface{}) *HasContent {
+	h.Content = val
+	return h
 }
 
+type marshalHasContent HasContent
+
 var requireKeysHasContent = []string{
 	"content",
 }
@@ -3281,6 +3340,13 @@ var requireKeysHasContent = []string{
 func (h *HasContent) UnmarshalJSON(data []byte) error {
 	var err error
 
+	mh := marshalHasContent(*h)
+
+	err = json.Unmarshal(data, &mh)
+	if err != nil {
+		return err
+	}
+
 	var rawMap map[string]json.RawMessage
 
 	err = json.Unmarshal(data, &rawMap)
@@ -3294,12 +3360,142 @@ func (h *HasContent) UnmarshalJSON(data []byte) error {
 		}
 	}
 
+	*h = HasContent(mh)
+
+	return nil
+}
+
+// SchemaXORContent structure is generated from "#/definitions/SchemaXORContent".
+//
+// Schema and content are mutually exclusive, at least one is required.
+type SchemaXORContent struct {
+	HasSchema  *HasSchema  `json:"-"`
+	HasContent *HasContent `json:"-"`
+}
+
+// WithHasSchema sets HasSchema value.
+func (s *SchemaXORContent) WithHasSchema(val HasSchema) *SchemaXORContent {
+	s.HasSchema = &val
+	return s
+}
+
+// HasSchemaEns ensures returned HasSchema is not nil.
+func (s *SchemaXORContent) HasSchemaEns() *HasSchema {
+	if s.HasSchema == nil {
+		s.HasSchema = new(HasSchema)
+	}
+
+	return s.HasSchema
+}
+
+// WithHasContent sets HasContent value.
+func (s *SchemaXORContent) WithHasContent(val HasContent) *SchemaXORContent {
+	s.HasContent = &val
+	return s
+}
+
+// HasContentEns ensures returned HasContent is not nil.
+func (s *SchemaXORContent) HasContentEns() *HasContent {
+	if s.HasContent == nil {
+		s.HasContent = new(HasContent)
+	}
+
+	return s.HasContent
+}
+
+// UnmarshalJSON decodes JSON.
+func (s *SchemaXORContent) UnmarshalJSON(data []byte) error {
+	var err error
+
+	var not SchemaXORContentNot
+
+	if json.Unmarshal(data, &not) == nil {
+		return errors.New("not constraint failed for SchemaXORContent")
+	}
+
+	oneOfErrors := make(map[string]error, 2)
+	oneOfValid := 0
+
+	err = json.Unmarshal(data, &s.HasSchema)
+	if err != nil {
+		oneOfErrors["HasSchema"] = err
+		s.HasSchema = nil
+	} else {
+		oneOfValid++
+	}
+
+	err = json.Unmarshal(data, &s.HasContent)
+	if err != nil {
+		oneOfErrors["HasContent"] = err
+		s.HasContent = nil
+	} else {
+		oneOfValid++
+	}
+
+	if oneOfValid != 1 {
+		return fmt.Errorf("oneOf constraint failed for SchemaXORContent with %d valid results: %v", oneOfValid, oneOfErrors)
+	}
+
 	return nil
 }
 
 // MarshalJSON encodes JSON.
-func (h HasContent) MarshalJSON() ([]byte, error) {
-	return marshalUnion()
+func (s SchemaXORContent) MarshalJSON() ([]byte, error) {
+	return marshalUnion(s.HasSchema, s.HasContent)
+}
+
+// SchemaXORContentNot structure is generated from "#/definitions/SchemaXORContent->not".
+type SchemaXORContentNot struct {
+	Schema  interface{} `json:"schema"`  // Required.
+	Content interface{} `json:"content"` // Required.
+}
+
+// WithSchema sets Schema value.
+func (s *SchemaXORContentNot) WithSchema(val interface{}) *SchemaXORContentNot {
+	s.Schema = val
+	return s
+}
+
+// WithContent sets Content value.
+func (s *SchemaXORContentNot) WithContent(val interface{}) *SchemaXORContentNot {
+	s.Content = val
+	return s
+}
+
+type marshalSchemaXORContentNot SchemaXORContentNot
+
+var requireKeysSchemaXORContentNot = []string{
+	"schema",
+	"content",
+}
+
+// UnmarshalJSON decodes JSON.
+func (s *SchemaXORContentNot) UnmarshalJSON(data []byte) error {
+	var err error
+
+	ms := marshalSchemaXORContentNot(*s)
+
+	err = json.Unmarshal(data, &ms)
+	if err != nil {
+		return err
+	}
+
+	var rawMap map[string]json.RawMessage
+
+	err = json.Unmarshal(data, &rawMap)
+	if err != nil {
+		rawMap = nil
+	}
+
+	for _, key := range requireKeysSchemaXORContentNot {
+		if _, found := rawMap[key]; !found {
+			return errors.New("required key missing: " + key)
+		}
+	}
+
+	*s = SchemaXORContentNot(ms)
+
+	return nil
 }
 
 // PathParameter structure is generated from "#/definitions/ParameterLocation/oneOf/0".
@@ -3347,14 +3543,14 @@ func (p *PathParameter) UnmarshalJSON(data []byte) error {
 		}
 	}
 
-	if v, ok := rawMap["in"]; !ok || string(v) != `"path"` {
-		return fmt.Errorf(`bad or missing const value for "in" ("path" expected, %s received)`, v)
+	if v, exists := rawMap["in"]; exists && string(v) != `"path"` {
+		return fmt.Errorf(`bad const value for "in" ("path" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "in")
 
-	if v, ok := rawMap["required"]; !ok || string(v) != "true" {
-		return fmt.Errorf(`bad or missing const value for "required" (true expected, %s received)`, v)
+	if v, exists := rawMap["required"]; exists && string(v) != "true" {
+		return fmt.Errorf(`bad const value for "required" (true expected, %s received)`, v)
 	}
 
 	delete(rawMap, "required")
@@ -3364,8 +3560,10 @@ func (p *PathParameter) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constPathParameter is unconditionally added to JSON.
-var constPathParameter = json.RawMessage(`{"in":"path","required":true}`)
+var (
+	// constPathParameter is unconditionally added to JSON.
+	constPathParameter = json.RawMessage(`{"in":"path","required":true}`)
+)
 
 // MarshalJSON encodes JSON.
 func (p PathParameter) MarshalJSON() ([]byte, error) {
@@ -3407,8 +3605,8 @@ func (q *QueryParameter) UnmarshalJSON(data []byte) error {
 		rawMap = nil
 	}
 
-	if v, ok := rawMap["in"]; !ok || string(v) != `"query"` {
-		return fmt.Errorf(`bad or missing const value for "in" ("query" expected, %s received)`, v)
+	if v, exists := rawMap["in"]; exists && string(v) != `"query"` {
+		return fmt.Errorf(`bad const value for "in" ("query" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "in")
@@ -3418,8 +3616,10 @@ func (q *QueryParameter) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constQueryParameter is unconditionally added to JSON.
-var constQueryParameter = json.RawMessage(`{"in":"query"}`)
+var (
+	// constQueryParameter is unconditionally added to JSON.
+	constQueryParameter = json.RawMessage(`{"in":"query"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (q QueryParameter) MarshalJSON() ([]byte, error) {
@@ -3445,14 +3645,14 @@ func (h *HeaderParameter) UnmarshalJSON(data []byte) error {
 		rawMap = nil
 	}
 
-	if v, ok := rawMap["in"]; !ok || string(v) != `"header"` {
-		return fmt.Errorf(`bad or missing const value for "in" ("header" expected, %s received)`, v)
+	if v, exists := rawMap["in"]; exists && string(v) != `"header"` {
+		return fmt.Errorf(`bad const value for "in" ("header" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "in")
 
-	if v, ok := rawMap["style"]; !ok || string(v) != `"simple"` {
-		return fmt.Errorf(`bad or missing const value for "style" ("simple" expected, %s received)`, v)
+	if v, exists := rawMap["style"]; exists && string(v) != `"simple"` {
+		return fmt.Errorf(`bad const value for "style" ("simple" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "style")
@@ -3460,8 +3660,10 @@ func (h *HeaderParameter) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constHeaderParameter is unconditionally added to JSON.
-var constHeaderParameter = json.RawMessage(`{"in":"header","style":"simple"}`)
+var (
+	// constHeaderParameter is unconditionally added to JSON.
+	constHeaderParameter = json.RawMessage(`{"in":"header","style":"simple"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (h HeaderParameter) MarshalJSON() ([]byte, error) {
@@ -3487,14 +3689,14 @@ func (c *CookieParameter) UnmarshalJSON(data []byte) error {
 		rawMap = nil
 	}
 
-	if v, ok := rawMap["in"]; !ok || string(v) != `"cookie"` {
-		return fmt.Errorf(`bad or missing const value for "in" ("cookie" expected, %s received)`, v)
+	if v, exists := rawMap["in"]; exists && string(v) != `"cookie"` {
+		return fmt.Errorf(`bad const value for "in" ("cookie" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "in")
 
-	if v, ok := rawMap["style"]; !ok || string(v) != `"form"` {
-		return fmt.Errorf(`bad or missing const value for "style" ("form" expected, %s received)`, v)
+	if v, exists := rawMap["style"]; exists && string(v) != `"form"` {
+		return fmt.Errorf(`bad const value for "style" ("form" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "style")
@@ -3502,8 +3704,10 @@ func (c *CookieParameter) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constCookieParameter is unconditionally added to JSON.
-var constCookieParameter = json.RawMessage(`{"in":"cookie","style":"form"}`)
+var (
+	// constCookieParameter is unconditionally added to JSON.
+	constCookieParameter = json.RawMessage(`{"in":"cookie","style":"form"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (c CookieParameter) MarshalJSON() ([]byte, error) {
@@ -4890,7 +5094,7 @@ var knownKeysLink = []string{
 func (l *Link) UnmarshalJSON(data []byte) error {
 	var err error
 
-	var not interface{}
+	var not LinkNot
 
 	if json.Unmarshal(data, &not) == nil {
 		return errors.New("not constraint failed for Link")
@@ -4966,6 +5170,62 @@ func (l Link) MarshalJSON() ([]byte, error) {
 	return marshalUnion(marshalLink(l), l.MapOfAnything)
 }
 
+// LinkNot structure is generated from "#/definitions/Link->not".
+//
+// Operation Id and Operation Ref are mutually exclusive.
+type LinkNot struct {
+	OperationID  interface{} `json:"operationId"`  // Required.
+	OperationRef interface{} `json:"operationRef"` // Required.
+}
+
+// WithOperationID sets OperationID value.
+func (l *LinkNot) WithOperationID(val interface{}) *LinkNot {
+	l.OperationID = val
+	return l
+}
+
+// WithOperationRef sets OperationRef value.
+func (l *LinkNot) WithOperationRef(val interface{}) *LinkNot {
+	l.OperationRef = val
+	return l
+}
+
+type marshalLinkNot LinkNot
+
+var requireKeysLinkNot = []string{
+	"operationId",
+	"operationRef",
+}
+
+// UnmarshalJSON decodes JSON.
+func (l *LinkNot) UnmarshalJSON(data []byte) error {
+	var err error
+
+	ml := marshalLinkNot(*l)
+
+	err = json.Unmarshal(data, &ml)
+	if err != nil {
+		return err
+	}
+
+	var rawMap map[string]json.RawMessage
+
+	err = json.Unmarshal(data, &rawMap)
+	if err != nil {
+		rawMap = nil
+	}
+
+	for _, key := range requireKeysLinkNot {
+		if _, found := rawMap[key]; !found {
+			return errors.New("required key missing: " + key)
+		}
+	}
+
+	*l = LinkNot(ml)
+
+	return nil
+}
+
 // LinkOrRef structure is generated from "#/definitions/LinkOrRef".
 type LinkOrRef struct {
 	LinkReference *LinkReference `json:"-"`
@@ -6246,8 +6506,8 @@ func (a *APIKeySecurityScheme) UnmarshalJSON(data []byte) error {
 		}
 	}
 
-	if v, ok := rawMap["type"]; !ok || string(v) != `"apiKey"` {
-		return fmt.Errorf(`bad or missing const value for "type" ("apiKey" expected, %s received)`, v)
+	if v, exists := rawMap["type"]; exists && string(v) != `"apiKey"` {
+		return fmt.Errorf(`bad const value for "type" ("apiKey" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "type")
@@ -6296,8 +6556,10 @@ func (a *APIKeySecurityScheme) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constAPIKeySecurityScheme is unconditionally added to JSON.
-var constAPIKeySecurityScheme = json.RawMessage(`{"type":"apiKey"}`)
+var (
+	// constAPIKeySecurityScheme is unconditionally added to JSON.
+	constAPIKeySecurityScheme = json.RawMessage(`{"type":"apiKey"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (a APIKeySecurityScheme) MarshalJSON() ([]byte, error) {
@@ -6440,8 +6702,8 @@ func (h *HTTPSecurityScheme) UnmarshalJSON(data []byte) error {
 		}
 	}
 
-	if v, ok := rawMap["type"]; !ok || string(v) != `"http"` {
-		return fmt.Errorf(`bad or missing const value for "type" ("http" expected, %s received)`, v)
+	if v, exists := rawMap["type"]; exists && string(v) != `"http"` {
+		return fmt.Errorf(`bad const value for "type" ("http" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "type")
@@ -6490,8 +6752,10 @@ func (h *HTTPSecurityScheme) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constHTTPSecurityScheme is unconditionally added to JSON.
-var constHTTPSecurityScheme = json.RawMessage(`{"type":"http"}`)
+var (
+	// constHTTPSecurityScheme is unconditionally added to JSON.
+	constHTTPSecurityScheme = json.RawMessage(`{"type":"http"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (h HTTPSecurityScheme) MarshalJSON() ([]byte, error) {
@@ -6517,8 +6781,8 @@ func (b *Bearer) UnmarshalJSON(data []byte) error {
 		rawMap = nil
 	}
 
-	if v, ok := rawMap["scheme"]; !ok || string(v) != `"bearer"` {
-		return fmt.Errorf(`bad or missing const value for "scheme" ("bearer" expected, %s received)`, v)
+	if v, exists := rawMap["scheme"]; exists && string(v) != `"bearer"` {
+		return fmt.Errorf(`bad const value for "scheme" ("bearer" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "scheme")
@@ -6526,8 +6790,10 @@ func (b *Bearer) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constBearer is unconditionally added to JSON.
-var constBearer = json.RawMessage(`{"scheme":"bearer"}`)
+var (
+	// constBearer is unconditionally added to JSON.
+	constBearer = json.RawMessage(`{"scheme":"bearer"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (b Bearer) MarshalJSON() ([]byte, error) {
@@ -6622,8 +6888,8 @@ func (o *OAuth2SecurityScheme) UnmarshalJSON(data []byte) error {
 		}
 	}
 
-	if v, ok := rawMap["type"]; !ok || string(v) != `"oauth2"` {
-		return fmt.Errorf(`bad or missing const value for "type" ("oauth2" expected, %s received)`, v)
+	if v, exists := rawMap["type"]; exists && string(v) != `"oauth2"` {
+		return fmt.Errorf(`bad const value for "type" ("oauth2" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "type")
@@ -6672,8 +6938,10 @@ func (o *OAuth2SecurityScheme) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constOAuth2SecurityScheme is unconditionally added to JSON.
-var constOAuth2SecurityScheme = json.RawMessage(`{"type":"oauth2"}`)
+var (
+	// constOAuth2SecurityScheme is unconditionally added to JSON.
+	constOAuth2SecurityScheme = json.RawMessage(`{"type":"oauth2"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (o OAuth2SecurityScheme) MarshalJSON() ([]byte, error) {
@@ -7493,8 +7761,8 @@ func (o *OpenIDConnectSecurityScheme) UnmarshalJSON(data []byte) error {
 		}
 	}
 
-	if v, ok := rawMap["type"]; !ok || string(v) != `"openIdConnect"` {
-		return fmt.Errorf(`bad or missing const value for "type" ("openIdConnect" expected, %s received)`, v)
+	if v, exists := rawMap["type"]; exists && string(v) != `"openIdConnect"` {
+		return fmt.Errorf(`bad const value for "type" ("openIdConnect" expected, %s received)`, v)
 	}
 
 	delete(rawMap, "type")
@@ -7543,8 +7811,10 @@ func (o *OpenIDConnectSecurityScheme) UnmarshalJSON(data []byte) error {
 	return nil
 }
 
-// constOpenIDConnectSecurityScheme is unconditionally added to JSON.
-var constOpenIDConnectSecurityScheme = json.RawMessage(`{"type":"openIdConnect"}`)
+var (
+	// constOpenIDConnectSecurityScheme is unconditionally added to JSON.
+	constOpenIDConnectSecurityScheme = json.RawMessage(`{"type":"openIdConnect"}`)
+)
 
 // MarshalJSON encodes JSON.
 func (o OpenIDConnectSecurityScheme) MarshalJSON() ([]byte, error) {
diff --git a/resources/schema/openapi3.json b/resources/schema/openapi3.json
index ebbc129..7fa14a0 100644
--- a/resources/schema/openapi3.json
+++ b/resources/schema/openapi3.json
@@ -271,6 +271,14 @@
       "additionalProperties": false
     },
     "SchemaOrRef": {
+      "examples": [
+        {
+          "type": "string"
+        },
+        {
+          "$ref": "#/components/schemas/Foo"
+        }
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/Schema"
@@ -281,6 +289,11 @@
       ]
     },
     "SchemaReference": {
+      "examples": [
+        {
+          "$ref": "#/components/schemas/Foo"
+        }
+      ],
       "type": "object",
       "required": [
         "$ref"
@@ -518,6 +531,9 @@
       "additionalProperties": false
     },
     "ResponseReference": {
+      "examples": [
+        {"$ref": "#/components/responses/Foo"}
+      ],
       "type": "object",
       "required": [
         "$ref"
@@ -541,6 +557,19 @@
       }
     },
     "ResponseOrRef": {
+      "examples": [
+        {"$ref": "#/components/responses/Foo"},
+        {
+          "description": "This is a sample response.",
+          "content": {
+            "application/json": {
+              "schema": {
+                "$ref": "#/components/schemas/Foo"
+              }
+            }
+          }
+        }
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/ResponseReference"
@@ -551,6 +580,18 @@
       ]
     },
     "Response": {
+      "examples": [
+        {
+          "description": "This is a sample response.",
+          "content": {
+            "application/json": {
+              "schema": {
+                "$ref": "#/components/schemas/Foo"
+              }
+            }
+          }
+        }
+      ],
       "type": "object",
       "required": [
         "description"
@@ -585,6 +626,13 @@
       "additionalProperties": false
     },
     "MediaType": {
+      "examples": [
+        {
+          "schema": {
+            "$ref": "#/components/schemas/Foo"
+          }
+        }
+      ],
       "type": "object",
       "properties": {
         "schema": {
@@ -617,6 +665,16 @@
       ]
     },
     "ExampleOrRef": {
+      "examples": [
+        {
+          "summary": "An Example",
+          "description": "This is an example.",
+          "value": "foo"
+        },
+        {
+          "$ref": "#/components/examples/Foo"
+        }
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/ExampleReference"
@@ -627,6 +685,7 @@
       ]
     },
     "ExampleReference": {
+      "examples": [{"$ref": "#/components/examples/Foo"}],
       "type": "object",
       "required": [
         "$ref"
@@ -650,6 +709,13 @@
       }
     },
     "Example": {
+      "examples": [
+        {
+          "summary": "An Example",
+          "description": "This is an example.",
+          "value": "foo"
+        }
+      ],
       "type": "object",
       "properties": {
         "summary": {
@@ -672,6 +738,16 @@
       "additionalProperties": false
     },
     "HeaderOrRef": {
+      "examples": [
+        {"$ref": "#/components/headers/Foo"},
+        {
+          "style": "simple",
+          "schema": {
+            "type": "string",
+            "description": "Sample header response."
+          }
+        }
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/HeaderReference"
@@ -682,6 +758,7 @@
       ]
     },
     "HeaderReference": {
+      "examples": [{"$ref": "#/components/headers/Foo"}],
       "type": "object",
       "required": [
         "$ref"
@@ -705,6 +782,15 @@
       }
     },
     "Header": {
+      "examples": [
+        {
+          "style": "simple",
+          "schema": {
+            "type": "string",
+            "description": "Sample header response."
+          }
+        }
+      ],
       "type": "object",
       "properties": {
         "description": {
@@ -960,25 +1046,79 @@
       }
     },
     "SchemaXORContent": {
+      "examples": [
+        {
+          "schema": {
+            "type": "string"
+          }
+        },
+        {
+          "content": {
+            "application/json": {
+              "schema": {
+                "$ref": "#/components/schemas/Foo"
+              }
+            }
+          }
+        }
+      ],
       "description": "Schema and content are mutually exclusive, at least one is required",
       "not": {
+        "examples": [
+          {
+            "schema": {
+              "type": "string"
+            },
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Foo"
+                }
+              }
+            }
+          }
+        ],
         "required": [
           "schema",
           "content"
-        ]
+        ],
+        "properties": {
+          "schema": {},
+          "content": {}
+        }
       },
       "oneOf": [
         {
+          "examples": [
+            {"schema": {"type": "string"}}
+          ],
           "title": "Has Schema",
           "required": [
             "schema"
-          ]
+          ],
+          "properties": {
+            "schema": {}
+          }
         },
         {
+          "examples": [
+            {
+              "content": {
+                "application/json": {
+                  "schema": {
+                    "$ref": "#/components/schemas/Foo"
+                  }
+                }
+              }
+            }
+          ],
           "title": "Has Content",
           "required": [
             "content"
           ],
+          "properties": {
+            "content": {}
+          },
           "description": "Some properties are not allowed if content is present",
           "allOf": [
             {
@@ -1021,6 +1161,19 @@
       ]
     },
     "ParameterOrRef": {
+      "examples": [
+        {
+          "name": "id",
+          "in": "path",
+          "required": true,
+          "schema": {
+            "type": "string"
+          }
+        },
+        {
+          "$ref": "#/components/parameters/Foo"
+        }
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/ParameterReference"
@@ -1031,6 +1184,11 @@
       ]
     },
     "ParameterReference": {
+      "examples": [
+        {
+          "$ref": "#/components/parameters/Foo"
+        }
+      ],
       "type": "object",
       "required": [
         "$ref"
@@ -1054,6 +1212,16 @@
       }
     },
     "Parameter": {
+      "examples": [
+        {
+          "name": "id",
+          "in": "path",
+          "required": true,
+          "schema": {
+            "type": "string"
+          }
+        }
+      ],
       "type": "object",
       "properties": {
         "name": {
@@ -1061,7 +1229,12 @@
         },
         "in": {
           "type": "string",
-          "enum": ["path", "query", "header", "cookie"]
+          "enum": [
+            "path",
+            "query",
+            "header",
+            "cookie"
+          ]
         },
         "description": {
           "type": "string"
@@ -1216,6 +1389,18 @@
       ]
     },
     "RequestBodyOrRef": {
+      "examples": [
+        {"$ref": "#/components/requestBodies/Foo"},
+        {
+          "content": {
+            "multipart/form-data": {
+              "schema": {
+                "$ref": "#/components/schemas/Foo"
+              }
+            }
+          }
+        }
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/RequestBodyReference"
@@ -1226,6 +1411,7 @@
       ]
     },
     "RequestBodyReference": {
+      "examples": [{"$ref": "#/components/requestBodies/Foo"}],
       "type": "object",
       "required": [
         "$ref"
@@ -1249,6 +1435,17 @@
       }
     },
     "RequestBody": {
+      "examples": [
+        {
+          "content": {
+            "multipart/form-data": {
+              "schema": {
+                "$ref": "#/components/schemas/Foo"
+              }
+            }
+          }
+        }
+      ],
       "type": "object",
       "required": [
         "content"
@@ -1275,6 +1472,14 @@
       "additionalProperties": false
     },
     "SecuritySchemeOrRef": {
+      "examples": [
+        {"$ref": "#/components/securitySchemes/Foo"},
+        {
+          "type": "http",
+          "scheme": "basic",
+          "description": "Admin access"
+        }
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/SecuritySchemeReference"
@@ -1285,6 +1490,9 @@
       ]
     },
     "SecuritySchemeReference": {
+      "examples": [
+        {"$ref": "#/components/securitySchemes/Foo"}
+      ],
       "type": "object",
       "required": [
         "$ref"
@@ -1308,6 +1516,13 @@
       }
     },
     "SecurityScheme": {
+      "examples": [
+        {
+          "type": "http",
+          "scheme": "basic",
+          "description": "Admin access"
+        }
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/APIKeySecurityScheme"
@@ -1608,6 +1823,10 @@
       "additionalProperties": false
     },
     "LinkOrRef": {
+      "examples": [
+        {"$ref": "#/components/links/Foo"},
+        {"operationId": "foo"}
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/LinkReference"
@@ -1618,6 +1837,7 @@
       ]
     },
     "LinkReference": {
+      "examples": [{"$ref": "#/components/links/Foo"}],
       "type": "object",
       "required": [
         "$ref"
@@ -1641,6 +1861,7 @@
       }
     },
     "Link": {
+      "examples": [{"operationId": "foo"}],
       "type": "object",
       "properties": {
         "operationId": {
@@ -1670,14 +1891,25 @@
       },
       "additionalProperties": false,
       "not": {
+        "examples": [
+          {"operationId": "foo", "operationRef": "bar"}
+        ],
         "description": "Operation Id and Operation Ref are mutually exclusive",
         "required": [
           "operationId",
           "operationRef"
-        ]
+        ],
+        "properties": {
+          "operationId": {},
+          "operationRef": {}
+        }
       }
     },
     "CallbackOrRef": {
+      "examples": [
+        {"$ref": "#/components/callbacks/Foo"},
+        {"foo": {"$ref": "#/paths/~1foo"}}
+      ],
       "oneOf": [
         {
           "$ref": "#/definitions/CallbackReference"
@@ -1688,6 +1920,9 @@
       ]
     },
     "CallbackReference": {
+      "examples": [
+        {"$ref": "#/components/callbacks/Foo"}
+      ],
       "type": "object",
       "required": [
         "$ref"


Test patch:
diff --git a/openapi3/entities_test.go b/openapi3/entities_test.go
new file mode 100644
index 0000000..b6f110f
--- /dev/null
+++ b/openapi3/entities_test.go
@@ -0,0 +1,1061 @@
+// Code generated by github.com/swaggest/json-cli v1.8.0, DO NOT EDIT.
+
+package openapi3
+
+import (
+	"encoding/json"
+	"testing"
+
+	"github.com/stretchr/testify/require"
+	"github.com/swaggest/assertjson"
+)
+
+func TestSpec_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"openapi":"cbbfff","info":{"title":"cdef","description":"aadce","termsOfService":"dc","contact":{"name":"daecfe","url":"cddbd","email":"accdf"},"license":{"name":"fd","url":"ad"},"version":"ead"},"externalDocs":{"description":"adbfc","url":"aebd"},"servers":[{"url":"ddbfe","description":"bfcce","variables":{"fdfed":{"enum":["cdba"],"default":"bedceb","description":"dadf"}}}],"security":[{"bffd":["eae"]}],"tags":[{"name":"db","description":"bfdbc","externalDocs":{"description":"ec","url":"eb"}}],"paths":{},"components":{"schemas":{},"responses":{},"parameters":{},"examples":{},"requestBodies":{},"headers":{},"securitySchemes":{},"links":{},"callbacks":{}}}`)
+		v         Spec
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestInfo_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"title":"fffbce","description":"dca","termsOfService":"ecaddd","contact":{"name":"bcf","url":"fa","email":"abdfad"},"license":{"name":"aeab","url":"bafd"},"version":"eaceae"}`)
+		v         Info
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestContact_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"name":"cc","url":"eadf","email":"ecdaea"}`)
+		v         Contact
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestLicense_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"name":"bcacc","url":"fcadff"}`)
+		v         License
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestExternalDocumentation_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"description":"eca","url":"bdb"}`)
+		v         ExternalDocumentation
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestServer_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"url":"dfe","description":"cfdcf","variables":{"baf":{"enum":["dda"],"default":"acdcfe","description":"de"}}}`)
+		v         Server
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestServerVariable_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"enum":["befdf"],"default":"dcba","description":"bffbb"}`)
+		v         ServerVariable
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestTag_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"name":"cdf","description":"caf","externalDocs":{"description":"eeacab","url":"bd"}}`)
+		v         Tag
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestPathItem_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"db","summary":"ebae","description":"fcbcf","servers":[{"url":"ce","description":"bb","variables":{"eabafb":{"enum":["ab"],"default":"daac","description":"cba"}}}],"parameters":[{"$ref":"#/components/parameters/Foo"}]}`)
+		v         PathItem
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestParameterReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/parameters/Foo"}`)
+		v         ParameterReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestParameter_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"name":"id","in":"path","required":true,"schema":{"type":"string"}}`)
+		v         Parameter
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSchema_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"title":"bed","multipleOf":9700.2,"maximum":501.131,"exclusiveMaximum":true,"minimum":8468.441,"exclusiveMinimum":true,"maxLength":7410,"minLength":2398,"pattern":"cc","maxItems":6200,"minItems":9818,"uniqueItems":true,"maxProperties":8290,"minProperties":8930,"required":["bfee"],"enum":[null],"type":"boolean","not":{"$ref":"#/components/schemas/Foo"},"allOf":[{"$ref":"#/components/schemas/Foo"}],"oneOf":[{"$ref":"#/components/schemas/Foo"}],"anyOf":[{"$ref":"#/components/schemas/Foo"}],"items":{"$ref":"#/components/schemas/Foo"},"properties":{"eaeaae":{"type":"string"}},"additionalProperties":true,"description":"ac","format":"abdb","nullable":true,"discriminator":{"propertyName":"cccf","mapping":{"bed":"cec"}},"readOnly":true,"writeOnly":true,"externalDocs":{"description":"efecaf","url":"fdeeb"},"deprecated":true,"xml":{"name":"afcfaf","namespace":"ec","prefix":"eaeeaf","attribute":true,"wrapped":true}}`)
+		v         Schema
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSchemaReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/schemas/Foo"}`)
+		v         SchemaReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSchemaOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"type":"string"}`)
+		v         SchemaOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSchemaAdditionalProperties_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/schemas/Foo"}`)
+		v         SchemaAdditionalProperties
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestDiscriminator_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"propertyName":"fdcbaf","mapping":{"abcdaf":"ac"}}`)
+		v         Discriminator
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestXML_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"name":"dcefd","namespace":"dfecaf","prefix":"ffaf","attribute":true,"wrapped":true}`)
+		v         XML
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestMediaType_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"schema":{"$ref":"#/components/schemas/Foo"}}`)
+		v         MediaType
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestExampleReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/examples/Foo"}`)
+		v         ExampleReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestExample_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"summary":"An Example","description":"This is an example.","value":"foo"}`)
+		v         Example
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestExampleOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/examples/Foo"}`)
+		v         ExampleOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestEncoding_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"contentType":"cd","headers":{"bdeb":{"style":"simple","schema":{"type":"string","description":"Sample header response."}}},"style":"form","explode":true,"allowReserved":true}`)
+		v         Encoding
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestHeader_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"style":"simple","schema":{"type":"string","description":"Sample header response."}}`)
+		v         Header
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestHasSchema_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"schema":{"type":"string"}}`)
+		v         HasSchema
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestHasContent_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Foo"}}}}`)
+		v         HasContent
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSchemaXORContent_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Foo"}}}}`)
+		v         SchemaXORContent
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSchemaXORContentNot_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"schema":{"type":"string"},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Foo"}}}}`)
+		v         SchemaXORContentNot
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestPathParameter_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"in":"path","style":"label","required":true}`)
+		v         PathParameter
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestQueryParameter_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"in":"query","style":"pipeDelimited"}`)
+		v         QueryParameter
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestHeaderParameter_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"in":"header","style":"simple"}`)
+		v         HeaderParameter
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestCookieParameter_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"in":"cookie","style":"form"}`)
+		v         CookieParameter
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestParameterLocation_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"in":"cookie","style":"form"}`)
+		v         ParameterLocation
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestParameterOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"name":"id","in":"path","required":true,"schema":{"type":"string"}}`)
+		v         ParameterOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestOperation_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"tags":["edc"],"summary":"aadabb","description":"fbadeb","externalDocs":{"description":"eccf","url":"eeacfa"},"operationId":"ffd","parameters":[{"$ref":"#/components/parameters/Foo"}],"requestBody":{"$ref":"#/components/requestBodies/Foo"},"responses":{"default":{"description":"This is a sample response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Foo"}}}}},"callbacks":{"afa":{"$ref":"#/components/callbacks/Foo"}},"deprecated":true,"security":[{"cac":["ddd"]}],"servers":[{"url":"aceba","description":"bc","variables":{"dfa":{"enum":["bcacab"],"default":"ae","description":"feb"}}}]}`)
+		v         Operation
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestRequestBodyReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/requestBodies/Foo"}`)
+		v         RequestBodyReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestRequestBody_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Foo"}}}}`)
+		v         RequestBody
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestRequestBodyOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Foo"}}}}`)
+		v         RequestBodyOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestResponses_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"default":{"description":"This is a sample response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Foo"}}}}}`)
+		v         Responses
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestResponseReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/responses/Foo"}`)
+		v         ResponseReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestResponse_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"description":"This is a sample response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Foo"}}}}`)
+		v         Response
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestHeaderReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/headers/Foo"}`)
+		v         HeaderReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestHeaderOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"style":"simple","schema":{"type":"string","description":"Sample header response."}}`)
+		v         HeaderOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestLinkReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/links/Foo"}`)
+		v         LinkReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestLink_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"operationId":"foo"}`)
+		v         Link
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestLinkNot_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"operationId":"foo","operationRef":"bar"}`)
+		v         LinkNot
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestLinkOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/links/Foo"}`)
+		v         LinkOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestResponseOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/responses/Foo"}`)
+		v         ResponseOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestCallbackReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/callbacks/Foo"}`)
+		v         CallbackReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestCallback_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"fd":{"$ref":"acf","summary":"eeea","description":"ccedaf","servers":[{"url":"acaf","description":"cfd","variables":{"ddb":{"enum":["fa"],"default":"ccacec","description":"ece"}}}],"parameters":[{"$ref":"#/components/parameters/Foo"}]}}`)
+		v         Callback
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestCallbackOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/callbacks/Foo"}`)
+		v         CallbackOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestPaths_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         Paths
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponents_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"schemas":{},"responses":{},"parameters":{},"examples":{},"requestBodies":{},"headers":{},"securitySchemes":{},"links":{},"callbacks":{}}`)
+		v         Components
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsSchemas_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsSchemas
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsResponses_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsResponses
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsParameters_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsParameters
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsExamples_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsExamples
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsRequestBodies_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsRequestBodies
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsHeaders_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsHeaders
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSecuritySchemeReference_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/securitySchemes/Foo"}`)
+		v         SecuritySchemeReference
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestAPIKeySecurityScheme_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"type":"apiKey","name":"eadbf","in":"query","description":"fac"}`)
+		v         APIKeySecurityScheme
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestHTTPSecurityScheme_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"scheme":"bee","bearerFormat":"cffaee","description":"dcddce","type":"http"}`)
+		v         HTTPSecurityScheme
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestBearer_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"scheme":"bearer"}`)
+		v         Bearer
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestNonBearer_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         NonBearer
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestOAuth2SecurityScheme_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"type":"oauth2","flows":{"implicit":{"authorizationUrl":"eb","refreshUrl":"ccec","scopes":{"dbcc":"ecabba"}},"password":{"tokenUrl":"ccfc","refreshUrl":"dfce","scopes":{"dbbfd":"fabcce"}},"clientCredentials":{"tokenUrl":"caee","refreshUrl":"cbed","scopes":{"edbe":"bddcd"}},"authorizationCode":{"authorizationUrl":"eb","tokenUrl":"bbab","refreshUrl":"ddf","scopes":{"ebdb":"cbe"}}},"description":"becfee"}`)
+		v         OAuth2SecurityScheme
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestOAuthFlows_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"implicit":{"authorizationUrl":"aaab","refreshUrl":"fe","scopes":{"da":"ce"}},"password":{"tokenUrl":"bfcfa","refreshUrl":"af","scopes":{"bfe":"cf"}},"clientCredentials":{"tokenUrl":"accb","refreshUrl":"aa","scopes":{"dfba":"ab"}},"authorizationCode":{"authorizationUrl":"ac","tokenUrl":"faceb","refreshUrl":"cffd","scopes":{"bbeffa":"bfd"}}}`)
+		v         OAuthFlows
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestImplicitOAuthFlow_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"authorizationUrl":"dde","refreshUrl":"ecf","scopes":{"fbffc":"ffde"}}`)
+		v         ImplicitOAuthFlow
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestPasswordOAuthFlow_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"tokenUrl":"df","refreshUrl":"aeedb","scopes":{"ccafeb":"eea"}}`)
+		v         PasswordOAuthFlow
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestClientCredentialsFlow_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"tokenUrl":"efaabe","refreshUrl":"cbe","scopes":{"caa":"bf"}}`)
+		v         ClientCredentialsFlow
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestAuthorizationCodeOAuthFlow_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"authorizationUrl":"aacdcd","tokenUrl":"bdc","refreshUrl":"ebaebb","scopes":{"bc":"daaf"}}`)
+		v         AuthorizationCodeOAuthFlow
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestOpenIDConnectSecurityScheme_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"type":"openIdConnect","openIdConnectUrl":"eb","description":"bfddfd"}`)
+		v         OpenIDConnectSecurityScheme
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSecurityScheme_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"type":"http","scheme":"basic","description":"Admin access"}`)
+		v         SecurityScheme
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestSecuritySchemeOrRef_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{"$ref":"#/components/securitySchemes/Foo"}`)
+		v         SecuritySchemeOrRef
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsSecuritySchemes_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsSecuritySchemes
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsLinks_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsLinks
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}
+
+func TestComponentsCallbacks_MarshalJSON_roundtrip(t *testing.T) {
+	var (
+		jsonValue = []byte(`{}`)
+		v         ComponentsCallbacks
+	)
+
+	require.NoError(t, json.Unmarshal(jsonValue, &v))
+
+	marshaled, err := json.Marshal(v)
+	require.NoError(t, err)
+	require.NoError(t, json.Unmarshal(marshaled, &v))
+	assertjson.Equal(t, jsonValue, marshaled)
+}