Skip to content

Commit e21a28f

Browse files
committed
feat: SecurityRequirementObject
1 parent 2106a24 commit e21a28f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ComponentsObject } from "./components";
22
import type { InfoObject } from "./info";
33
import type { PathsObject } from "./paths";
4+
import type { SecurityRequirementObject } from "./security-requirement";
45
import type { ServerObject } from "./server";
56
import type { TagObject } from "./tag";
67

@@ -41,7 +42,7 @@ export type OpenApiDocument = {
4142
/**
4243
* 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.
4344
*/
44-
security?: unknown,
45+
security?: SecurityRequirementObject[],
4546
/**
4647
* 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 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.
4748
*/

src/operation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ParameterObject } from "./parameter";
22
import type { ReferenceObject } from "./reference";
33
import type { RequestBodyObject } from "./request-body";
44
import type { ResponsesObject } from "./response";
5+
import type { SecurityRequirementObject } from "./security-requirement";
56

67
/**
78
* Describes a single API operation on a path.
@@ -50,7 +51,7 @@ export type OperationObject = {
5051
/**
5152
* 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. To remove a top-level security declaration, an empty array can be used.
5253
*/
53-
security?: unknown,
54+
security?: SecurityRequirementObject[],
5455
/**
5556
* 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.
5657
*/

src/security-requirement.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Lists the required security schemes to execute this operation.
3+
*/
4+
export type SecurityRequirementObject = Record<string, string[]>;

0 commit comments

Comments
 (0)