-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
OAS3 Tag/template to define external-components URL #1979
Comments
[EDIT: I misunderstood some stuff, see my next comment] @gerardbosch OpenAPI (or really JSON Schema as that is where this feature comes from) would need to come up with a completely different feature for this, because breaking RFC 3986 compatibility would be a huge problem. In JSON Schema proper, this is handled by allowing |
@handrews Do you think this issue could be treated as a "Feature Request" in some way? I think it would be very beneficial to have clean What I pretend is a way of shortening and reusing the URL part to the |
@gerardbosch Actually I'm now realizing that I misread your primary use case of a base URI in the sense of referencing another file/resource. Not referencing a different location in the same file with some sort of relative fragment.
There might be something here around an OpenAPI-specific variable substitution thing, which would ore closely match what you wrote- I'll leave that to someone else to respond to, I'm mostly just here for JSON Schema stuff 😃 |
Coming back to this- the base URI is determined by the Server Object's URLs. You would need to at least have the file name of the external file, plus the fragment, but that is a way that you can dramatically shrink the URLs in your @gerardbosch does that answer your question? If you still have it- sorry for the delay. |
@gerardbosch Many years later... we now have a proposal for OAS 3.2 that allows OAS documents to self-identify, which also sets the base URI. So you could do something like this:
@gerardbosch if you are still interested in this, would this be sufficient for your needs? |
Hi @handrews, it has been a long time and right now I'm not sure as I'm not working in the same project currently. But from your snippet above it's not very clear to me the location where the error is referenced as there's no So in this case, where is And thanks for following up after so much time :) |
@gerardbosch apologies again for the delayed reply, although shorter this time! My late Aug-Oct got rather hectic, and we weren't focusing on 3.2 yet which is where this would be addressed. We are now shifting to that release since 3.0.4 and 3.1.1 are finally out! In this example,
When you see
So the combination of the new
is equivalent to:
Does that help? |
Hi @handrews, thanks for taking time to check this after so long 🙏 Yes, this looks exactly what I was asking back in the day. I think it's a nice thing, although I had no time to investigate about the Anyway, thanks for the update! 🙂 |
@gerardbosch that is correct. I'm hoping we will get 3.2 out in the first half of 2025. Ideally by April, but hopefully at least by June. |
Hi there,
I find myself using the power of
$ref
to reference external components in my API definitions, which is great as allows component reuse. But I find myself with this kind of code in my API definitions, where the links to external components are very long and hard to read:I would really like to know if is there any way to define the base-path of that URLs in some kind of variable or YAML tag, so I could lead to
$ref
s of this form:$ref: '{apicomponents-errors}#/components/schemas/Something'
where I could define
apicomponents-errors: http://...
just once.This is not only for better readability, but to allow update the versions all-in-once, as you can see from this example that the referenced components are versioned by its URL.
I have no idea if such kind of feature exists or can be implemented in OAS 3.
P.S. This does not only applies to schemas, but any kind of ref.
The text was updated successfully, but these errors were encountered: