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.0.4.md
+67-6Lines changed: 67 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3802,9 +3802,38 @@ security:
3802
3802
3803
3803
See [Resolving Implicit Connections](#resolvingImplicitConnections) for more information.
3804
3804
3805
-
Entry document `openapi.yaml`:
3805
+
First, our entry document is where parsing begins. It defines the `MySecurity` security scheme to be JWT-based, and it defines on Path Item as a reference to a component in another document:
3806
3806
3807
-
```YAML
3807
+
```HTTP
3808
+
GET /api/description/openapi HTTP/1.1
3809
+
Host: www.example.com
3810
+
Accept: application/openapi+json
3811
+
```
3812
+
3813
+
```json
3814
+
"components": {
3815
+
"securitySchemes": {
3816
+
"MySecurity": {
3817
+
"type": "http",
3818
+
"scheme": "bearer",
3819
+
"bearerFormat": "JWT"
3820
+
}
3821
+
}
3822
+
},
3823
+
"paths": {
3824
+
"/foo": {
3825
+
"$ref": "other#/components/pathItems/Foo"
3826
+
}
3827
+
}
3828
+
```
3829
+
3830
+
```HTTP
3831
+
GET /api/description/openapi HTTP/1.1
3832
+
Host: www.example.com
3833
+
Accept: application/openapi+yaml
3834
+
```
3835
+
3836
+
```yaml
3808
3837
components:
3809
3838
securitySchemes:
3810
3839
MySecurity:
@@ -3813,12 +3842,44 @@ components:
3813
3842
bearerFormat: JWT
3814
3843
paths:
3815
3844
/foo:
3816
-
$ref: "other.yaml#/components/pathItems/Foo"
3845
+
$ref: "other#/components/pathItems/Foo"
3817
3846
```
3818
3847
3819
-
Referenced document `other.yaml`:
3848
+
Next, we have our referenced document, `other`, that we presumably request in the same format we requested for the entry document. But the fact that we don't use file extensions gives the client the flexibilty to choose on a resource-by-resource basis, assuming both representations are available:
3820
3849
3821
-
```YAML
3850
+
```HTTP
3851
+
GET /api/description/other HTTP/1.1
3852
+
Host: www.example.com
3853
+
Accept: application/openapi+json
3854
+
```
3855
+
3856
+
```json
3857
+
"components": {
3858
+
"securitySchemes": {
3859
+
"MySecurity": {
3860
+
"type": "http",
3861
+
"scheme": "basic"
3862
+
}
3863
+
},
3864
+
"pathItems": {
3865
+
"Foo": {
3866
+
"get": {
3867
+
"security": [
3868
+
"MySecurity": []
3869
+
]
3870
+
}
3871
+
}
3872
+
}
3873
+
}
3874
+
```
3875
+
3876
+
```HTTP
3877
+
GET /api/description/other HTTP/1.1
3878
+
Host: www.example.com
3879
+
Accept: application/openapi+yaml
3880
+
```
3881
+
3882
+
```yaml
3822
3883
components:
3823
3884
securitySchemes:
3824
3885
MySecurity:
@@ -3831,7 +3892,7 @@ components:
3831
3892
- MySecurity: []
3832
3893
```
3833
3894
3834
-
In this example, it is implementation-defined whether the Security Requirement for "MySecurity"in `other.yaml` resolves to `other.yaml#/components/securitySchemes/MySecurity` or the RECOMMENDED resolved location of `openapi.yaml#/components/securitySchemes/MySecurity`.
3895
+
In this `other` document, the reference path item has a Security Requirement for the Security Scheme "MySecurity". But there is a Security Scheme by that name in the `other` document as well. As discussed in [Resolving Implicit Connections](#resolvingImplicitConnections), which "MySecurity" gets used is [implementation-defined](#undefinedAndImplementationDefinedBehavior). However, as also 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