-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
addd flag for media type example set value #3975
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/mixin/ExampleMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.swagger.v3.core.jackson.mixin; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import java.util.Map; | ||
|
||
public abstract class ExampleMixin { | ||
|
||
@JsonAnyGetter | ||
public abstract Map<String, Object> getExtensions(); | ||
|
||
@JsonAnySetter | ||
public abstract void addExtension(String name, Object value); | ||
|
||
@JsonInclude(JsonInclude.Include.CUSTOM) | ||
public abstract Object getValue(); | ||
|
||
@JsonIgnore | ||
public abstract boolean getValueSetFlag(); | ||
} |
23 changes: 23 additions & 0 deletions
23
modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/mixin/MediaTypeMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.swagger.v3.core.jackson.mixin; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAnyGetter; | ||
import com.fasterxml.jackson.annotation.JsonAnySetter; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
import java.util.Map; | ||
|
||
public abstract class MediaTypeMixin { | ||
|
||
@JsonAnyGetter | ||
public abstract Map<String, Object> getExtensions(); | ||
|
||
@JsonAnySetter | ||
public abstract void addExtension(String name, Object value); | ||
|
||
@JsonIgnore | ||
public abstract boolean getExampleSetFlag(); | ||
|
||
@JsonInclude(JsonInclude.Include.CUSTOM) | ||
public abstract Object getExample(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
modules/swagger-core/src/test/resources/specFiles/media-type-null-example.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
openapi: "3.0.1" | ||
info: | ||
version: 1.0.0 | ||
title: Swagger Petstore | ||
license: | ||
name: MIT | ||
servers: | ||
- url: https://petstore3.swagger.io/api/v3 | ||
paths: | ||
/pet: | ||
post: | ||
tags: | ||
- pet | ||
summary: Add a new pet to the store | ||
operationId: addPet | ||
requestBody: | ||
description: Pet object that needs to be added to the store | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
example: | ||
id: 10 | ||
name: kitty | ||
tag: something | ||
required: true | ||
responses: | ||
200: | ||
description: Expected response to a valid request | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Pet" | ||
/pets/{petId}: | ||
get: | ||
summary: Info for a specific pet | ||
operationId: showPetById | ||
tags: | ||
- pets | ||
parameters: | ||
- name: petId | ||
in: path | ||
required: true | ||
description: The id of the pet to retrieve | ||
schema: | ||
type: string | ||
responses: | ||
200: | ||
description: Expected response to a valid request | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Pet" | ||
example: null | ||
components: | ||
schemas: | ||
Pet: | ||
required: | ||
- id | ||
- name | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
name: | ||
type: string | ||
tag: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,8 @@ public class MediaType { | |
private Map<String, Encoding> encoding = null; | ||
private java.util.Map<String, Object> extensions = null; | ||
|
||
private boolean exampleSetFlag; | ||
|
||
/** | ||
* returns the schema property from a MediaType instance. | ||
* | ||
|
@@ -93,10 +95,11 @@ public Object getExample() { | |
|
||
public void setExample(Object example) { | ||
this.example = example; | ||
exampleSetFlag = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see how this is done in Schema to correctly handle all scenarios |
||
} | ||
|
||
public MediaType example(Object example) { | ||
this.example = example; | ||
setExample(example); | ||
return this; | ||
} | ||
|
||
|
@@ -127,6 +130,14 @@ public MediaType addEncoding(String key, Encoding encodingItem) { | |
return this; | ||
} | ||
|
||
public boolean getExampleSetFlag() { | ||
return exampleSetFlag; | ||
} | ||
|
||
public void setExampleSetFlag(boolean exampleSetFlag) { | ||
this.exampleSetFlag = exampleSetFlag; | ||
} | ||
|
||
@Override | ||
public boolean equals(java.lang.Object o) { | ||
if (this == o) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see how this is done in Schema to correctly handle all scenarios