-
Notifications
You must be signed in to change notification settings - Fork 537
fix Parsing of Model "example" is not consistent with parsing of Prop… #449
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
Merged
gracekarina
merged 2 commits into
swagger-api:master
from
boillodmanuel:fix/model-example
Mar 14, 2018
Merged
Changes from all commits
Commits
Show all changes
2 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
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
22 changes: 22 additions & 0 deletions
22
modules/swagger-parser/src/test/java/io/swagger/parser/util/TestUtils.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,22 @@ | ||
| package io.swagger.parser.util; | ||
|
|
||
| import java.io.File; | ||
| import java.net.URISyntaxException; | ||
|
|
||
| public class TestUtils { | ||
|
|
||
| /** | ||
| * @param resourceLocation The resource location relative to classpath root (ie: starts with '/') | ||
| */ | ||
| public static String getResourceAbsolutePath(String resourceLocation) { | ||
| if (!resourceLocation.startsWith("/")) { | ||
| throw new RuntimeException("resourceLocation should be relative to classpath root (ie: starts with '/')"); | ||
| } | ||
| try { | ||
| // we use toURI | ||
| return new File(TestUtils.class.getResource(resourceLocation).toURI()).getAbsolutePath(); | ||
| } catch (URISyntaxException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
modules/swagger-parser/src/test/resources/definition_example.yaml
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,57 @@ | ||
| --- | ||
| swagger: '2.0' | ||
| info: | ||
| version: 1.0.0 | ||
| title: Pets Store | ||
| paths: {} | ||
| definitions: | ||
|
|
||
| NumberType: | ||
| type: number | ||
| example: 2.0 | ||
|
|
||
| IntegerType: | ||
| type: integer | ||
| example: 2 | ||
|
|
||
| StringType: | ||
| type: string | ||
| example: "2" | ||
|
|
||
| ObjectType: | ||
| type: object | ||
| example: | ||
| propertyA: valueA | ||
| propertyB: 123 | ||
|
|
||
| ArrayType: | ||
| type: array | ||
| items: | ||
| type: object | ||
| example: | ||
| - propertyA: valueA1 | ||
| propertyB: 123 | ||
| - propertyA: valueA2 | ||
| propertyB: 456 | ||
|
|
||
| NumberTypeStringExample: | ||
| type: number | ||
| example: "2.0" | ||
|
|
||
| IntegerTypeStringExample: | ||
| type: integer | ||
| example: "2" | ||
|
|
||
| StringTypeStringExample: | ||
| type: string | ||
| example: "2" | ||
|
|
||
| ObjectTypeStringExample: | ||
| type: object | ||
| example: "{\"propertyA\": \"valueA\", \"propertyB\": 123}" | ||
|
|
||
| ArrayTypeStringExample: | ||
| type: array | ||
| items: | ||
| type: object | ||
| example: "[{\"propertyA\": \"valueA1\", \"propertyB\": 123}, {\"propertyA\": \"valueA2\", \"propertyB\": 456}]" |
42 changes: 0 additions & 42 deletions
42
modules/swagger-parser/src/test/resources/objectExample.json
This file was deleted.
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.
Hi, why delete this test instead of making it work with the new approach?.
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.
Could I try to make this test work? Again, anything to move this fix along would be great.
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.
yes, please and rebase as well. Thanks!
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.
So, grab the pull request, fix the test, rebase against the latest, and resubmit the pull request? You know I'm not the original author of this pull request ...
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.
oh ok. So how else can we speed this fix?
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.
I'll try to patch up the pull request and see if I can make the test work. Hopefully sometime later today or tomorrow (unless the original author fixes this first).
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.
After some work/investigation and consulting the original issue 255, I believe this fix is correct and the original was not (and this is also indicated/hinted at in the fix of 255). There are unit tests in this fix that verify that a proper ArrayModel is returned for the array example (not a string as in the prior fixes unit test). I also tested with several downstream pipelines (one that takes swagger -> markdown -> asciidoc -> pdf and a similar one that takes swagger -> markdown -> asciidoc -> static html). In each case, the fixed version works (i.e. the final pdf / html with an array of objects is displayed correctly). So, the test was removed because it is somewhat redundant. Also, it seems like you might want the original issue 255 authors/collaborators to weigh in as I do not know what their downstream usage of the swagger-parser is (so this fix could break their usage - I cannot tell).
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.
So, are we good to go? Will this show up soon in a release?
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.
Hi we need this is updated with master branch, I do not have permission to update the @boillodmanuel fork, let me check what we can do. 👍
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.
@kidnme merged!