Open bogi158 opened 1 year ago
Hi @bogi158 , I suppose that the error is probably produced because the json-refs
module is trying to resolve refs from the root document, which in this case is not the OpenAPI itself, but a ref to the OpenAPI.
Have you tried to fix it using the plugin options refs.subDocPath
or refs.location
? It also supports defining any other json-refs
module options.
{
plugins: {
openapi: {
refs: {
subDocPath: "", // Read the docs for further info about this options
location: "", // Read the docs for further info about this options
// You can define any other json-refs option here
}
},
},
}
In any case, it deserves to be investigated further in order to find and document a possible solution. Thanks for reporting it!
sorry but I needed to change the mocks library because of the limitation I had, so at the moment I am not using mocks-server and I cannot test your solution. I might try in the future if I have time.
Describe the bug Generating mocks from OpenAPI definition is not working whe using $ref to point to some schema.
To Reproduce Download the Petstore example from Swagger Hub, configure mocks server on a Node project and run.
Expected behavior Mocks Server should be able to generate the routes.
Logs One of the many errors:
Operating system, Node.js an npm versions, or browser version (please complete the following information):
Additional context The mock server works if I put all the OpenAPI specification inside the
document
property ofdefinitions.js
, but doesn't if I want to have an external file reference indocument
with$ref
.