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

Adjust uri to uri-reference for security schema fixed fields #4328

Merged
merged 2 commits into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions schemas/v3.1/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ properties:
$ref: '#/$defs/info'
jsonSchemaDialect:
type: string
format: uri
format: uri-reference
Copy link
Member

Choose a reason for hiding this comment

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

This one is the twin to JSON Schema's $schema keyword, and therefore cannot be a uri-reference.

Copy link
Member

Choose a reason for hiding this comment

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

@karenetheridge philosophically I agree with you, but the way the OAS field is written unfortunately allows a relative URI-reference. Of course you'd have to resolve that before you could use it as a dialect URI, and the only way that might work is with a custom dialect, but there's no reason it couldn't work that way.

I do agree that it should have been written as requiring a non-relative URI.

Copy link
Author

Choose a reason for hiding this comment

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

Happy to make the change if needed. Waiting for maintainer to come to an agreement.

Copy link
Member

Choose a reason for hiding this comment

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

@handrews what do you mean "the way the OAS field is written unfortunately allows a relative URI-reference"? What are you referencing here?

Copy link
Member

Choose a reason for hiding this comment

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

@karenetheridge It's the combination of two things:

§4.6.7 states:

Unless specified otherwise, all fields that are URIs MAY be relative references as defined by [RFC3986] Section 4.2.

while the fixed fields description for jsonSchemaDialect says:

The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI.

Strictly speaking, this text allows a URI reference. The value used with $schema of course must be a full URI, but that can be produced by resolving the relative URI-reference normally, just as with any other field that the OAS says "MUST be in the form of a URI". What is used with $schema is the resolved value, not the literal text.

At least that is my interpretation. We can always kick it up to @OAI/tsc for a ruling if you disagree. Again, I prefer your reading (and really dislike that we don't just explicitly say "URI-reference" and instead say "URI means URI-reference unless otherwise stated") but that's what we have to work with.

Copy link
Member

Choose a reason for hiding this comment

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

At the very least we need to tighten up the language that leaves this vague. It is not reasonable to say in one place that a value is a URI, and then at the top say "actually that means URI-reference" because now there's no way to say that no, really, this actually has to be a fully-resolved URI.

Also, in any place where we do allow a URI-reference, we should be explicit as to how that value will be resolved -- whether it's against the URI used to identify the entry document, the current document, or the Host header on the current HTTP request under consideration (when relevant) -- I can see places where each of these might be the appropriate choice for URI resolution.

Copy link
Member

Choose a reason for hiding this comment

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

@karenetheridge take a look at the XML Object's namespace field for how we say a field is a fully-resolve URI (again, I agree we should use the correct terminology per RFC3986 and not what we're doing now, but we do have ways to say we don't want a non-relative reference). We are very explicit about how OAD URI-referencess and API URL-references are resolved. Each of those topics gets a full section in the 3.1 specification. In any event, this is drifting outside of the scope of this PR and should continue in a discussion or issue.

default: 'https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS'
servers:
type: array
Expand Down Expand Up @@ -64,7 +64,7 @@ $defs:
type: string
termsOfService:
type: string
format: uri
format: uri-reference
contact:
$ref: '#/$defs/contact'
license:
Expand All @@ -85,7 +85,7 @@ $defs:
type: string
url:
type: string
format: uri
format: uri-reference
email:
type: string
format: email
Expand All @@ -102,7 +102,7 @@ $defs:
type: string
url:
type: string
format: uri
format: uri-reference
required:
- name
dependentSchemas:
Expand Down Expand Up @@ -297,7 +297,7 @@ $defs:
type: string
url:
type: string
format: uri
format: uri-reference
required:
- url
$ref: '#/$defs/specification-extensions'
Expand Down Expand Up @@ -598,7 +598,7 @@ $defs:
value: true
externalValue:
type: string
format: uri
format: uri-reference
not:
required:
- value
Expand Down Expand Up @@ -830,7 +830,7 @@ $defs:
properties:
openIdConnectUrl:
type: string
format: uri
format: uri-reference
required:
- openIdConnectUrl

Expand Down Expand Up @@ -864,10 +864,10 @@ $defs:
properties:
authorizationUrl:
type: string
format: uri
format: uri-reference
refreshUrl:
type: string
format: uri
format: uri-reference
scopes:
$ref: '#/$defs/map-of-strings'
required:
Expand All @@ -881,10 +881,10 @@ $defs:
properties:
tokenUrl:
type: string
format: uri
format: uri-reference
refreshUrl:
type: string
format: uri
format: uri-reference
scopes:
$ref: '#/$defs/map-of-strings'
required:
Expand All @@ -898,10 +898,10 @@ $defs:
properties:
tokenUrl:
type: string
format: uri
format: uri-reference
refreshUrl:
type: string
format: uri
format: uri-reference
scopes:
$ref: '#/$defs/map-of-strings'
required:
Expand All @@ -915,13 +915,13 @@ $defs:
properties:
authorizationUrl:
type: string
format: uri
format: uri-reference
tokenUrl:
type: string
format: uri
format: uri-reference
refreshUrl:
type: string
format: uri
format: uri-reference
scopes:
$ref: '#/$defs/map-of-strings'
required:
Expand Down