Skip to content

Commit c8a154f

Browse files
committed
example as YAML/JSON via HTTP negotiation
1 parent ae35691 commit c8a154f

File tree

1 file changed

+67
-6
lines changed

1 file changed

+67
-6
lines changed

versions/3.0.4.md

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,9 +3802,38 @@ security:
38023802

38033803
See [Resolving Implicit Connections](#resolvingImplicitConnections) for more information.
38043804

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:
38063806

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
38083837
components:
38093838
securitySchemes:
38103839
MySecurity:
@@ -3813,12 +3842,44 @@ components:
38133842
bearerFormat: JWT
38143843
paths:
38153844
/foo:
3816-
$ref: "other.yaml#/components/pathItems/Foo"
3845+
$ref: "other#/components/pathItems/Foo"
38173846
```
38183847

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:
38203849

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
38223883
components:
38233884
securitySchemes:
38243885
MySecurity:
@@ -3831,7 +3892,7 @@ components:
38313892
- MySecurity: []
38323893
```
38333894

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.
38353896

38363897
### <a name="specificationExtensions"></a>Specification Extensions
38373898

0 commit comments

Comments
 (0)