OpenAPI.NET.OData
OpenAPI.NET.OData copied to clipboard
Consider replacing anyOf with allOf for enum types at least
In converted schema there are many places like this:
schema:
anyOf:
- $ref: '#/components/schemas/Pbx.NumberFilterType'
This I believe is done to express extra props. Specifically to make this type nullable for example.
While this works with OpenAPI Generator 5.4.0
it doesn't work with many other versions including 6.X
branches.
6.X
branches generate complete gibberish if referenced type is enum and it is referenced via anyOf
I'm not a great specialist in OpenAPI specs but I want to raise this discussion because replacing anyOf
to allOf
works perfectly.
So what do you think?
Steps to reproduce
Make a schema with enum.
Expected result
schema:
allOf:
- $ref: '#/components/schemas/Pbx.NumberFilterType'
Actual result
schema:
anyOf:
- $ref: '#/components/schemas/Pbx.NumberFilterType'
@sherlock1982 thanks for the suggestion.
Can you expand on why you didn't request this instead?
schema:
$ref: '#/components/schemas/Pbx.NumberFilterType'
Currently, we use anyOf
when referencing an enum reference if it is nullable in OpenAPI 3.0 spec. and above. An example would be:
requestedModalities:
type: array
items:
anyOf:
- $ref: '#/components/schemas/microsoft.graph.modality'
- type: object
nullable: true
else (if it is not nullable)
role:
$ref: '#/components/schemas/microsoft.graph.screenSharingRole'
Using allOf
would mean that all of the given schemas must be valid for the given property, which would not be factual.
One of would probably make the most sense here
@sherlock1982 would oneOf
work for your case?