Skip to content

Commit 2de0f80

Browse files
committed
Clarify security; state that [] is undefined behaviour
Port of #4007 to v3.0.4-dev
1 parent b7c20ee commit 2de0f80

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

versions/3.0.4.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,24 @@ This is the root object of the [OpenAPI document](#openapi-description).
249249
| <a name="oas-servers"></a>servers | [[Server Object](#server-object)] | An array of Server Objects, which provide connectivity information to a target server. If the `servers` property is not provided, or is an empty array, the default value would be a [Server Object](#server-object) with a [url](#server-url) value of `/`. |
250250
| <a name="oas-paths"></a>paths | [Paths Object](#paths-object) | **REQUIRED**. The available paths and operations for the API. |
251251
| <a name="oas-components"></a>components | [Components Object](#components-object) | An element to hold various schemas for the document. |
252-
| <a name="oas-security"></a>security | [[Security Requirement Object](#security-requirement-object)] | A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. Individual operations can override this definition. To make security optional, an empty security requirement (`{}`) can be included in the array. |
252+
| <a name="oas-security"></a>security | [[Security Requirement Object](#security-requirement-object)] | A declaration of which security mechanisms can be used across the API. See [The `security` Field](#the-security-field). |
253253
| <a name="oas-tags"></a>tags | [[Tag Object](#tag-object)] | A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operation-object) must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. |
254254
| <a name="oas-external-docs"></a>externalDocs | [External Documentation Object](#external-documentation-object) | Additional external documentation. |
255255

256256
This object MAY be extended with [Specification Extensions](#specification-extensions).
257257

258+
###### The `security` Field
259+
260+
The `security` field describes how requests are authorized:
261+
262+
- If omitted, then nothing can be inferred about the authorization requirements; the behaviour is implementation-defined.
263+
- If present but empty (`security: []`), then the behaviour is undefined.
264+
- Otherwise, it is an array of [Security Requirement Objects](#security-requirement-object), at least one of which needs to be satisfied for the request to be authorized.
265+
266+
Because the empty Security Requirement Object `{}` will always be satisfied, any `security` list that includes `{}` will allow all requests. In particular, `security: [{}]` means that no security schemes are in use (also known as "no security").
267+
268+
Individual Operations can [override this field](#operation-security).
269+
258270
#### Info Object
259271

260272
The object provides metadata about the API.
@@ -897,7 +909,7 @@ Describes a single API operation on a path.
897909
| <a name="operation-responses"></a>responses | [Responses Object](#responses-object) | **REQUIRED**. The list of possible responses as they are returned from executing this operation. |
898910
| <a name="operation-callbacks"></a>callbacks | Map[`string`, [Callback Object](#callback-object) \| [Reference Object](#reference-object)] | A map of possible out-of band callbacks related to the parent operation. The key is a unique identifier for the Callback Object. Each value in the map is a [Callback Object](#callback-object) that describes a request that may be initiated by the API provider and the expected responses. |
899911
| <a name="operation-deprecated"></a>deprecated | `boolean` | Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is `false`. |
900-
| <a name="operation-security"></a>security | [[Security Requirement Object](#security-requirement-object)] | A declaration of which security mechanisms can be used for this operation. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a request. To make security optional, an empty security requirement (`{}`) can be included in the array. This definition overrides any declared top-level [`security`](#oas-security). To remove a top-level security declaration, an empty array can be used. |
912+
| <a name="operation-security"></a>security | [[Security Requirement Object](#security-requirement-object)] | A declaration of which security mechanisms can be used for this operation. If present, then this overrides any `security` field specified at the [OpenAPI Object](#oas-security) level. See the [definition of that field](#the-security-field) for details. |
901913
| <a name="operation-servers"></a>servers | [[Server Object](#server-object)] | An alternative `server` array to service this operation. If an alternative `server` object is specified at the Path Item Object or Root level, it will be overridden by this value. |
902914

903915
This object MAY be extended with [Specification Extensions](#specification-extensions).
@@ -3715,7 +3727,7 @@ The name used for each property MUST correspond to a security scheme declared in
37153727
Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized.
37163728
This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information.
37173729

3718-
When a list of Security Requirement Objects is defined on the [OpenAPI Object](#openapi-object) or [Operation Object](#operation-object), only one of the Security Requirement Objects in the list needs to be satisfied to authorize the request.
3730+
When a non-empty list of Security Requirement Objects is defined on the [OpenAPI Object](#openapi-object) or [Operation Object](#operation-object), at least one of the Security Requirement Objects in the list needs to be satisfied for the request to be authorized; see [the `security` field](#the-security-field).
37193731

37203732
##### Patterned Fields
37213733

0 commit comments

Comments
 (0)