Skip to content

Commit 6a97a0f

Browse files
committed
Clarify resolving implicit connections (3.1.1)
This clarifies how to handle resolving implicit (non-URI-based) connections in multi-document OpenAPI Descriptions. While the behavior is implementation-defined overall, this RECOMMENDS a single approach based on how things behaved going back to the 2.0 referencing model. This allows Security Schemes and Tags to (like the top-level Server Objects) define a deployment-specific interface for referenced documents to access. This entry document interface approach makes less sense for the Discriminator Object, but it can use the URI syntax of `mapping` to keep things within the local document. This also aligns the search for matching `operationId`s with 3.1's full-document parsing requirements. Note that the term "complete OpenAPI document" has been defined in another change pending approval on the 3.0.4 branch.
1 parent d94d13f commit 6a97a0f

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

versions/3.1.1.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,46 @@ It is the responsibility of an embedding format to define how to parse embedded
185185

186186
When parsing an OAD, JSON or YAML objects are parsed into specific Objects (such as [Operation Objects](#operationObject), [Response Objects](#responseObject), [Reference Objects](#referenceObject), etc.) based on the parsing context. Depending on how references are arranged, a given JSON or YAML object can be parsed in multiple different contexts:
187187

188-
* As a full OpenAPI Description document (an [OpenAPI Object](#oasObject) taking up an entire document)
188+
* As a complete OpenAPI Description document
189189
* As the Object type implied by its parent Object within the document
190190
* As a reference target, with the Object type matching the reference source's context
191191

192192
If the same JSON/YAML object is parsed multiple times and the respective contexts require it to be parsed as _different_ Object types, the resulting behavior is _implementation defined_, and MAY be treated as an error if detected. An example would be referencing an empty Schema Object under `#/components/schemas` where a Path Item Object is expected, as an empty object is valid for both types. For maximum interoperability, it is RECOMMENDED that OpenAPI Description authors avoid such scenarios.
193193

194+
#### <a name="resolvingImplicitConnections"></a>Resolving Implicit Connections
195+
196+
Several features of this specification require resolving a non-URI-based connection to some other part of the OpenAPI Description (OAD).
197+
198+
These connections are easily resolved in single-document OADs, but the resolution process in multi-document OADs has never been spelled out, and is therefore _implementation-defined_, within the constraints described in this section.
199+
In some cases, an unambiguous URI-based alternative is available, and OAD authors are RECOMMENDED to always use the alternative:
200+
201+
Source | Target | Alternative
202+
------ | ------ | -----------
203+
[Security Requirement Object](#securityRequirementObject) `{name}` | [Security Scheme Object](#securitySchemeObject) name under the [Components Object](#componentsObject) | _n/a_
204+
[Discriminator Object](#discriminatorObject) `mapping` _(implicit, or explicit name syntax)_ | [Schema Object](#schemaObject) name under the Components Object | `mapping` _(explicit URI syntax)_
205+
[Operation Object](#operationObject) `tags` | [Tag Object](#tagObject) `name` (in the Components Object) | _n/a_
206+
[Link Object](#linkObject) `operationId` | [Path Item Object](#pathItemObject) `operationId` | `operationRef`
207+
208+
A fifth implicit connection, which involves appending the templated URL paths of the [Paths Object](#pathsObject) to the appropriate [Server Object](#serverObject)'s `url` field, is unambiguous because only the entry document's Paths Object contributes URLs to the described API.
209+
210+
It is RECOMMENDED to consider all Operation Objects from all parsed documents when resolving any Link Object `operationId`.
211+
This requires ensuring that all referenced documents have been parsed prior to determining an `operationId` to be unresolvable.
212+
213+
The implicit connections in the Security Requirement Object and Discriminator Object rely on the _component name_, which is the property name holding the component in the appropriate typed sub-object of the Components Object.
214+
For example, the component name of the Schema Object at `#/components/schemas/Foo` is `Foo`.
215+
The implicit connection of tags in the Operation Object use the `name` field of Tag Objects, which (like the Components Object) are found under the root OpenAPI Object.
216+
This means that resolving component names and tag names both depend on starting from the correct OpenAPI Object.
217+
218+
For resolving component and tag name connections from a referenced (non-entry) document, it is RECOMMENDED that tools resolve from the entry document, rather than the current document.
219+
This allows Security Scheme Objects and Tag Objects to be defined with the API's deployment information (the top-level Server Objects), and treated as an interface for referenced documents to access.
220+
221+
The interface approach can also work for Discriminator Objects and Schema Objects, but it is also possible to keep the Discriminator Object's behavior within a single document using the relative URI-reference syntax of `mapping`.
222+
223+
There are not currently URI-based alternatives for the Security Requirement Object or for the Operation Object's `tags` field.
224+
These limitations are expected to be addressed in a future release.
225+
226+
Note that no aspect of implicit connection resolution changes how [URIs are resolved](#relativeReferencesURI), or restricts their possible targets.
227+
194228
### <a name="dataTypes"></a>Data Types
195229

196230
Data types in the OAS are based on the types supported by the [JSON Schema Specification Draft 2020-12](https://tools.ietf.org/html/draft-bhutton-json-schema-00#section-4.2.1).

0 commit comments

Comments
 (0)