-
Couldn't load subscription status.
- Fork 765
feat: resolve external value #2013
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
Conversation
28eec21 to
2613f63
Compare
@char0n Would it be ok to remove to resolved externalValue and place the resolved value in the .value path instead.
If it should be placed in .externalValue how could this be accomplished. Plugin seems to be called while externalValue key exists, so my questions is probably how to mark a fullPath to exernalValue as resolved to not call the plugin with it again and again.
Originally posted by @mathis-m in #1978 (comment)
4374ca1 to
235f3f3
Compare
235f3f3 to
c158c2c
Compare
89b08cb to
69efc1c
Compare
@char0n Would it be ok to remove to resolved externalValue and place the resolved value in the
.valuepath instead.
Yes, externalValue should stay unmodified, and the resolved thing should be put in value field.
If it should be placed in
.externalValuehow could this be accomplished. Plugin seems to be called whileexternalValuekey exists, so my questions is probably how to mark a fullPath to exernalValue as resolved to not call the plugin with it again and again.
We should check if value field is set and stop the processing.
I have a follow up question, do you have time to continue with this PR Draft?
@char0n can try to finish this in the next week!
69efc1c to
346779d
Compare
@char0n currently I am reading the OAS Spec 3.1.0, it is stating that externalValue should follow the Relative References Section. This section states that it should also resolve fragments.
- Is this something I need to take care of?
- What are the cases that need to be handled?:
- full url
- url relative to base docuement
- fragment
- Are there any util functions that can be used for this?
@char0n have added the absolitfy for the url. No support for fragments until now. If needed please tell me.
Needed to increase entrypoint size. Maybe we could refactor the absolitfy from refs plugin to helpers to save some bytes.
@char0n currently I am reading the OAS Spec 3.1.0, it is stating that [externalValue should follow the Relative References Section]
Yes it does, but swagger-client only supports OAS 3.0.3 at this point as a maximum OAS version. The resolution of externalValue happens as specified in this comment and was verified with the spec author.
This section states that it [should also resolve fragments]
As mentioned above, this is part of OAS 3.1.0 spec. But even if we were to implement OAS 3.1.0 behavior, the fragment in externalValue URL IMHO doesn't really make sense as the fragment is ignored by any requesting mechanism and the expected resolved value is of arbitrary type.
- Is this something I need to take care of?
If this question is specific to your questions of OAS 3.1, then I'd say no, we don't care about those thing as they just don't apply here. We only care about #1978 (comment)
- What are the cases that need to be handled?:
- full url
- url relative to base docuement
- fragment
We need to handle full url and relative url. We don't care about fragments. We resolve relative URL agains the Server.url not agains the baseURI.
- Are there any util functions that can be used for this?
Not aware of any special ones
@char0n besides the review comment I made are there any changes need. I think the PR currently fulfills the stated behavior from your last comment.
@mathis-m as you mentioned the base64 requirement is missing.
I'll start testing this PR against the requirements of OAS 3.0.x specification.
@char0n I updated this PR that fixes merge conflicts, test and lint errors on a new branch mathis-m-ft/external_value. (mostly b/c I couldn't push to this PR directly). It looks like all three primary case are now covered, including handling of absolute vs relative url. The new tests provided now all pass.
However, can you clarify why this comment needs to be included in this PR as well, given that it appears to not otherwise be present in the refs.js case either? Seems to me it should be a different feature/issue?
If the file extension if different then
.json, '.yamlor.ymlwe shouldbase64 encodethe string before we transclude the resolved value tovalue` field.
Otherwise, are there other tests that you would have liked to see included in this PR?
Thanks!
Probably it is not good to base64 encode all other stuff. Imagine a external value that is a .txt, .xml or any other readable format.
base64 does not make sense for all types of external values, maybe it only does for e.g. images.
As reference take the spec defined in #1978
The min value is fetched from a txt file. Which is totally fine to do, then I expect that the number value in that file is put into the min value of the spec.
Uh oh!
There was an error while loading. Please reload this page.
Description
resolve external value to value
fixes or baseline for swagger-api/swagger-ui#5433
TODO
DONE
Motivation and Context
Fixes #1978
How Has This Been Tested?
currently not
Types of changes
package.json)Checklist: