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

does the XML "namespace" field allow URI fragments? #3263

Open
handrews opened this issue May 1, 2023 · 8 comments
Open

does the XML "namespace" field allow URI fragments? #3263

handrews opened this issue May 1, 2023 · 8 comments
Assignees
Labels
bug media and encoding Issues regarding media type support and how to encode data (outside of query/path params) xml
Milestone

Comments

@handrews
Copy link
Member

handrews commented May 1, 2023

OAS states that the namespace field of the XML Object "MUST be in the form of an absolute URI." (3.0; 3.1).

Technically, an absolute URI cannot have a fragment. However, XML Namespaces are defined as URI-references, although relative references are deprecated. The intention of URI-references-but-not-relative-URI-references is to allow fragments in namespace URIs.

If OAS intended to be aligned with this usage (no relative references, but yes fragments), then the wording needs to be changed.

@MikeRalphson
Copy link
Member

Why would you use an (xpath?) fragment id to identify a portion of an XML resource as a namespace?

@handrews
Copy link
Member Author

handrews commented May 1, 2023

@MikeRalphson I haven't used XML for anything in decades :-)

However, RDF namespaces are related to XML namespaces and typically include an empty fragment (because namespace URIs are prefixes, not base URIs, and RDF vocabulary terms are defined as plain name fragments within the resource). The RDF/XML specification shows that http://www.w3.org/1999/02/22-rdf-syntax-ns# is the standard XML namespace for RDF.

Here's an example from the spec:

<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
            xmlns:dc="http://purl.org/dc/elements/1.1/"
            xmlns:ex="http://example.org/stuff/1.0/">

  <rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar"
             dc:title="RDF1.1 XML Syntax">
    <ex:editor>
      <rdf:Description ex:fullName="Dave Beckett">
        <ex:homePage rdf:resource="http://purl.org/net/dajobe/" />
      </rdf:Description>
    </ex:editor>
  </rdf:Description>

</rdf:RDF>

@MikeRalphson
Copy link
Member

An optional empty fragment id I can get behind.

@handrews
Copy link
Member Author

handrews commented May 5, 2023

@MikeRalphson as a use case for a non-empty fragment, consider the compliance project. I'll be defining an ontology for OAS 3.0 and 3.1 concepts. I could, of course, put these in separate documents and use an empty-fragment namespace for each.

However, I want to ensure that certain concepts are defined as identical in 3.0 and 3.1 while still giving them separate URIs to avoid asking users to use a mix of 3.0 and 3.1 terms when working with 3.1. I will also want to define that some concepts, while not identical, are analogous.

This should be easier to do if both ontologies are defined in the same resource. If one is using both ontologies at once (because you are describing multiple APIs, some using 3.0 and 3.1) then declaring a namespace of https://openapis.org/ontology# and using term names like oas3.0.SchemaObject and oas3.1.SchemaObject would make sense. But if you are working with just one version, declaring a namespace prefix of https://openapis.org/ontology#oas3.0. and using term names like SchemaObject would be more suitable. (I think . ends up being legal here, but if not, then some other character - it's legal in URI fragments, but prefixed names use a more limited character set).

@MikeRalphson
Copy link
Member

But the xml object is only for hinting at the conversion between the JSON Schema and XML object mappings within an OpenAPI document's schema objects. And the namespace property definition is only valid within this context.

It isn't clear to me that the compliance parser operates within, or on, this context.

@handrews
Copy link
Member Author

handrews commented May 6, 2023

@MikeRalphson the question is whether the namespace is supposed to be an actual XML namespace or not. I was just showing that there is a use case for XML namespaces with non-empty fragments, in order to make a general point about the syntax.

If namespace is not really an XML namespace, a.) it's badly named and b.) it can do whatever it wants.

@Saud96525

This comment was marked as duplicate.

@MikeRalphson
Copy link
Member

@handrews then in that case a PR would be great if you have time!

@handrews handrews self-assigned this May 11, 2023
@handrews handrews modified the milestones: v3.1.1, v3.0.4 Jan 27, 2024
@handrews handrews added xml media and encoding Issues regarding media type support and how to encode data (outside of query/path params) and removed 3.0.4 labels Jan 27, 2024
@handrews handrews modified the milestones: v3.0.4, v3.2.0 May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug media and encoding Issues regarding media type support and how to encode data (outside of query/path params) xml
Projects
None yet
Development

No branches or pull requests

3 participants