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

Use remote references to other local files #645

Open
Ppetrus opened this issue Mar 12, 2025 · 1 comment
Open

Use remote references to other local files #645

Ppetrus opened this issue Mar 12, 2025 · 1 comment

Comments

@Ppetrus
Copy link

Ppetrus commented Mar 12, 2025

Hello,

I have multiple yml files, but they use some of the same components. I wanted to extract those components and put them into shared files that would be used as references in the main files (following the swagger documentation : https://swagger.io/docs/specification/v3_0/using-ref/ )

but when I do, I get the following error :

"Can't resolve test.yml#/components/schemas/Account, only internal refs are supported."
Error loading OpenAPI Glue: 44 |       async parse(specification, options = {}) {
45 |           const supportedVersions = new Set(["2.0", "3.0", "3.1"]);
46 |
47 |           const res = await this.preProcessSpec(specification);
48 |           if (!(res.valid && supportedVersions.has(res.version))) {
49 |                   throw new Error(
              ^

Is there a way to use those references anyway ?

Thank you for your answer !

Best regards,
Pierre

Edit : Using validator.addSpecRef, I managed to get something working.

But it doesn't work at all with the swagger documentation because it looks for the refs directly, and I couldn't find a workaround for this...

@seriousme
Copy link
Owner

Hi Pierre,

thanks for asking!
Did you see the documentation on subschema's ?
https://github.com/seriousme/fastify-openapi-glue/blob/master/docs/subSchemas.md

An example of schema's to be bundled can be found at: https://github.com/seriousme/openapi-schema-validator/tree/master/test/bundle

Hope this helps.

Kind regards,
Hans

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants