OpenAPI-Specification
OpenAPI-Specification copied to clipboard
XML Object - unfortunate default rule for name changes
In the OpenAPI spec, section "XML Object", https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#xmlObject
the examples show a default rule which I think is a bad decision.
Consider the case (see also spec example at the end of this text):
- schema has type "array"
- the schema has an xmlObject with wrapped equal true and name equal "aliens"
- the items schema has no xmlObject
So we an array type with a wrapped XML representation, a wrapper name explicitly set, and an item name not explicitly set.
Proposal In this case the item name should correspond to the property name, it should not be changed to the wrapper name.
Rationale Almost certainly one wants wrapper name and item name to be different; it should suffice to manipulate one of the two to achieve this goal. To let the name change of the wrapper be "inherited" by the items makes no sense at all.
Status quo, however ... See below for the spec example, demonstrating undesirable behavior.
Schema:
{
"animals": {
"type": "array",
"items": {
"type": "string"
},
"xml": {
"name": "aliens",
"wrapped": true
}
}
}
XML
<aliens>
<aliens>value</aliens>
<aliens>value</aliens>
</aliens>`
@hrennau , I agree, it's not a great design decision. Where wrapped
is true
, the wrapper element name should be independent of the inner element name. That's much more intuitive, IMO.
I don't think we can do this in a v3.x version, because it would be a breaking change. We can consider it for v4, but it may also depend on whether the TSC wants to continue evolving XML Object, or adopt a more comprehensive approach like Alternative Schemas.
I agree that this can't be done in 3.x. Feel free to start a discussion about XML in the OAI/sig-moonwalk repository, and see:
- OAI/sig-moonwalk#122
for discussions in the context of alternative schemas.