Forum Discussion
ponelat
3 years agoStaff
Hey Southclaws
Interesting question!
tl;dr it's not technically valid. And it's a quirk of how OpenAPI tooling often misuses the `allOf` keyword to do inheritance.
For reference: https://json-schema.org/understanding-json-schema/reference/combining.html . As the name implies (allOf) the instance (ie: JSON data) needs to be valid against all the schemas, independently. So having one with type: string and another with type: number, makes it impossible to match both.
I don't think I'd recommend having the same field change type between read and write, one way of being valid might be to use those flags (readOnly and writeOnly). But given that they share the field name, tooling may not give you what you want.
price:
oneOf:
- type: string
readOnly: true
- type: number
writeOnly: true
Related Content
- 6 years ago
- 6 years ago
Recent Discussions
- 10 days ago
- 16 days ago