How load OpenApi split to many files
Hello,
I have my OpenAPI specification in separate files. I use references to load data. When I try to do so, I get an exception.
{"Unable to cast object of type 'SharpYaml.Serialization.YamlScalarNode' to type 'SharpYaml.Serialization.YamlMappingNode'."}
My openapi looks `openapi: 3.0.3 info: title: 'Test' version: '1.0.0'
components: schemas: $ref: './AllSchemas.yml'
paths: /api/orders: $ref: './orders.yml'`
Can you please help me? Thank you
OpenAPI.Net readers currently only have limited support for external files. External files need to be valid OpenAPI documents themselves. Also, $ref in pathItems is a special case that is not supported.
The best option is to preprocess your OpenAPI file using a reference resolver before handing it over to OpenAPI.Net.
Thank you for response. Do you think about add this functionality sometime?
Yes. We are aiming to fix external references in our v2 version.
Yes. We are aiming to fix external references in our v2 version.
Thank you for reply. And when do you think will be v3 ready? Thank you
The particular examples of referencing that you are using can be addressed using a pre-processing reference resolver. The first example of pulling in a set of schemas in not valid as per the OpenAPI specification, and the second use if $ref in the path is not likely to be supported by this library. I expect that feature to go away in the next major version of OpenAPI.
It would be much better to use a preprocessing tool.