JSON Schema Wrapping enums in allOF keyword.
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 7
- Joined: Mon Sep 12, 2022 7:58 pm
JSON Schema Wrapping enums in allOF keyword.
Post 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"
}
}
},
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"
}
}
},
Michael J Grudgings
Business Architect
Business Architect
-
- Posts: 37
- Joined: Wed Sep 09, 2020 3:17 pm
Re: JSON Schema Wrapping enums in allOF keyword.
Post 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:
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
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",
...
]
}
and you will get a notification.
Regards,
Florin
-
- Posts: 37
- Joined: Wed Sep 09, 2020 3:17 pm
Re: JSON Schema Wrapping enums in allOF keyword.
Post 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
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
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service