Skip to content

Commit 3b8959d

Browse files
feat: Add addSecuritySchema method to OpenAPI for defining security schemes
1 parent 6d709e4 commit 3b8959d

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@murat/openapi",
33
"exports": "./mod.ts",
4-
"version": "0.1.11",
4+
"version": "0.1.12",
55
"tasks": {
66
"lint": "deno lint",
77
"test": "deno test --allow-all",

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@murat/openapi",
3-
"version": "0.1.11",
3+
"version": "0.1.12",
44
"license": "MIT",
55
"exports": "./mod.ts",
66
"imports": {

src/Core.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type {
22
OpenAPICore,
33
OpenAPIPathItem,
44
OpenAPISecurityRequirement,
5+
OpenAPISecurityTypes,
56
OpenAPITag,
67
} from './Core.types.ts';
78
import { createEndpointBuilder, EndpointBuilder } from './EndpointBuilder.ts';
@@ -195,6 +196,17 @@ class OpenAPI {
195196
};
196197
return this;
197198
}
199+
200+
addSecuritySchema(name: string, schema: { type: OpenAPISecurityTypes; description?: string }): this {
201+
if (!this.raw.components) {
202+
this.raw.components = { securitySchemes: {} };
203+
}
204+
if (!this.raw.components.securitySchemes) {
205+
this.raw.components.securitySchemes = {};
206+
}
207+
this.raw.components.securitySchemes[name] = schema;
208+
return this;
209+
}
198210
}
199211

200212
export { createEndpointBuilder, createEndpointPath, OpenAPI };

0 commit comments

Comments
 (0)