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

Relative references in $ref are not supported #74

Open
tnmtechnologies opened this issue Jun 7, 2024 · 1 comment
Open

Relative references in $ref are not supported #74

tnmtechnologies opened this issue Jun 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@tnmtechnologies
Copy link

tnmtechnologies commented Jun 7, 2024

Version

4.5.8

Context

Relative references in $ref are not supported (see OpenAPI spec https://spec.openapis.org/oas/latest.html#relative-references-in-uris) while it worked well with previous OpenAPI library.

The following exception is thrown:

java.lang.UnsupportedOperationException: Can't resolve 'the relative reference to a OpenAPI file ', only internal refs are supported.
at io.vertx.json.schema.impl.JsonRef.resolveUri(JsonRef.java:344)
at io.vertx.json.schema.impl.JsonRef.resolve(JsonRef.java:211)
at io.vertx.json.schema.impl.SchemaRepositoryImpl.resolve(SchemaRepositoryImpl.java:243)
at io.vertx.openapi.contract.OpenAPIVersion.lambda$resolve$3(OpenAPIVersion.java:86)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:191)
at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279)
at io.vertx.core.impl.ContextImpl.lambda$internalExecuteBlocking$2(ContextImpl.java:210)
at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:833)

We work with more than one hundred of OpenAPI files. Most of them use relative references to components in other OpenAPI files.
They are provided by a third party.

It would be nice to support relative references from a configuration option.
It would avoid to update OpenAPI files in order to replace relative references by fake absolute ones and to add them by hand as additionalContractFiles in OpenAPIContract.from method.

Do you have a reproducer?

No

  • Link to github project/gist

Steps to reproduce

Extra

  • Anything that can be relevant such as OS version, JVM version
@pk-work
Copy link
Contributor

pk-work commented Sep 25, 2024

Due to security reasons we decided that files must be provided upfront. Maybe we could add a method which parses the OpenAPI files, follow the relative links and create the required additionalContractFiles Map. But I don't think that is something I will develop in the future.

If you want to provide such a feature, I would support it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants