Replies: 5 comments 10 replies
-
Will this be our general pattern?
|
Beta Was this translation helpful? Give feedback.
-
I am particularly interested in whether folks think the |
Beta Was this translation helpful? Give feedback.
-
I also want to call attention to the requirements on what implementations MUST accept. As noted in the proposal, these requirements assume an implementation that does not do any I/O, and either accepts JSON/YAML text or just parsed JSON/YAML in whatever data structure is typical for the environment.
Note that:
I assume many implementations will do their own parsing and local filesystem and/or network I/O! For those tools, it's useful to think about the internals as the OAS implementation, and the part that does parsing and I/O as an "application". This allows tools to handle that I/O and parsing however they think is best while still being compliant. |
Beta Was this translation helpful? Give feedback.
-
Note that I just added two sections to the proposal above:
|
Beta Was this translation helpful? Give feedback.
-
Could we clearly document what exact problems this proposal is trying to solve comparing to the current referencing approach using |
Beta Was this translation helpful? Give feedback.
-
NOTE: Credit for the imports object and import-using syntax goes to Darrel Miller. I just wrote it up and added pieces around how imports get resolved.
I feel that it's important to get imports nailed down early on, for several reasons:
This proposal attempts to codify what @darrelmiller has already used in the deployments proposal, with gaps filled in based on my experiences writing
oascomply
and dealing with the inconsistent support for resolving and loading referenced schemas in JSON Schema-land.I can provide use cases for anything that I intentionally added beyond what the deployments proposal uses.
This is written more-or-less like specification text, but I'm assuming the wording will go through a lot of changes.
NOTE: This proposal does not address the interaction between Moonwalk importing an JSON Schema referencing. See discussion #73 for that aspect of the proposal.
OpenAPI Description Structure
An OpenAPI Description (OAD) MAY be made up of a single document, or divided into multiple documents connected by imports.
This specification defines the OpenAPI Description Document (OAD Document) format. OADs can incorporate other formats, such as JSON Schema, as stated for specific keywords in this specification or extensions to it.
Relative References in Description IRIs
The base IRI for relative IRI-references that identify OAD resources MUST be determined in accordance with RFC 3987 §6.5 which delegates the process to RFC 3986 §5.
The
self
field in the OpenAPI Object, if it is present, MUST be used as the base IRI in accordance with RFC 3986 §5.1.1.As the full environment necessary to determine a base IRI might not be visible an OAS implementation, implementations MUST allow the user to specify an external base IRI for each OAD Document, which is assumed to be in accordance with RFC 3986 §5.1.2 – §5.1.4.
If
self
is not present and no external base IRI is provided, implementations MAY define and document a default base IRI in accordance with RFC 3986 §5.1.4. Otherwise, if relative IRI-references are present, implementations MUST raise an error.Embedding OAD Documents in Other Formats
NOTE: This section added 11 Feb 2024.
Other formats MAY embed OAD Documents. Embedded OAD Documents SHOULD define a
self
import. If noself
import is present, the behavior is undefined by this specification.It is RECOMMENDED that formats embedding OADs require and enforce a
self
import that uses anabsolute-IRI
in order to be interoperable with tools that parse and use the embedded OAD Document format without understanding the containing format. The behavior of OAS-specific tools with embedded OADs that do not define such aself
field is implementation-defined.TODO: should implementations be required to support embedded OAD Documents with an absolute-IRI
self
field, or is that a MAY feature only? Presumably, parsing out the embedded document so it can be treated as if it were standalone would happen before anything else. It would complicate using a URL to import things as it would presumably require a fragment, and I am highly reluctant to require handling such things directly.Relative References in API URLs
Relative URL-references in the described API are resolved using the base URL defined in the relevant Deployment Object. If no Deployment Object is defined or relevant, API URL-references MUST be resolved as described for IRIs in the previous section.
Schema
OpenAPI Object
Fixed Fields
IRI-reference
(without a fragment)NOTE: The following paragraph was added 19 Feb 2024.
The value of
self
is an identifier, and not necessarily a locator. The value need not be usable as a URL, and even if it is, the document need not be accessible at that location.Import Object
An object associating a resource, identified by an
absolute-IRI
, with a namespace.Fixed Fields
TODO: namespace syntax, which MUST allow for full use of unicode in human-readable components
string
IRI-reference
(without a fragment)The namespace
self
is reserved as the namespace for the current document.Using Imported Names
NOTE: This syntax comes directly from the deployments examples. It does involve values that are either objects (inline) or strings (imported names) which might be of concern to developers in strictly typed languages.
Imported names are used in specific contexts that require a particular type of Object. The syntax for using a name is:
where
<namespace>
is replaced by the namespace from an Import Object in the current document, and<componentName>
MUST but the name of an Object in the imported document's Components Object, under the appropriate semantic type section. Therefore:In this example, the import
href
"fooComponents" is an IRI-reference resolved againstself
as a base IRI, producinghttps://example.com/fooComponents
. Since thefoo:Foos
is found where a Path Item Object is expected, the "Foos" entry underpathItems
is used rather than the identically-named Schema Object underschemas
.The
/bars
entry shows how to use a component from the current document with the reservedself
namespace.Referencing a Complete Document
NOTE: This section added 11 Feb 2024.
Some fields require a document-level reference, such as connecting a deployment to its shape. In that case, only the namespace is used, without the component name separator:
This form MUST only be used when it makes sense to talk about the effect of the complete document, rather than components within the document.
Locating and Loading Imported Resources
NOTE: The requirements in this section are phrased to allow, but not require, compliant implementations to delegate all I/O to applications. It should also be possible to implement resolvers separate from the core OAS support, somewhat like reference resolvers/removers but with much better UX.
Implementations MUST support two methods of resolving imports:
Note that interacting with local files is equivalent to retrieval using
file:
IRIs ([RFC 8089])(https://datatracker.ietf.org/doc/html/rfc8089).As implementations cannot determine a self-assigned IRI without parsing the resource, they MUST support pre-loading resources or otherwise configuring some mechanism to load likely candidates on demand.
Implementations MAY directly support URL retrieval. Those that do SHOULD support URI schemes most relevant to their environment, such as
file:
for local access andhttps:
for network access.Implementations that do not support URL retrieval MUST support associating a retrieval URL with each resource.
Security Considerations for URL Retrieval
TODO
Beta Was this translation helpful? Give feedback.
All reactions