swift-openapi-generator
swift-openapi-generator copied to clipboard
Support `type: 'null'` as `OpenAPIValueContainer`
Motivation
OpenAPIKit's handling of type: 'null' was problematic with older Yams versions. See https://github.com/mattpolzin/OpenAPIKit/pull/366/files for a test demonstrating that & dependency version bump.
Similarly, swift-openapi-generator explicitly does not "support" type: 'null'. As part of searching for something to address https://github.com/apple/swift-openapi-generator/issues/513 I have added such support for explicit nulls. This gives one more sort of input schema where swift-openapi-generator produces some useful output instead of skipping a schema.
Modifications
- Bumped minimum supported Yams version.
- Return
truefromisSchemaSupportedfortype: 'null'schemas. - Defined
.nullto have a builtint ype ofOpenAPIValueContainer
Result
Nothing should change for existing users because type: null schemas were previously unsupported. Going forward, usages of these schemas is supported.
Test Plan
New test included.
Based on the discussion in the other thread, I think we should not merge this PR, and instead we should simply filter out null from anyOf/allOf schemas, as OpenAPIKit will already represent the nullability on the parent schema.
We had a report that this is blocking generation for the Figma API: https://github.com/figma/rest-api-spec/blob/main/openapi/openapi.yaml, which I can confirm doesn't compile as-is.
It would be great to get this merged as it unblocks using the Figma API as Simon mentions. Anything I can do to help?
I think we can't merge it as-is, as it'd be an API break. Plus, see my earlier message, I think we should fix this slightly differently.