Skip to content

Commit 41720cb

Browse files
fix: Bump version to 0.1.15 in deno.json and jsr.json; update import statements for consistency
1 parent cad4600 commit 41720cb

7 files changed

Lines changed: 63 additions & 72 deletions

File tree

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.14",
4+
"version": "0.1.15",
55
"tasks": {
66
"lint": "deno lint",
77
"test": "deno test --allow-all",

deno.lock

Lines changed: 1 addition & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.14",
3+
"version": "0.1.15",
44
"license": "MIT",
55
"exports": "./mod.ts",
66
"imports": {

mod.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from './src/Core.types.ts';
2-
export * from './src/Licenses.types.ts';
3-
export * from './src/Core.ts';
4-
export * from './src/EndpointBuilder.ts';
1+
export * from "./src/Core.types.ts";
2+
export * from "./src/Licenses.types.ts";
3+
export * from "./src/Core.ts";
4+
export * from "./src/EndpointBuilder.ts";

src/Core.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@ import type {
44
OpenAPISecurityRequirement,
55
OpenAPISecurityTypes,
66
OpenAPITag,
7-
} from './Core.types.ts';
8-
import { createEndpointBuilder, EndpointBuilder } from './EndpointBuilder.ts';
9-
import { createEndpointPath, type EndpointPath } from './EndpointPath.ts';
10-
import type { AllowedLicenses } from './Licenses.types.ts';
7+
} from "./Core.types.ts";
8+
import {
9+
createEndpointBuilder,
10+
type EndpointBuilder,
11+
} from "./EndpointBuilder.ts";
12+
import { createEndpointPath, type EndpointPath } from "./EndpointPath.ts";
13+
import type { AllowedLicenses } from "./Licenses.types.ts";
1114

1215
class OpenAPI {
1316
private raw: OpenAPICore;
1417
private endpoints: EndpointBuilder[];
1518

1619
constructor() {
1720
this.raw = {
18-
openapi: '3.1.0',
21+
openapi: "3.1.0",
1922
info: {
20-
title: 'OpenAPI 3.1.0',
21-
version: '1.0.0',
23+
title: "OpenAPI 3.1.0",
24+
version: "1.0.0",
2225
},
2326
};
2427
this.endpoints = [];
@@ -37,8 +40,8 @@ class OpenAPI {
3740
for (const endpoint of this.endpoints) {
3841
if (!endpoint.path || !endpoint.method) {
3942
console.warn(
40-
'Endpoint is missing path or method, skipping',
41-
endpoint
43+
"Endpoint is missing path or method, skipping",
44+
endpoint,
4245
);
4346
continue;
4447
}
@@ -108,19 +111,19 @@ class OpenAPI {
108111
}
109112

110113
setLicenseName(name: string): this {
111-
this.raw.info.license = this.raw.info.license || { name: '' };
114+
this.raw.info.license = this.raw.info.license || { name: "" };
112115
this.raw.info.license.name = name;
113116
return this;
114117
}
115118

116119
setLicenseUrl(url: string): this {
117-
this.raw.info.license = this.raw.info.license || { name: '' };
120+
this.raw.info.license = this.raw.info.license || { name: "" };
118121
this.raw.info.license.url = url;
119122
return this;
120123
}
121124

122125
setLicenseIdentifier(identifier: AllowedLicenses): this {
123-
this.raw.info.license = this.raw.info.license || { name: '' };
126+
this.raw.info.license = this.raw.info.license || { name: "" };
124127
this.raw.info.license.identifier = identifier;
125128
return this;
126129
}
@@ -149,7 +152,7 @@ class OpenAPI {
149152
}
150153

151154
setSecurity(scheme: {
152-
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
155+
type: "apiKey" | "http" | "oauth2" | "openIdConnect";
153156
name: string;
154157
scopes?: string[];
155158
}): this {
@@ -199,17 +202,17 @@ class OpenAPI {
199202

200203
addSecuritySchema(
201204
name: string,
202-
scheme: {
203-
type: OpenAPISecurityTypes;
204-
scheme?: string; // Correct property for HTTP auth
205+
scheme: {
206+
type: OpenAPISecurityTypes;
207+
scheme?: string; // Correct property for HTTP auth
205208
bearerFormat?: string; // For JWT format specification
206209
name?: string; // For apiKey type
207210
in?: string; // For apiKey type
208211
openIdConnectUrl?: string; // For openIdConnect type
209212
// deno-lint-ignore no-explicit-any
210213
flows?: Record<string, any>; // For oauth2 type
211214
description?: string;
212-
}
215+
},
213216
): this {
214217
if (!this.raw.components) {
215218
this.raw.components = { securitySchemes: {} };

src/EndpointBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class EndpointBuilder {
129129
return this;
130130
}
131131

132-
addRawParameter(obj: OpenAPIParameter ): this {
132+
addRawParameter(obj: OpenAPIParameter): this {
133133
if (!this.operation.parameters) {
134134
this.operation.parameters = [];
135135
}

test/new_usage_test.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Deno.test("New usage with individual endpoints", () => {
77
.setVersion("1.0.0");
88

99
const endpoint1 = createEndpointBuilder()
10-
.setMethod('get')
11-
.setPath('/tasks')
12-
.setSummary('Get Tasks')
13-
.setOperationId('getTasks')
10+
.setMethod("get")
11+
.setPath("/tasks")
12+
.setSummary("Get Tasks")
13+
.setOperationId("getTasks")
1414
.setResponses({
1515
200: {
1616
description: "Success response",
@@ -33,23 +33,23 @@ Deno.test("New usage with individual endpoints", () => {
3333
});
3434

3535
const endpoint2 = createEndpointBuilder()
36-
.setMethod('post')
37-
.setPath('/tasks')
38-
.setSummary('Create Task')
39-
.setOperationId('createTask')
36+
.setMethod("post")
37+
.setPath("/tasks")
38+
.setSummary("Create Task")
39+
.setOperationId("createTask")
4040
.setRequestBody(
4141
{
42-
'application/json': {
42+
"application/json": {
4343
schema: {
44-
type: 'object',
44+
type: "object",
4545
properties: {
46-
title: { type: 'string' },
47-
completed: { type: 'boolean' },
46+
title: { type: "string" },
47+
completed: { type: "boolean" },
4848
},
4949
},
5050
},
5151
},
52-
true
52+
true,
5353
)
5454
.setResponses({
5555
201: {
@@ -59,11 +59,11 @@ Deno.test("New usage with individual endpoints", () => {
5959

6060
// Add endpoint with different path
6161
const endpoint3 = createEndpointBuilder()
62-
.setMethod('get')
63-
.setPath('/tasks/{taskId}')
64-
.setSummary('Get Task by ID')
65-
.setOperationId('getTaskById')
66-
.setParameter('taskId', 'path', true, 'Task identifier')
62+
.setMethod("get")
63+
.setPath("/tasks/{taskId}")
64+
.setSummary("Get Task by ID")
65+
.setOperationId("getTaskById")
66+
.setParameter("taskId", "path", true, "Task identifier")
6767
.setResponses({
6868
200: {
6969
description: "Task details",
@@ -79,34 +79,34 @@ Deno.test("New usage with individual endpoints", () => {
7979

8080
// Verify that we have two distinct paths
8181
assertEquals(Object.keys(result.paths || {}).length, 2);
82-
82+
8383
// Check that /tasks has both GET and POST methods
8484
// deno-lint-ignore no-explicit-any
85-
const tasksPath = result.paths?.['/tasks'] as any;
86-
assertEquals(typeof tasksPath?.get, 'object');
87-
assertEquals(typeof tasksPath?.post, 'object');
88-
assertEquals(tasksPath?.get?.operationId, 'getTasks');
89-
assertEquals(tasksPath?.post?.operationId, 'createTask');
90-
85+
const tasksPath = result.paths?.["/tasks"] as any;
86+
assertEquals(typeof tasksPath?.get, "object");
87+
assertEquals(typeof tasksPath?.post, "object");
88+
assertEquals(tasksPath?.get?.operationId, "getTasks");
89+
assertEquals(tasksPath?.post?.operationId, "createTask");
90+
9191
// Check that /tasks/{taskId} has GET method
9292
// deno-lint-ignore no-explicit-any
93-
const taskByIdPath = result.paths?.['/tasks/{taskId}'] as any;
94-
assertEquals(typeof taskByIdPath?.get, 'object');
95-
assertEquals(taskByIdPath?.get?.operationId, 'getTaskById');
93+
const taskByIdPath = result.paths?.["/tasks/{taskId}"] as any;
94+
assertEquals(typeof taskByIdPath?.get, "object");
95+
assertEquals(taskByIdPath?.get?.operationId, "getTaskById");
9696
});
9797

9898
Deno.test("Adding a single endpoint works", () => {
9999
const api = new OpenAPI();
100-
100+
101101
api.addEndpoint(
102102
createEndpointBuilder()
103-
.setMethod('get')
104-
.setPath('/users')
105-
.setOperationId('getUsers')
103+
.setMethod("get")
104+
.setPath("/users")
105+
.setOperationId("getUsers"),
106106
);
107-
107+
108108
// deno-lint-ignore no-explicit-any
109109
const result = api.getJSON() as any;
110-
assertEquals(typeof result.paths?.['/users']?.get, 'object');
111-
assertEquals(result.paths?.['/users']?.get?.operationId, 'getUsers');
110+
assertEquals(typeof result.paths?.["/users"]?.get, "object");
111+
assertEquals(result.paths?.["/users"]?.get?.operationId, "getUsers");
112112
});

0 commit comments

Comments
 (0)