-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: resolve PrimitiveType casting for OpenAPI 3.1 schemas (#4963) #4989
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
Open
K5qu4r3d
wants to merge
19
commits into
swagger-api:master
Choose a base branch
from
K5qu4r3d:bug/4963-fix-schema-primitive-boxed-type-cast
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+323
−74
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f4884c4
fix: verify Schema object getTypes() is not null or empty
K5qu4r3d debfed1
fix: add type values to all PrimitiveType JSON schemas
K5qu4r3d 7c0a6af
fix: remove "type" and "types" value declarations from OBJECT enum
K5qu4r3d 4baa804
Revert "fix: remove "type" and "types" value declarations from OBJECT…
K5qu4r3d e8cfe79
fix: fix existing test cases
K5qu4r3d 5c655c6
Merge branch 'master' into bug/4963-fix-schema-primitive-boxed-type-cast
K5qu4r3d 02179c1
fix: fix existing test cases pt. 2
K5qu4r3d 23253a2
fix: update access modifier of class PrimitiveType.DateStub
K5qu4r3d 26ab407
test: add test cases for updated OpenAPI 3.1 "type"/"types" value sch…
K5qu4r3d ecb8929
fix: update type values for date/time 3.1 schemas
K5qu4r3d b7791fa
Merge branch 'master' into bug/4963-fix-schema-primitive-boxed-type-cast
K5qu4r3d e4d7b45
fix: add "LocalTime" class mappings for PARTIAL_TIME
K5qu4r3d 75bc935
fix: remove duplicate "LocalTime" model from expected YAML
K5qu4r3d 935dacd
fix: convert APIResponsesResourceTest to parameterized test
K5qu4r3d 1e1711a
Merge branch 'master' into bug/4963-fix-schema-primitive-boxed-type-cast
daniel-kmiecik 1f0d050
Merge branch 'master' into bug/4963-fix-schema-primitive-boxed-type-cast
daniel-kmiecik cecddf1
fix: remove unnecessary comment
K5qu4r3d e6beba3
fix: remove enablePartialTime() call
K5qu4r3d c0da882
fix: rename variable for clarity
K5qu4r3d 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
61 changes: 61 additions & 0 deletions
61
modules/swagger-jaxrs2/src/test/java/io/swagger/v3/jaxrs2/APIResponsesResourceTest.java
This file contains hidden or 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,61 @@ | ||
| package io.swagger.v3.jaxrs2; | ||
|
|
||
| import io.swagger.v3.jaxrs2.resources.APIResponsesResource; | ||
| import io.swagger.v3.oas.integration.SwaggerConfiguration; | ||
| import io.swagger.v3.oas.models.OpenAPI; | ||
| import io.swagger.v3.oas.models.Operation; | ||
| import io.swagger.v3.oas.models.media.Schema; | ||
| import org.testng.annotations.BeforeMethod; | ||
| import org.testng.annotations.DataProvider; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import static org.testng.AssertJUnit.assertEquals; | ||
|
|
||
| public class APIResponsesResourceTest { | ||
| private OpenAPI openAPI; | ||
|
|
||
| // Prepare list of resource schema URLs | ||
| @DataProvider(name = "schemas") | ||
| public String[] getSchemas() { | ||
| return new String[] { | ||
| "/postStringOrEmailSchemaContent", | ||
| "/postBooleanSchemaContent", | ||
| "/postByteOrBinarySchemaContent", | ||
| "/postURISchemaContent", | ||
| "/postURLSchemaContent", | ||
| "/postUUIDSchemaContent", | ||
| "/postIntegerSchemaContent", | ||
| "/postLongSchemaContent", | ||
| "/postFloatSchemaContent", | ||
| "/postDoubleSchemaContent", | ||
| "/postBigIntegerSchemaContent", | ||
| "/postBigDecimalSchemaContent", | ||
| "/postNumberSchemaContent", | ||
| "/postDateStubSchemaContent", | ||
| "/postDateSchemaContent", | ||
| "/postLocalTimeSchemaContent", | ||
| "/postFileSchemaContent", | ||
| "/postObjectSchemaContent" | ||
| }; | ||
| } | ||
|
|
||
| @BeforeMethod | ||
| public void setUp() { | ||
| SwaggerConfiguration config = new SwaggerConfiguration().openAPI31(true); | ||
| Reader reader = new Reader(config); | ||
| openAPI = reader.read(APIResponsesResource.class); | ||
| } | ||
|
|
||
| private Schema getResponseSchema(String path) { | ||
| Operation postOperation = openAPI.getPaths().get(path).getPost(); | ||
| return postOperation.getResponses().get("200").getContent().get("*/*").getSchema(); | ||
| } | ||
|
|
||
| @Test(dataProvider = "schemas") | ||
| public void testSchemaAPIResource31(String schema) { | ||
| Schema responseSchema = getResponseSchema(schema); | ||
|
|
||
| // Value of field "type" must equal value of field "types" | ||
| assertEquals(responseSchema.getType(), responseSchema.getTypes().iterator().next()); | ||
| } | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
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.
Please provide at least on test with 'null' in type
Uh oh!
There was an error while loading. Please reload this page.
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.
For the new test case, do we want "null" type for
SimpleTagclass or itsannotatedproperty? Sorry if I'm looking at this incorrectly.