Open toomuchdesign opened 3 weeks ago
Good afternoon! I'm writing to ask feedback about a possible conversion case that could be not handled by this library: combiners + nullable.
combiners
nullable
const schema = { nullable: true, allOf: [ { type: "object", required: ["foo"], properties: { foo: { type: "integer", }, }, }, ], };
Currently the output strips nullable: true out, but it doesn't seem right. The most plausible solution I can think of is the following, but I'd like to hear your thoughts about it.
nullable: true
const schema = { oneOf: [ { type: "null", }, { allOf: [ { type: "object", required: ["foo"], properties: { foo: { type: "integer", }, }, }, ], }, ], };
The approach above, beside being a valid OAS definition, seems to be a legit OAS 3.0.0 workaround to define nullable $ref properties.
$ref
// This is OAS invalid since you can't extend `$ref` definitions const schema = { type: "object" properties: { foo: { $ref: '#/components/schemas/MyReferencedComponent' nullable: true } } } // This seems to be a valid workaround const schema = { type: "object", properties: { foo: { allOf: [{ $ref: "#/components/schemas/MyReferencedComponent" }], nullable: true, }, }, };
Happy to open a PR if the described use case seems legit. Cheers!
Good afternoon! I'm writing to ask feedback about a possible conversion case that could be not handled by this library:
combiners
+nullable
.Currently the output strips
nullable: true
out, but it doesn't seem right. The most plausible solution I can think of is the following, but I'd like to hear your thoughts about it.The approach above, beside being a valid OAS definition, seems to be a legit OAS 3.0.0 workaround to define nullable
$ref
properties.Happy to open a PR if the described use case seems legit. Cheers!