You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versions/3.1.1.md
+133-1
Original file line number
Diff line number
Diff line change
@@ -185,14 +185,50 @@ It is the responsibility of an embedding format to define how to parse embedded
185
185
186
186
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:
187
187
188
-
* As a full OpenAPI Description document (an [OpenAPI Object](#oasObject) taking up an entire document)
188
+
* As a complete OpenAPI Description document
189
189
* As the Object type implied by its parent Object within the document
190
190
* As a reference target, with the Object type matching the reference source's context
191
191
192
192
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.
Several features of this specification require resolution of non-URI-based connections to some other part of the OpenAPI Description (OAD).
197
+
198
+
These connections are unambiguously resolved in single-document OADs, but the resolution process in multi-document OADs is _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_
A fifth implicit connection involves appending the templated URL paths of the [Paths Object](#pathsObject) to the appropriate [Server Object](#serverObject)'s `url` field.
209
+
This is unambiguous because only the entry document's Paths Object contributes URLs to the described API.
210
+
211
+
It is RECOMMENDED to consider all Operation Objects from all parsed documents when resolving any Link Object `operationId`.
212
+
This requires parsing all referenced documents prior to determining an `operationId` to be unresolvable.
213
+
214
+
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 appropriately typed sub-object of the Components Object.
215
+
For example, the component name of the Schema Object at `#/components/schemas/Foo` is `Foo`.
216
+
The implicit connection of `tags` in the Operation Object uses the `name` field of Tag Objects, which (like the Components Object) are found under the root OpenAPI Object.
217
+
This means resolving component names and tag names both depend on starting from the correct OpenAPI Object.
218
+
219
+
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.
220
+
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.
221
+
222
+
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`.
223
+
224
+
There are no URI-based alternatives for the Security Requirement Object or for the Operation Object's `tags` field.
225
+
These limitations are expected to be addressed in a future release.
226
+
227
+
See [Security Requirement in a Referenced Document](#security-requirement-in-a-referenced-document) for an example of the possible resolutions, including which one is recommended by this section.
228
+
The behavior for Discrimator Object non-URI mappings and for the Operation Object's `tags` field operate on the same principles.
229
+
230
+
Note that no aspect of implicit connection resolution changes how [URIs are resolved](#relativeReferencesURI), or restricts their possible targets.
231
+
196
232
### <aname="dataTypes"></a>Data Types
197
233
198
234
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).
@@ -3792,6 +3828,102 @@ security:
3792
3828
- read:pets
3793
3829
```
3794
3830
3831
+
###### Security Requirement in a Referenced Document
3832
+
3833
+
See [Resolving Implicit Connections](#resolvingImplicitConnections) for more information.
3834
+
3835
+
First, our entry document is where parsing begins. It defines the `MySecurity` security scheme to be JWT-based, and it defines a Path Item as a reference to a component in another document:
3836
+
3837
+
```HTTP
3838
+
GET /api/description/openapi HTTP/1.1
3839
+
Host: www.example.com
3840
+
Accept: application/openapi+json
3841
+
```
3842
+
3843
+
```json
3844
+
"components": {
3845
+
"securitySchemes": {
3846
+
"MySecurity": {
3847
+
"type": "http",
3848
+
"scheme": "bearer",
3849
+
"bearerFormat": "JWT"
3850
+
}
3851
+
}
3852
+
},
3853
+
"paths": {
3854
+
"/foo": {
3855
+
"$ref": "other#/components/pathItems/Foo"
3856
+
}
3857
+
}
3858
+
```
3859
+
3860
+
```HTTP
3861
+
GET /api/description/openapi HTTP/1.1
3862
+
Host: www.example.com
3863
+
Accept: application/openapi+yaml
3864
+
```
3865
+
3866
+
```yaml
3867
+
components:
3868
+
securitySchemes:
3869
+
MySecurity:
3870
+
type: http
3871
+
scheme: bearer
3872
+
bearerFormat: JWT
3873
+
paths:
3874
+
/foo:
3875
+
$ref: "other#/components/pathItems/Foo"
3876
+
```
3877
+
3878
+
Next, we have our referenced document, `other`. The fact that we don't use file extensions gives the client the flexibility to choose an acceptable format on a resource-by-resource basis, assuming both representations are available:
3879
+
3880
+
```HTTP
3881
+
GET /api/description/other HTTP/1.1
3882
+
Host: www.example.com
3883
+
Accept: application/openapi+json
3884
+
```
3885
+
3886
+
```json
3887
+
"components": {
3888
+
"securitySchemes": {
3889
+
"MySecurity": {
3890
+
"type": "http",
3891
+
"scheme": "basic"
3892
+
}
3893
+
},
3894
+
"pathItems": {
3895
+
"Foo": {
3896
+
"get": {
3897
+
"security": [
3898
+
"MySecurity": []
3899
+
]
3900
+
}
3901
+
}
3902
+
}
3903
+
}
3904
+
```
3905
+
3906
+
```HTTP
3907
+
GET /api/description/other HTTP/1.1
3908
+
Host: www.example.com
3909
+
Accept: application/openapi+yaml
3910
+
```
3911
+
3912
+
```yaml
3913
+
components:
3914
+
securitySchemes:
3915
+
MySecurity:
3916
+
type: http
3917
+
scheme: basic
3918
+
pathItems:
3919
+
Foo:
3920
+
get:
3921
+
security:
3922
+
- MySecurity: []
3923
+
```
3924
+
3925
+
In the `other` document, the referenced path item has a Security Requirement for a Security Scheme, `MySecurity`. The same Security Scheme exists in the original entry document. As outlined in [Resolving Implicit Connections](#resolvingImplicitConnections), `MySecurity` is resolved with an [implementation-defined behavior](#undefinedAndImplementationDefinedBehavior). However, documented in that section, it is RECOMMENDED that tools resolve component names from the [entry document](#documentStructure). As with all implementation-defined behavior, it is important to check tool documentation to determine which behavior is supported.
0 commit comments