New to OAS. Can someone recommend how you would create an OAS Specification with reusable files (or snippets) that can be included in multiple specifications? Every example I can see references to components in the same specification, but I want it to be a separate file so it can be referenced by multiple specifications.
OAS with Includes
78 Views Asked by Julie At
2
There are 2 best solutions below
0
On
use https://redocly.com/docs/cli | npm i @redocly/cli
it's powerful toolbox with much more than just extended $refs
they support relative paths in filesystem and even remote URL in references ($refs)
when your definition with non-standard references is done just bundle it out
PS check out all other very useful commands
The reference can be any relative URI. Most examples you find show references to the same file using the fragment of the URI, that is everything after the
#(hash), but you can also put stuff before it, including a path to a different file.E.g.:
This way you can split your spec into multiple files (and folders) and reuse those in multiple API specs as well.
Note: this assumes version 3 of OAS, not sure if it works with previous versions.