microsoft / OpenAPI.NET

The OpenAPI.NET SDK contains a useful object model for OpenAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.
MIT License
1.39k stars 230 forks source link

How load OpenApi split to many files #1194

Open petrkasnal opened 1 year ago

petrkasnal commented 1 year ago

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

darrelmiller commented 1 year ago

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.

petrkasnal commented 1 year ago

Thank you for response. Do you think about add this functionality sometime?

darrelmiller commented 1 year ago

Yes. We are aiming to fix external references in our v2 version.

petrkasnal commented 1 year ago

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