-
Notifications
You must be signed in to change notification settings - Fork 537
fixing relative references #726
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fa95a67
fixing relative references
gracekarina e4fb582
fixing relative ref after deserializing issue #727
gracekarina b7df4fd
Merge branch '2.0' of https://github.com/swagger-api/swagger-parser i…
gracekarina fafb4b6
more validations where there is a - refs - issue #727
gracekarina 4a8e218
Do not read info block if it does not exist
9d0094a
Add a test case for issue #755
jmini 3c7995c
Merge pull request #753 from bmordue/no-info-block-oas3
ralphdoe 23dc343
Merge branch '2.0' into OAS3-relative-resolving
gracekarina 96c54a7
Merge branch '2.0' into OAS3-relative-resolving
gracekarina 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
14 changes: 14 additions & 0 deletions
14
modules/swagger-parser-v2-converter/src/test/resources/issue-755.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,14 @@ | ||
| swagger: '2.0' | ||
| host: petstore.swagger.io | ||
| basePath: /v2 | ||
| schemes: | ||
| - http | ||
| paths: | ||
| /ping: | ||
| post: | ||
| summary: test | ||
| description: 'test it' | ||
| operationId: pingOp | ||
| responses: | ||
| '200': | ||
| description: OK |
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
31 changes: 23 additions & 8 deletions
31
modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/PathUtils.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 |
|---|---|---|
| @@ -1,21 +1,36 @@ | ||
| package io.swagger.v3.parser.util; | ||
|
|
||
| import java.net.URI; | ||
| import java.net.URL; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
|
|
||
| public class PathUtils { | ||
|
|
||
|
|
||
| public static Path getParentDirectoryOfFile(String fileStr) { | ||
| final String fileScheme = "file:"; | ||
| Path file; | ||
| fileStr = fileStr.replaceAll("\\\\","/"); | ||
| if (fileStr.toLowerCase().startsWith(fileScheme)) { | ||
| file = Paths.get(URI.create(fileStr)).toAbsolutePath(); | ||
| } else { | ||
| file = Paths.get(fileStr).toAbsolutePath(); | ||
| public static Path getParentDirectoryOfFile(String location) { | ||
| Path file = null; | ||
| try { | ||
| location = location.replaceAll("\\\\","/"); | ||
| final String fileScheme = "file:"; | ||
| if (location.toLowerCase().startsWith(fileScheme)) { | ||
| file = Paths.get(URI.create(location)).toAbsolutePath(); | ||
| } else { | ||
| file = Paths.get(location).toAbsolutePath(); | ||
| } | ||
| if (!Files.exists(file)) { | ||
| URL url = PathUtils.class.getClassLoader().getResource(location); | ||
| file = Paths.get((URI.create(url.toExternalForm()))); | ||
| return file.getParent(); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } catch (Exception e) { | ||
| e.getMessage(); | ||
| } | ||
|
|
||
| return file.toAbsolutePath().getParent(); | ||
| } | ||
| } |
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
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.
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.
Should this parentDirectory be the directory of where the file containing $ref exists or the directory of the main file which is read first by the Parser?
I am asking this because this seems to be the behavior of swagger-ui. And to make my swagger spec work with both I had to use links.
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.
is the directory where the file is