Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Object - unfortunate default rule for name changes #2096

Closed
hrennau opened this issue Jan 9, 2020 · 2 comments
Closed

XML Object - unfortunate default rule for name changes #2096

hrennau opened this issue Jan 9, 2020 · 2 comments
Labels
media and encoding Issues regarding media type support and how to encode data (outside of query/path params) Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk xml

Comments

@hrennau
Copy link

hrennau commented Jan 9, 2020

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>`
@tedepstein
Copy link
Contributor

@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.

@handrews handrews added the media and encoding Issues regarding media type support and how to encode data (outside of query/path params) label Jan 30, 2024
@handrews handrews added the Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk label May 24, 2024
@handrews
Copy link
Member

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:

for discussions in the context of alternative schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
media and encoding Issues regarding media type support and how to encode data (outside of query/path params) Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk xml
Projects
None yet
Development

No branches or pull requests

4 participants