Skip to content

Remove namespace prefix from the XML Object #4126

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

Closed
wants to merge 1 commit into from

Conversation

saper
Copy link

@saper saper commented Oct 7, 2024

Do not allow to specify the namespace prefix for the XML object. Only namespace URIs should be used to identify the namespaces used.

The prefix functions only as a placeholder and has a meaning exclusively in the context of the XML document

Namespaces in XML 1.0 (Third Edition)
https://www.w3.org/TR/REC-xml-names/#ns-qualnames

Do not allow to specify the namespace prefix for the XML object.
Only namespace URIs should be used to identify the namespaces used.

The prefix functions only as a placeholder and has a meaning exclusively
in the context of the XML document

Namespaces in XML 1.0 (Third Edition)
https://www.w3.org/TR/REC-xml-names/#ns-qualnames
@saper
Copy link
Author

saper commented Oct 8, 2024

I have submitted this for a 3.2.0 branch. But maybe, if there is a consensus, this should be backported to the older branches.

@handrews handrews added the Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk label Oct 9, 2024
@handrews
Copy link
Member

handrews commented Oct 9, 2024

@saper Thanks for your efforts here. I'm afraid we cannot make backwards-incompatible changes such as removing a field in a minor release (3.1 was an exception made due to the pain caused by conflicting with the JSON Schema standard, and not an exception we want to repeat). This is something that can be taken into account in 4.0 a.k.a. Moonwalk. We have not yet gotten into how we plan to handle XML in that release.

@saper
Copy link
Author

saper commented Oct 9, 2024

Thank you, that is what I initially thought we should not do, but I saw a couple of less obscure things removed and decided to file this. What about just adding the comment not to use this thing at all? If the attribute is present in the OAS, the tools SHOULD simply ignore it.

(I am still in search of the tooling that supports namespacing of the XML-Object but I could not find any, yet - pointers welcome).

@saper
Copy link
Author

saper commented Oct 9, 2024

I do have a pretty obscure use case for this though. I have a commercial application (a proxy) that can handle both OpenAPI and SOAP requests.

As it turns out, the some low level HTTP errors (401, 404, 500, and others) do return a text/xml SOAP response, even if otherwise the API is defined using OAS and uses JSON.

So I have to tell the clients to expect, among application/json higher-level errors from the backend application, a text/xmlresponse with a SOAP Fault message it, that might come from the proxy.

It seems perfectly possible to model SOAP Fault using the XML Object feature; but the namespace prefix must be ignored, since in theory random prefixes can be returned (or automatically generated ones like ns1, ns2, ...).

@handrews handrews added xml and removed Moved to Moonwalk Issues that can be closed or migrated as being addressed in Moonwalk labels Oct 9, 2024
@handrews
Copy link
Member

@saper that use case is quite reasonable!

Having looked into this more deeply, I think there might not really be a problem here. The lack of tooling support for the XML Object (which you noted) makes it hard to say for certain in practical terms. I know it gets used, but it might be used more by custom tooling than major vendors. I'm really not sure.

Anyway....

The way the OAS documents the XML Object seems to mostly be about how to use it to serialize JSON values to XML. In that direction, it's perfectly valid to specify namespaces and prefixes.

The OAS does not explicitly state any parsing requirements or validation behavior. The most obvious reading is to require the prefixes to match. But the XML Object is described as "metadata" rather than validation. Arguably, the W3C's SHOULD directives here could be taken to mean "the prefix field is only used on serialization, and not on parsing, as the specific prefix used does not impact parsing."

@handrews handrews requested a review from a team October 10, 2024 03:19
ralfhandl
ralfhandl previously approved these changes Oct 10, 2024
@ralfhandl ralfhandl requested a review from a team October 10, 2024 08:03
@ralfhandl ralfhandl added this to the v3.2.0 milestone Oct 10, 2024
Copy link
Member

@handrews handrews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To re-cap the conversation (but with an official "Request changes" status):

  • We cannot remove prefix in a minor release
  • The prefix field is actually necessary for correct serialization of JSON values into XML, and in that sense does not violate the W3C's "SHOULD" requirement any more than any other XML authoring tool that allows setting prefixes for namespaces
  • However, the "SHOULD" does mean that, when parsing and validating, as long as the namespace field matches the namespace in use, a mismatch in prefix ought to be ignored as the OAS is, in a parsing context, an "application" (I think- are there XML parsing tools that enforce a specific prefix, and are they considered compliant wiht the W3C?)

@ralfhandl ralfhandl dismissed their stale review October 10, 2024 16:13

No breaking changes in minor versions

@lornajane
Copy link
Contributor

Discussed this topic in the TSC meeting and generally agreed that we do not support removing the prefix field. However a separate PR can be created to clarify that the prefix can be ignored when parsing.

@lornajane lornajane closed this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants