I want to split my OpenAPI file components to separate files and reuse them in my documentation. My problem is that although my IDE finds the reference of my component in another file the Swagger parser throws an error. My files are in the same folder and based on the documentation we can access external component. I am using OpenAPI 3.0.0.
The error I am getting is this:
Unable to resolve resource /C:/wamp/www/justbe/documentation/API_Specs/Components/Application.yaml/General.yaml/
Seems like the parser tries to find the other yaml file under the one I am calling the reference:
Note: although the error the Swagger plugin in my PhpStorm displays the structure in the editor however, I cannot merge all files to one because of the issue. I tried also VS Code, same issue.





Update your reference uri to the following:
$ref: './General.yaml#/components/schemas/Note'Note the
#must be in the same path segment as the file path because it acts as the "anchor" to that file. The reference parser then uses the base path uri to traverse the document tree.