mattpolzin / OpenAPIKit

Codable Swift OpenAPI implementation.
MIT License
280 stars 35 forks source link

Determining if a reference is optional #228

Closed mndzup closed 3 years ago

mndzup commented 3 years ago

Hello OpenAPIKit team,

I am looking for a bit of clarification as to how to find out if a reference is optional or required, since it seems that references and other schema are required by default.

Thank you!

mattpolzin commented 3 years ago

This is something for which support was lacking prior to OpenAPIKit 3 (which is currently in alpha).

I would recommend checking out the first alpha release of OpenAPIKit 3 if you have the time: https://github.com/mattpolzin/OpenAPIKit/releases/tag/3.0.0-alpha.1.

The first alpha of OpenAPIKit 3 is actually a pretty stable representation of support for version 3.0 of the OpenAPI specification (it is support for version 3.1 of the specification that is heavily in flux still), but you will need to change your imports from import OpenAPIKit to import OpenAPIKit30 if you check the alpha release out and want to use it within code with very few (if any) changes needed.

mattpolzin commented 3 years ago

Unfortunately the change needed to support optional references was a breaking change, so the addition cannot be ported back to version 2.x of OpenAPIKit.

mndzup commented 3 years ago

Thank you this was very helpful, I ended up forking and making some additions to the repo as a work around but will look into the alpha if I have time.