Skip to content

Commit 6d0fad1

Browse files
committed
feat(esm): move to ESM for compatibility and get latest openapi-typescript
1 parent 5c3cf7a commit 6d0fad1

File tree

7 files changed

+368
-325
lines changed

7 files changed

+368
-325
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ jest.config.js
3131
.eslintrc.js
3232
.commitlintrc.json
3333
vitest.config.ts
34+
.eslintrc.cjs
35+
.prettierrc.cjs

__tests__/__snapshots__/index.spec.ts.snap

+72-24
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ export interface components {
247247
pathItems: never;
248248
}
249249
250+
export type $defs = Record<string, never>;
251+
250252
export type external = Record<string, never>;
251253
252254
export interface operations {
@@ -273,11 +275,17 @@ export interface operations {
273275
};
274276
};
275277
/** @description Invalid ID supplied */
276-
400: never;
278+
400: {
279+
content: never;
280+
};
277281
/** @description Pet not found */
278-
404: never;
282+
404: {
283+
content: never;
284+
};
279285
/** @description Validation exception */
280-
405: never;
286+
405: {
287+
content: never;
288+
};
281289
};
282290
};
283291
/**
@@ -302,7 +310,9 @@ export interface operations {
302310
};
303311
};
304312
/** @description Invalid input */
305-
405: never;
313+
405: {
314+
content: never;
315+
};
306316
};
307317
};
308318
/**
@@ -325,7 +335,9 @@ export interface operations {
325335
};
326336
};
327337
/** @description Invalid status value */
328-
400: never;
338+
400: {
339+
content: never;
340+
};
329341
};
330342
};
331343
/**
@@ -348,7 +360,9 @@ export interface operations {
348360
};
349361
};
350362
/** @description Invalid tag value */
351-
400: never;
363+
400: {
364+
content: never;
365+
};
352366
};
353367
};
354368
/**
@@ -371,9 +385,13 @@ export interface operations {
371385
};
372386
};
373387
/** @description Invalid ID supplied */
374-
400: never;
388+
400: {
389+
content: never;
390+
};
375391
/** @description Pet not found */
376-
404: never;
392+
404: {
393+
content: never;
394+
};
377395
};
378396
};
379397
/** Updates a pet in the store with form data */
@@ -392,7 +410,9 @@ export interface operations {
392410
};
393411
responses: {
394412
/** @description Invalid input */
395-
405: never;
413+
405: {
414+
content: never;
415+
};
396416
};
397417
};
398418
/** Deletes a pet */
@@ -408,7 +428,9 @@ export interface operations {
408428
};
409429
responses: {
410430
/** @description Invalid pet value */
411-
400: never;
431+
400: {
432+
content: never;
433+
};
412434
};
413435
};
414436
/** uploads an image */
@@ -447,7 +469,7 @@ export interface operations {
447469
200: {
448470
content: {
449471
\\"application/json\\": {
450-
[key: string]: number | undefined;
472+
[key: string]: number;
451473
};
452474
};
453475
};
@@ -473,7 +495,9 @@ export interface operations {
473495
};
474496
};
475497
/** @description Invalid input */
476-
405: never;
498+
405: {
499+
content: never;
500+
};
477501
};
478502
};
479503
/**
@@ -496,9 +520,13 @@ export interface operations {
496520
};
497521
};
498522
/** @description Invalid ID supplied */
499-
400: never;
523+
400: {
524+
content: never;
525+
};
500526
/** @description Order not found */
501-
404: never;
527+
404: {
528+
content: never;
529+
};
502530
};
503531
};
504532
/**
@@ -514,9 +542,13 @@ export interface operations {
514542
};
515543
responses: {
516544
/** @description Invalid ID supplied */
517-
400: never;
545+
400: {
546+
content: never;
547+
};
518548
/** @description Order not found */
519-
404: never;
549+
404: {
550+
content: never;
551+
};
520552
};
521553
};
522554
/**
@@ -561,7 +593,9 @@ export interface operations {
561593
};
562594
};
563595
/** @description successful operation */
564-
default: never;
596+
default: {
597+
content: never;
598+
};
565599
};
566600
};
567601
/** Logs user into the system */
@@ -589,14 +623,18 @@ export interface operations {
589623
};
590624
};
591625
/** @description Invalid username/password supplied */
592-
400: never;
626+
400: {
627+
content: never;
628+
};
593629
};
594630
};
595631
/** Logs out current logged in user session */
596632
logoutUser: {
597633
responses: {
598634
/** @description successful operation */
599-
default: never;
635+
default: {
636+
content: never;
637+
};
600638
};
601639
};
602640
/** Get user by user name */
@@ -616,9 +654,13 @@ export interface operations {
616654
};
617655
};
618656
/** @description Invalid username supplied */
619-
400: never;
657+
400: {
658+
content: never;
659+
};
620660
/** @description User not found */
621-
404: never;
661+
404: {
662+
content: never;
663+
};
622664
};
623665
};
624666
/**
@@ -642,7 +684,9 @@ export interface operations {
642684
};
643685
responses: {
644686
/** @description successful operation */
645-
default: never;
687+
default: {
688+
content: never;
689+
};
646690
};
647691
};
648692
/**
@@ -658,9 +702,13 @@ export interface operations {
658702
};
659703
responses: {
660704
/** @description Invalid username supplied */
661-
400: never;
705+
400: {
706+
content: never;
707+
};
662708
/** @description User not found */
663-
404: never;
709+
404: {
710+
content: never;
711+
};
664712
};
665713
};
666714
}

__tests__/index.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path';
22

33
import { expect, test } from 'vitest';
44

5-
import { generate } from '../src/index';
5+
import { generate } from '../src/index.js';
66

77
test('should generate a matching document', async () => {
88
const types = await generate(path.resolve(__dirname, 'petstore.json'), {});

package.json

+13-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "A version of openapi-typescript that also generates enumerations",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",
7+
"type": "module",
78
"bin": "build/bin/index.js",
89
"author": "Max Metral <[email protected]>",
910
"license": "MIT",
@@ -41,23 +42,23 @@
4142
"access": "public"
4243
},
4344
"devDependencies": {
44-
"@commitlint/cli": "^17.6.7",
45-
"@commitlint/config-conventional": "^17.6.7",
46-
"@openapi-typescript-infra/coconfig": "^3.3.6",
45+
"@commitlint/cli": "^17.7.1",
46+
"@commitlint/config-conventional": "^17.7.0",
47+
"@openapi-typescript-infra/coconfig": "^4.2.0",
4748
"@semantic-release/changelog": "^6.0.3",
4849
"@semantic-release/exec": "^6.0.3",
4950
"@semantic-release/git": "^10.0.1",
5051
"@types/yargs-parser": "^21.0.0",
51-
"@typescript-eslint/eslint-plugin": "^6.2.1",
52-
"@typescript-eslint/parser": "^6.2.1",
52+
"@typescript-eslint/eslint-plugin": "^6.7.2",
53+
"@typescript-eslint/parser": "^6.7.2",
5354
"coconfig": "^0.13.3",
54-
"eslint": "^8.46.0",
55-
"eslint-config-prettier": "^8.10.0",
56-
"eslint-plugin-import": "^2.28.0",
57-
"prettier": "^3.0.1",
55+
"eslint": "^8.49.0",
56+
"eslint-config-prettier": "^9.0.0",
57+
"eslint-plugin-import": "^2.28.1",
58+
"prettier": "^3.0.3",
5859
"ts-node": "^10.9.1",
59-
"typescript": "^5.1.6",
60-
"vitest": "^0.34.1"
60+
"typescript": "^5.2.2",
61+
"vitest": "^0.34.4"
6162
},
6263
"scripts": {
6364
"test": "tsc -p tsconfig.test.json --noEmit && vitest",
@@ -71,7 +72,7 @@
7172
},
7273
"dependencies": {
7374
"ansi-colors": "^4.1.3",
74-
"openapi-typescript": "6.3.9",
75+
"openapi-typescript": "6.6.1",
7576
"yargs-parser": "^21.1.1"
7677
}
7778
}

src/bin/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import glob from 'fast-glob';
77
// eslint-disable-next-line import/order -- what the actual heck, this rule bounces
88
import parser from 'yargs-parser';
99

10-
// @ts-expect-error ESM is a threat to humanity
1110
import type { OpenAPITSOptions } from 'openapi-typescript';
1211

13-
import { generate } from '../index';
12+
import { generate } from '../index.js';
1413

1514
/** print error message */
1615
export function error(msg: string) {

src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// @ts-expect-error ESM is a threat to humanity. Once OATS exposes a working CJS, use it
21
import type { OpenAPITSOptions } from 'openapi-typescript';
32

43
function getEnumTitle(path: string) {

0 commit comments

Comments
 (0)