-
Notifications
You must be signed in to change notification settings - Fork 27
Import document with $ref not able to resolve #30
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue. |
Hi @michaelpro1 It is currently not possible to resolve references relative to the URL of the spec location. What I mean is that if you want to reference schema from the remote, you need to do this:
|
@derberg Would you consider taking a PR for this feature? I was thinking to simply do it on the client and qualify all relative links |
@michaelpro1 I'm not 100% sure what you mean by |
For example interface https://github.com/asyncapi/avro-schema-parser/blob/9180ea497b11bd52d4027060251edca3b82fbd1b/tests/asyncapi-avro-1.9.0.yaml#L11 has a reference to a separate schema I import this document via During the This allows the backend service to resolve all relative references to the imported document seamless from client side. It allows playground editor to work with imported documents without modification such as when they are loaded from source control, or wiki etc which is how typically interface docs are stored including Swagger, OpenAPI etc |
The problem with such an approach is that this would be supported in the playground only and would confuse users. The user would then take such a schema that works fine in the playground and would get errors in the generator for example. Best would be to have something like this in the parser. same as we have with the I dug a bit and looks like it is supported
But using it in the https://github.com/asyncapi/parser-js/ is not so easy 🤔 |
That was the first thing I tried actually, in version.js to supply I tried passing the sourceFileUrl and just sourceFolder without any luck, but couldn't figure out why it was failing. Tried it with latest libs without any luck. This was the only way to get it working, however it will not work with nested |
awesome that it is possible without any magic |
Can anyone please help why I am not able to run and execute the generator for the remote using I have seen some examples where they are providing the schema registry url under Url-->Binding Here is how my asyncapi.yaml looks like asyncapi: 2.4.0 |
Describe the bug
When trying to import a document with references, those references are not resolved against the original document. For example using the example:
https://raw.githubusercontent.com/asyncapi/avro-schema-parser/master/tests/asyncapi-avro-1.9.0.yaml
It is unable to resolve the
schemas/Person-1.9.0.avsc
and looks locally on the system.I have also tried putting all the async.yaml and related artifacts onto file system of the app however the app is not able to resolve them. Similarly placing them into
public/
folder resolves references at the wrong spot instead looking at/usr/src/app
instead of/usr/src/app/public
How to Reproduce
Steps to reproduce the issue. Attach all resources that can help us understand the issue:
Scenario 1 HTTP
https://raw.githubusercontent.com/asyncapi/avro-schema-parser/master/tests/asyncapi-avro-1.9.0.yaml
click import - error appearsScenario 2 local file
Expected behavior
file:///
handling should be clarified so that something like a volume mount can work, any chance of using local files?The text was updated successfully, but these errors were encountered: