Redocly / redocly-vs-code

Redocly VS Code extension
35 stars 6 forks source link

Why is there no root directory support in $ref in paths? #43

Closed junsred closed 1 year ago

junsred commented 1 year ago

https://github.com/Redocly/openapi-starter/tree/main/openapi/paths#drawbacks-2

image

it is possible to use this way $ref: '#/definitions/components/schemas/Error.yaml' but extension shows error even though in preview it works

tatomyr commented 1 year ago

Hi @junsred,

If a reference starts with # it means you're pointing to some resource inside the current file (please check the JSON pointer reference). In your example you're pointing to an external file (Error.yaml). So you probably have to use something like $ref: './definitions/components/schemas/Error.yaml'. The actual path will depend on how your folders are structured. I believe there's no legitimate way to define a root folder inside the OpenAPI definition.

BTW, it might be working in the preview because we cache the latest successful bundle.

tatomyr commented 1 year ago

Closing this as not active.