JSON Schema Wrapping enums in allOF keyword.
Posted: Mon Sep 12, 2022 8:04 pm
Why does Oxygen XML wrap all my enums in an allOf keyword? It is causing issues when we exchange data on a transactional level?
The thing that’s different in the json schema is that every enum is wrapped in an “allOf”, like this:
TransmissionType:
allOf:
- type: string
- enum:
- ActivesOnly
- ChangesOnly
- FullFile
So when we generate our classes using the standard openAPI library, it gives us some odd output.
From what I understand in openAPI 3.x “oneOf”, “anyOf”, “allOf” provide ways of expressing complex schemas in which you can specify that one, any, or all of a list of types (sub schemas) can be included at some specific point (https://swagger.io/docs/specification/d ... allof-not/). I can’t find any examples in which these are wrapped around a single enum, though. Enums are typically expressed as (https://swagger.io/docs/specification/d ... els/enums/):
Example:
"EmploymentIncome": {
"type": "object",
"properties": {
"IncomeTypeCode": {"$ref": "#/components/schemas/IncomeType"},
"IncomeAmount": {"type": "number"},
"IncomeModeCode": {
"allOf": [
{"type": "string"},
{
"enum": [
"Hourly",
"Annual",
"Monthly12PerYear",
"BiWeekly26PerYear",
"SemiMonthly24PerYear",
"SemiMonthly21PerYear",
"Weekly52PerYear",
"Weekly48PerYear",
"Quarterly",
"SemiAnnual",
"9thly",
"10thly"
]
}
]
},
"IncomeEffectiveDate": {
"type": "string",
"format": "date"
}
}
},
The thing that’s different in the json schema is that every enum is wrapped in an “allOf”, like this:
TransmissionType:
allOf:
- type: string
- enum:
- ActivesOnly
- ChangesOnly
- FullFile
So when we generate our classes using the standard openAPI library, it gives us some odd output.
From what I understand in openAPI 3.x “oneOf”, “anyOf”, “allOf” provide ways of expressing complex schemas in which you can specify that one, any, or all of a list of types (sub schemas) can be included at some specific point (https://swagger.io/docs/specification/d ... allof-not/). I can’t find any examples in which these are wrapped around a single enum, though. Enums are typically expressed as (https://swagger.io/docs/specification/d ... els/enums/):
Example:
"EmploymentIncome": {
"type": "object",
"properties": {
"IncomeTypeCode": {"$ref": "#/components/schemas/IncomeType"},
"IncomeAmount": {"type": "number"},
"IncomeModeCode": {
"allOf": [
{"type": "string"},
{
"enum": [
"Hourly",
"Annual",
"Monthly12PerYear",
"BiWeekly26PerYear",
"SemiMonthly24PerYear",
"SemiMonthly21PerYear",
"Weekly52PerYear",
"Weekly48PerYear",
"Quarterly",
"SemiAnnual",
"9thly",
"10thly"
]
}
]
},
"IncomeEffectiveDate": {
"type": "string",
"format": "date"
}
}
},