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.42k stars 240 forks source link

Provide IOpenApiSchema interface #542

Open petriashev opened 3 years ago

petriashev commented 3 years ago

I am a supporter of MicroElements.Swashbuckle.FluentValidation project and I want to support NJsonSchema (NSwag).

Issue: https://github.com/micro-elements/MicroElements.Swashbuckle.FluentValidation/issues/63 One of the possible solutions is to adapt NJsonSchema to OpenApiSchema but it is a concrete type.

Can we extract IOpenApiSchema interface?

darrelmiller commented 3 years ago

We will probably have to make some changes to the OpenApiSchema model as we implement OpenAPI 3.1 support and support for JSON Schema 2020-12 draft. We can consider an interface then.

Wouldn't it just be easier to create a factory that creates an OpenAPISchema from an NJsonSchema parameter?

petriashev commented 3 years ago

Wouldn't it just be easier to create a factory that creates an OpenAPISchema from an NJsonSchema parameter?

Yes it is another option. This case I need convert NJsonSchema -> OpenAPISchema and back. At this moment I think more easy is to create some schema adapter with functionality I need. But I don't want to create Yet Another Interface That Common to other existing :)

Third option is to support two branches for OpenApi and NJsonSchema separately.