Fix openapi3.referencedDocumentPath#248
Merged
Merged
Conversation
Collaborator
|
Hi there, thanks for the patch! |
`openapi3.referencedDocument` tried to `path.Join` two URLs, and then generate a new `url.URL` by parsing the obtained path. The URL obtained at the end would be invalid when the base path is HTTP URL. Given base path as 'http://example.com/schemas' and ref as '/schema1', the obtained end URL would be 'http:/example.com/schemas'. This happens because `path.Join` cleans the path it generates and replaces repeated '//' with a single '/'. This is fixed by doing a `path.Join` on the base URL.Path and the ref, and setting this result as the URL.Path of the new URL.
0317a9f to
33ca746
Compare
Contributor
Author
|
I've added the tests. I'm not a 100% sure on the about the expected result of |
fenollp
approved these changes
Sep 3, 2020
fenollp
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the tests :) I have a few nitpicks but after that it'll be merged.
Contributor
Author
|
Not sure why tests are failing. They're unrelated to my change in the |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
openapi3.referencedDocumenttried topath.Jointwo URLs, and thengenerate a new
url.URLby parsing the obtained path. The URLobtained at the end would be invalid, when the base path is HTTP URL.
Given base path as 'http://example.com/schemas' and ref as '/schema1',
the obtained end URL would be 'http:/example.com/schemas'. This happens
because
path.Joincleans the path it generates and replaces repeated'//' with a single '/'.
This is fixed by doing a
path.Joinon the base URL.Path and the ref,and setting this result as the URL.Path of the new URL.