Skip to content
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

Fix URISyntaxException for $ref to path with param #1523

Merged
merged 7 commits into from Apr 30, 2021

Conversation

rmzzz
Copy link
Contributor

@rmzzz rmzzz commented Jan 25, 2021

In case $ref refers to path with parameter, using whole $ref in processRefSchema as externalFile argument results in URISyntaxException

java.net.URISyntaxException: Illegal character in fragment at index 49: ../v1/checkout.yml#/paths/1checkout1orderItem~1{orderItemId}
at java.base/java.net.URI$Parser.fail(URI.java:2915)
at java.base/java.net.URI$Parser.checkChars(URI.java:3086)
at java.base/java.net.URI$Parser.parse(URI.java:3130)
at java.base/java.net.URI.(URI.java:600)
at io.swagger.v3.parser.processors.ExternalRefProcessor.join(ExternalRefProcessor.java:977)
at io.swagger.v3.parser.processors.ExternalRefProcessor.constructRef(ExternalRefProcessor.java:928)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchema(ExternalRefProcessor.java:918)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchemaObject(ExternalRefProcessor.java:867)
at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalPathItem(ExternalRefProcessor.java:280)
at io.swagger.v3.parser.processors.PathsProcessor.processReferencePath(PathsProcessor.java:299)
at io.swagger.v3.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:63)
at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:49)

Using only file part (without fragment) produces expected result.

rmzzz and others added 4 commits January 25, 2021 16:37
In case $ref refers to path with parameter, using whole $ref in processRefSchema as externalFile argument results in URISyntaxException

java.net.URISyntaxException: Illegal character in fragment at index 49: ../v1/checkout.yml#/paths/~1checkout~1orderItem~1{orderItemId}
	at java.base/java.net.URI$Parser.fail(URI.java:2915)
	at java.base/java.net.URI$Parser.checkChars(URI.java:3086)
	at java.base/java.net.URI$Parser.parse(URI.java:3130)
	at java.base/java.net.URI.<init>(URI.java:600)
	at io.swagger.v3.parser.processors.ExternalRefProcessor.join(ExternalRefProcessor.java:977)
	at io.swagger.v3.parser.processors.ExternalRefProcessor.constructRef(ExternalRefProcessor.java:928)
	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchema(ExternalRefProcessor.java:918)
	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefSchemaObject(ExternalRefProcessor.java:867)
	at io.swagger.v3.parser.processors.ExternalRefProcessor.processRefToExternalPathItem(ExternalRefProcessor.java:280)
	at io.swagger.v3.parser.processors.PathsProcessor.processReferencePath(PathsProcessor.java:299)
	at io.swagger.v3.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:63)
	at io.swagger.v3.parser.OpenAPIResolver.resolve(OpenAPIResolver.java:49)

Using only file part (without fragment) produces expected result.
@gracekarina
Copy link
Contributor

Hi, @rmzzz thanks for this PR, sorry for the delay response, can you please attach the spec, that causes the exception so I can test it and merge? Thanks

@gracekarina gracekarina merged commit fbbfd8c into swagger-api:master Apr 30, 2021
@gracekarina
Copy link
Contributor

@rmzzz thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants