Page 1 of 1

JSON Schema Wrapping enums in allOF keyword.

Posted: Mon Sep 12, 2022 8:04 pm
by michaelgrudgings
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"
}
}
},

Re: JSON Schema Wrapping enums in allOF keyword.

Posted: Thu Sep 15, 2022 12:19 pm
by florin_nica
Hi Michael,

Thank you very much for the feedback.

Indeed, wrapping enums into "allOf" seems kind of redundant, so I adjusted the XSD to JSON Schema converter tool a little. Your example
would now look like this:

Code: Select all

"IncomeModeCode": {
	"type": "string",
	"enum": [
		"Hourly",
		"Annual",
        ...
        ]
}
This improvement will be available starting with version 24.1.1 of the XSD to JSON Schema add-on. It's release is scheduled for next month,
and you will get a notification.

Regards,
Florin

Re: JSON Schema Wrapping enums in allOF keyword.

Posted: Thu Oct 13, 2022 4:36 pm
by florin_nica
Hi Michael,

Just wanted to let you know that version 25 of Oxygen XML Editor has just been released, as well as version 24.1.1 of XSD to JSON Schema add-on. This includes the improvement that you requested.

Best regards,
Florin