OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

Immutable schema model

Open jcracknell opened this issue 5 years ago • 1 comments

Having spent the last few days hacking on Swashbuckle, I was wondering whether or not anybody had floated the idea of refactoring or deprecating the current schema models in favor of immutable ones?

The mutability and lack of deep copying functionality makes things like caching inline or primitive type schemas a non-starter. It could also allow for more robust validation at construction time.

jcracknell avatar Oct 30 '20 02:10 jcracknell

Tell me more.... we are going to have to do some non-trivial changes in OpenAPI 3.1 because the way we handle JSON Schema is changing a lot for 3.1.

Can you show what kind of inline caching you would like to do?

darrelmiller avatar Dec 13 '20 20:12 darrelmiller

@MaggieKimani1 Could you confirm that the schemas created by JSONSchema.NET are immutable?

darrelmiller avatar Jan 30 '24 14:01 darrelmiller

@jcracknell the JSON schema object exposed by the JsonSchema.Net library is completely immutable; you can't directly add or update its keywords/properties. You can however use the JsonSchemaBuilder object to build inline schemas. You can find more information in their docs here https://docs.json-everything.net/schema/basics/

MaggieKimani1 avatar Feb 12 '24 12:02 MaggieKimani1