dtsgenerator 3.19.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +0 -3
- package/.nycrc +1 -1
- package/README.md +7 -1
- package/dist/commandOptions.js +4 -3
- package/dist/core/astBuilder.js +29 -28
- package/dist/core/config.d.ts +1 -3
- package/dist/core/config.js +3 -4
- package/dist/core/index.js +1 -1
- package/dist/core/jsonSchema.js +7 -8
- package/dist/core/jsonSchemaDraft04.d.ts +4 -12
- package/dist/core/jsonSchemaDraft07.d.ts +6 -14
- package/dist/core/openApiV2.d.ts +11 -33
- package/dist/core/openApiV3.d.ts +17 -51
- package/dist/core/schemaId.d.ts +0 -1
- package/dist/core/type.d.ts +2 -2
- package/dist/core/type.js +7 -8
- package/dist/core/typeTree.js +1 -2
- package/dist/core/utils.js +4 -5
- package/dist/core/validateIdentifier.js +3 -4
- package/dist/jsonPointer.js +4 -5
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +16 -18
- package/docs/dependency-modernization.md +189 -0
- package/docs/npm-trusted-publishing.md +60 -0
- package/eslint.config.cjs +24 -0
- package/package.json +31 -30
- package/src/commandOptions.ts +2 -1
- package/src/core/astBuilder.ts +17 -10
- package/src/core/config.ts +1 -3
- package/src/core/dtsGenerator.ts +5 -7
- package/src/core/jsonSchema.ts +8 -12
- package/src/core/jsonSchemaDraft04.ts +6 -17
- package/src/core/jsonSchemaDraft07.ts +7 -17
- package/src/core/openApiV2.ts +31 -60
- package/src/core/openApiV3.ts +39 -60
- package/src/core/type.ts +6 -10
- package/src/core/utils.ts +1 -1
- package/src/core/validateIdentifier.ts +4 -5
- package/src/jsonPointer.ts +0 -2
- package/src/utils.ts +11 -11
- package/tsconfig.json +1 -1
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -30
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# npm trusted publishing への移行
|
|
2
|
+
|
|
3
|
+
リリースworkflowは、npmの長期トークンを使う方式からGitHub ActionsのOIDCを使うtrusted publishingへ移行する。GitHub Actions側に`NPM_TOKEN`などの新しいsecretを追加する必要はない。Node.js 24系に同梱されるnpm 11.5.1以降を使用し、`id-token: write`権限でnpmへ短時間だけ有効な認証情報を要求する。
|
|
4
|
+
|
|
5
|
+
## npmでの設定
|
|
6
|
+
|
|
7
|
+
各パッケージのnpmページで `Settings` → `Trusted Publisher` を開き、publisherとして `GitHub Actions` を選択する。次の値を登録する。
|
|
8
|
+
|
|
9
|
+
| npmパッケージ | GitHub owner/repository | Workflow filename | Environment |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `@dtsgenerator/eslint-config` | `dtsgenerator/eslint-config` | `release.yml` | 空欄 |
|
|
12
|
+
| `@dtsgenerator/do-nothing` | `dtsgenerator/do-nothing` | `workflow-release.yaml` | 空欄 |
|
|
13
|
+
| `@dtsgenerator/replace-namespace` | `dtsgenerator/replace-namespace` | `workflow-release.yaml` | 空欄 |
|
|
14
|
+
| `@dtsgenerator/single-quote` | `dtsgenerator/single-quote` | `workflow-release.yaml` | 空欄 |
|
|
15
|
+
| `@dtsgenerator/decorate-typename` | `dtsgenerator/decorate-typename` | `workflow-release.yaml` | 空欄 |
|
|
16
|
+
| `dtsgenerator` | `horiuchi/dtsgenerator` | `workflow-release.yaml` | 空欄 |
|
|
17
|
+
| `@dtsgenerator/create` | `dtsgenerator/create` | なし(手動リリース) | 対象外 |
|
|
18
|
+
|
|
19
|
+
`create`が生成したプラグインでは、生成先の実際のGitHub owner/repositoryと`workflow-release.yaml`を登録し、Environmentは空欄にする。trusted publisherを登録できるのはnpmレジストリにすでに存在するパッケージだけなので、新規パッケージは最初にnpmへログインし、buildとtestを確認してから`npm publish --ignore-scripts`で一度だけ手動公開する。
|
|
20
|
+
|
|
21
|
+
npmのtrusted publisher設定にある `Allow direct npm publish` を明示的に有効にする。新規設定ではstage publishが既定のため、この設定が無効なままでは現在のworkflowにある`npm publish`を実行できない。
|
|
22
|
+
|
|
23
|
+
## 公開順序
|
|
24
|
+
|
|
25
|
+
1. `@dtsgenerator/eslint-config`
|
|
26
|
+
2. `@dtsgenerator/do-nothing`
|
|
27
|
+
3. `@dtsgenerator/replace-namespace`、`@dtsgenerator/single-quote`、`@dtsgenerator/decorate-typename`、`dtsgenerator`
|
|
28
|
+
4. `@dtsgenerator/create`(必要な場合は手動公開)
|
|
29
|
+
|
|
30
|
+
`@dtsgenerator/eslint-config@1.0.0`と`@dtsgenerator/do-nothing@3.0.1`は
|
|
31
|
+
2026-09-18時点で公開済みであり、両方のconsumer lockfileを公開registryの
|
|
32
|
+
artifactから更新済みである。`dtsgenerator`を公開する前提パッケージの公開と
|
|
33
|
+
lockfile更新は完了している。
|
|
34
|
+
|
|
35
|
+
## 公開後のlockfile更新
|
|
36
|
+
|
|
37
|
+
前提パッケージを公開するたびに、そのパッケージを参照するすべての
|
|
38
|
+
`package-lock.json`を公開registryの実体に合わせて更新する。registryの
|
|
39
|
+
version、dependencies、peerDependenciesが公開対象と一致することを確認する。
|
|
40
|
+
さらに`dist.tarball`を取得して実体のhashを検証し、lockfileの`resolved`と
|
|
41
|
+
`integrity`がそのartifactおよび`dist` metadataと一致することを確認する。
|
|
42
|
+
その後、作業ツリーとは別のコピーと空のnpm cacheを使って`npm ci`を実行する。
|
|
43
|
+
|
|
44
|
+
公開前の結合確認にローカルでpackしたartifactを使用しても、そのintegrityを
|
|
45
|
+
registry URLのlock entryへ転記しない。ローカルartifactをcacheへ事前投入した
|
|
46
|
+
検証は、公開registryだけを使ったinstall確認として扱わない。main lockfileの
|
|
47
|
+
`@dtsgenerator/do-nothing` entryは、公開された3.0.1のtarball URLとintegrityに
|
|
48
|
+
更新済みである。
|
|
49
|
+
|
|
50
|
+
## workflowを実行する前の注意
|
|
51
|
+
|
|
52
|
+
変更したworkflowを含むコミットを先にGitHubへpushする。失敗した古いrunを再実行しても、そのrunが参照していた古いYAMLが使われるためOIDCへの移行確認にはならない。タグで起動するworkflowでは、タグが移行済みコミットを指していることを確認してからpushする。
|
|
53
|
+
|
|
54
|
+
ローカルで確認できるのはYAMLの構文と設定内容までである。npm UIでtrusted publisherを登録した後、GitHub Actionsから実際に公開し、OIDC認証が成功することを確認する。
|
|
55
|
+
|
|
56
|
+
参考資料:
|
|
57
|
+
|
|
58
|
+
- [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/)
|
|
59
|
+
- [npm trust](https://docs.npmjs.com/cli/v11/commands/npm-trust/)
|
|
60
|
+
- [actions/setup-node advanced usage](https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const shared = require('@dtsgenerator/eslint-config');
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
...shared,
|
|
5
|
+
{ ignores: ['test/snapshots/**'] },
|
|
6
|
+
{ rules: { '@typescript-eslint/no-explicit-any': 'off' } },
|
|
7
|
+
{
|
|
8
|
+
files: ['**/*_test.ts'],
|
|
9
|
+
rules: {
|
|
10
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
11
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
12
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
13
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
14
|
+
'@typescript-eslint/no-implied-eval': 'off',
|
|
15
|
+
'@typescript-eslint/no-misused-promises': 'off',
|
|
16
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
17
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
18
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
19
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
|
20
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
21
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtsgenerator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "TypeScript d.ts file generator for JSON Schema file",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dtsgen": "bin/dtsgen"
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
"build": "tsc -p ./tsconfig-build.json",
|
|
12
12
|
"clean": "rimraf dist/ build/ {src,test}/**/*.{js,js.map} *.tsbuildinfo",
|
|
13
13
|
"compile": "tsc -p .",
|
|
14
|
-
"lint": "eslint --
|
|
15
|
-
"
|
|
14
|
+
"lint": "eslint --report-unused-disable-directives src/ test/",
|
|
15
|
+
"lint:fix": "npm run lint -- --fix",
|
|
16
|
+
"format": "prettier --check 'src/**/*.ts' 'test/*.ts' 'test/core/*.ts'",
|
|
17
|
+
"format:fix": "prettier --cache --write 'src/**/*.ts' 'test/*.ts' 'test/core/*.ts'",
|
|
16
18
|
"precompile": "npm run lint && npm run format",
|
|
17
19
|
"prepublishOnly": "npm run build",
|
|
18
20
|
"pretest": "npm run compile",
|
|
@@ -20,7 +22,7 @@
|
|
|
20
22
|
"test": "nyc npm run do-test",
|
|
21
23
|
"test:update-snapshot": "UPDATE_SNAPSHOT=1 npm run test",
|
|
22
24
|
"coverage": "nyc report --reporter=lcov",
|
|
23
|
-
"prepare": "husky
|
|
25
|
+
"prepare": "husky"
|
|
24
26
|
},
|
|
25
27
|
"directories": {
|
|
26
28
|
"test": "test/"
|
|
@@ -41,40 +43,39 @@
|
|
|
41
43
|
"url": "https://github.com/horiuchi/dtsgenerator/issues"
|
|
42
44
|
},
|
|
43
45
|
"engines": {
|
|
44
|
-
"node": ">=
|
|
46
|
+
"node": "^22.22.2 || >=24.15.0"
|
|
45
47
|
},
|
|
46
48
|
"dependencies": {
|
|
47
|
-
"commander": "^
|
|
48
|
-
"cross-fetch": "^4.
|
|
49
|
-
"debug": "^4.3
|
|
50
|
-
"glob": "^
|
|
51
|
-
"http-proxy-agent": "^
|
|
52
|
-
"https-proxy-agent": "^
|
|
53
|
-
"js-yaml": "^4.
|
|
54
|
-
"tslib": "^2.
|
|
55
|
-
"typescript": "^
|
|
49
|
+
"commander": "^15.0.0",
|
|
50
|
+
"cross-fetch": "^4.1.0",
|
|
51
|
+
"debug": "^4.4.3",
|
|
52
|
+
"glob": "^13.0.6",
|
|
53
|
+
"http-proxy-agent": "^9.1.0",
|
|
54
|
+
"https-proxy-agent": "^9.1.0",
|
|
55
|
+
"js-yaml": "^4.3.2",
|
|
56
|
+
"tslib": "^2.8.1",
|
|
57
|
+
"typescript": "^6.0.3"
|
|
56
58
|
},
|
|
57
59
|
"devDependencies": {
|
|
58
|
-
"@dtsgenerator/do-nothing": "^
|
|
59
|
-
"@dtsgenerator/eslint-config": "^0.
|
|
60
|
+
"@dtsgenerator/do-nothing": "^3.0.1",
|
|
61
|
+
"@dtsgenerator/eslint-config": "^1.0.0",
|
|
60
62
|
"@dtsgenerator/replace-namespace": "^1.6.0",
|
|
61
63
|
"@dtsgenerator/single-quote": "^1.7.0",
|
|
62
64
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
63
|
-
"@types/debug": "^4.1.
|
|
64
|
-
"@types/
|
|
65
|
-
"@types/
|
|
66
|
-
"@types/
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"rimraf": "^5.0.1",
|
|
65
|
+
"@types/debug": "^4.1.13",
|
|
66
|
+
"@types/js-yaml": "^4.0.9",
|
|
67
|
+
"@types/mocha": "^10.0.10",
|
|
68
|
+
"@types/node": "^22.20.1",
|
|
69
|
+
"cross-env": "^10.1.0",
|
|
70
|
+
"eslint": "^10.10.0",
|
|
71
|
+
"husky": "^9.1.7",
|
|
72
|
+
"lint-staged": "^17.5.0",
|
|
73
|
+
"mocha": "^12.0.0",
|
|
74
|
+
"nyc": "^18.0.0",
|
|
75
|
+
"prettier": "^3.9.6",
|
|
76
|
+
"rimraf": "^6.1.3",
|
|
76
77
|
"source-map-support": "^0.5.21",
|
|
77
|
-
"ts-node": "^10.9.
|
|
78
|
+
"ts-node": "^10.9.2"
|
|
78
79
|
},
|
|
79
80
|
"lint-staged": {
|
|
80
81
|
"**/*.ts": [
|
package/src/commandOptions.ts
CHANGED
|
@@ -40,7 +40,7 @@ function parse(options: CommandOptions, argv: string[]): commander.Command {
|
|
|
40
40
|
return memo;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment
|
|
44
44
|
const pkg: { name: string; version: string } = require('../package.json');
|
|
45
45
|
|
|
46
46
|
// <hoge> is required, [hoge] is optional
|
|
@@ -66,6 +66,7 @@ function parse(options: CommandOptions, argv: string[]): commander.Command {
|
|
|
66
66
|
'for developer mode. output loaded config and plugin details only.',
|
|
67
67
|
)
|
|
68
68
|
.option('--output-ast', 'output TypeScript AST instead of d.ts file.')
|
|
69
|
+
.allowExcessArguments(true)
|
|
69
70
|
.addHelpText(
|
|
70
71
|
'afterAll',
|
|
71
72
|
`
|
package/src/core/astBuilder.ts
CHANGED
|
@@ -48,6 +48,15 @@ export function buildStringLiteralTypeNode(s: string): ts.LiteralTypeNode {
|
|
|
48
48
|
return ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(s));
|
|
49
49
|
}
|
|
50
50
|
export function buildNumericLiteralTypeNode(n: string): ts.LiteralTypeNode {
|
|
51
|
+
if (!isNaN(parseFloat(n)) && parseFloat(n) < 0) {
|
|
52
|
+
return ts.factory.createLiteralTypeNode(
|
|
53
|
+
ts.factory.createPrefixUnaryExpression(
|
|
54
|
+
ts.SyntaxKind.MinusToken,
|
|
55
|
+
ts.factory.createNumericLiteral(Math.abs(parseFloat(n))),
|
|
56
|
+
),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
return ts.factory.createLiteralTypeNode(ts.factory.createNumericLiteral(n));
|
|
52
61
|
}
|
|
53
62
|
export function buildBooleanLiteralTypeNode(b: boolean): ts.LiteralTypeNode {
|
|
@@ -117,10 +126,9 @@ export function buildPropertySignature(
|
|
|
117
126
|
isPattern: boolean | undefined,
|
|
118
127
|
): ts.PropertySignature | ts.IndexSignatureDeclaration {
|
|
119
128
|
const modifiers = undefined;
|
|
120
|
-
const questionToken =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
: undefined;
|
|
129
|
+
const questionToken = !required?.includes(propertyName)
|
|
130
|
+
? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
|
|
131
|
+
: undefined;
|
|
124
132
|
if (isPattern) {
|
|
125
133
|
return ts.factory.createIndexSignature(
|
|
126
134
|
modifiers,
|
|
@@ -223,13 +231,12 @@ export function buildTupleTypeNode(
|
|
|
223
231
|
for (let i = 0; i < itemCount; i++) {
|
|
224
232
|
let node = typesIsArray(types)
|
|
225
233
|
? i < types.length
|
|
226
|
-
?
|
|
227
|
-
types[i]!
|
|
234
|
+
? types[i]!
|
|
228
235
|
: additionalItems !== undefined
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
236
|
+
? additionalItems === false
|
|
237
|
+
? buildNeverKeyword()
|
|
238
|
+
: additionalItems
|
|
239
|
+
: buildAnyKeyword()
|
|
233
240
|
: types;
|
|
234
241
|
if (minItems == null || i >= minItems) {
|
|
235
242
|
node = ts.factory.createOptionalTypeNode(node);
|
package/src/core/config.ts
CHANGED
package/src/core/dtsGenerator.ts
CHANGED
|
@@ -57,7 +57,7 @@ export default class DtsGenerator {
|
|
|
57
57
|
|
|
58
58
|
const postProcess = await this.getPostProcess(plugins.post);
|
|
59
59
|
const result = ts.transform(file, postProcess);
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
const transformedNodes = result.transformed[0]!;
|
|
62
62
|
|
|
63
63
|
const transformedContent = config.outputAST
|
|
@@ -263,12 +263,10 @@ export default class DtsGenerator {
|
|
|
263
263
|
): ts.DeclarationStatement {
|
|
264
264
|
const content = schema.content;
|
|
265
265
|
if (
|
|
266
|
-
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */
|
|
267
266
|
content.$ref ||
|
|
268
267
|
content.oneOf ||
|
|
269
268
|
content.anyOf ||
|
|
270
269
|
content.enum ||
|
|
271
|
-
/* eslint-enable @typescript-eslint/prefer-nullish-coalescing */
|
|
272
270
|
'const' in content ||
|
|
273
271
|
content.type !== 'object'
|
|
274
272
|
) {
|
|
@@ -553,14 +551,14 @@ export default class DtsGenerator {
|
|
|
553
551
|
const additionalItems = schema.content.additionalItems
|
|
554
552
|
? this.normalizeContent(schema, '/additionalItems')
|
|
555
553
|
: schema.content.additionalItems === false
|
|
556
|
-
|
|
557
|
-
|
|
554
|
+
? false
|
|
555
|
+
: undefined;
|
|
558
556
|
|
|
559
557
|
return additionalItems === undefined
|
|
560
558
|
? undefined
|
|
561
559
|
: additionalItems === false
|
|
562
|
-
|
|
563
|
-
|
|
560
|
+
? false
|
|
561
|
+
: this.generateTypeProperty(additionalItems, false);
|
|
564
562
|
};
|
|
565
563
|
|
|
566
564
|
if (items == null) {
|
package/src/core/jsonSchema.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
1
|
import * as JsonPointer from '../jsonPointer';
|
|
3
2
|
import { JsonSchemaDraft04 } from './jsonSchemaDraft04';
|
|
4
3
|
import { OpenApisV2 } from './openApiV2';
|
|
@@ -103,7 +102,7 @@ export function searchAllSubSchema(
|
|
|
103
102
|
});
|
|
104
103
|
};
|
|
105
104
|
const walkObject = (
|
|
106
|
-
obj:
|
|
105
|
+
obj: Record<string, JsonSchema> | undefined,
|
|
107
106
|
paths: string[],
|
|
108
107
|
parentIds: string[],
|
|
109
108
|
): void => {
|
|
@@ -202,7 +201,7 @@ export function searchAllSubSchema(
|
|
|
202
201
|
}
|
|
203
202
|
function setSubIdToAnyObject<T>(
|
|
204
203
|
f: (t: T, keys: string[]) => void,
|
|
205
|
-
obj:
|
|
204
|
+
obj: Record<string, T> | undefined,
|
|
206
205
|
keys: string[],
|
|
207
206
|
): void {
|
|
208
207
|
if (obj == null) {
|
|
@@ -297,7 +296,7 @@ export function searchAllSubSchema(
|
|
|
297
296
|
const paths = keys
|
|
298
297
|
.slice(0, keys.length - 1)
|
|
299
298
|
.concat(inType + 'Parameters');
|
|
300
|
-
const properties:
|
|
299
|
+
const properties: Record<string, JsonSchemaDraft04.Schema> = {};
|
|
301
300
|
params.forEach(([key, _]) => {
|
|
302
301
|
properties[key] = {
|
|
303
302
|
$ref: createId(keys.concat(key)),
|
|
@@ -323,8 +322,7 @@ export function searchAllSubSchema(
|
|
|
323
322
|
) => setSubIdToAnyObject(setSubIdToResponseV2, responses, keys);
|
|
324
323
|
function setSubIdToResponseV2(
|
|
325
324
|
response:
|
|
326
|
-
|
|
327
|
-
| undefined,
|
|
325
|
+
OpenApisV2.SchemaJson.Definitions.ResponseValue | undefined,
|
|
328
326
|
keys: string[],
|
|
329
327
|
): void {
|
|
330
328
|
if (response == null) {
|
|
@@ -332,10 +330,10 @@ export function searchAllSubSchema(
|
|
|
332
330
|
}
|
|
333
331
|
if ('schema' in response) {
|
|
334
332
|
const s = response.schema;
|
|
335
|
-
if (s
|
|
333
|
+
if (s?.type === 'file') {
|
|
336
334
|
return;
|
|
337
335
|
}
|
|
338
|
-
setSubId(s
|
|
336
|
+
setSubId(s, keys);
|
|
339
337
|
}
|
|
340
338
|
}
|
|
341
339
|
function setSubIdToOperationV2(
|
|
@@ -347,7 +345,6 @@ export function searchAllSubSchema(
|
|
|
347
345
|
}
|
|
348
346
|
const operationId = ops.operationId;
|
|
349
347
|
if (operationId) {
|
|
350
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
351
348
|
keys = [keys[0]!, convertKeyToTypeName(operationId)];
|
|
352
349
|
}
|
|
353
350
|
setSubIdToParameters(ops.parameters, keys.concat('parameters'));
|
|
@@ -446,7 +443,6 @@ export function searchAllSubSchema(
|
|
|
446
443
|
}
|
|
447
444
|
const operationId = ops.operationId;
|
|
448
445
|
if (operationId) {
|
|
449
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
450
446
|
keys = [keys[0]!, convertKeyToTypeName(operationId)];
|
|
451
447
|
}
|
|
452
448
|
setSubIdToParameters(ops.parameters, keys.concat('parameters'));
|
|
@@ -476,7 +472,7 @@ export function searchAllSubSchema(
|
|
|
476
472
|
}
|
|
477
473
|
|
|
478
474
|
function setSubIdToObject(
|
|
479
|
-
obj:
|
|
475
|
+
obj: Record<string, JsonSchema> | undefined,
|
|
480
476
|
paths: string[],
|
|
481
477
|
): void {
|
|
482
478
|
if (obj == null) {
|
|
@@ -558,7 +554,7 @@ export function selectSchemaType(content: JsonSchema | OpenApiSchema): {
|
|
|
558
554
|
);
|
|
559
555
|
}
|
|
560
556
|
if ('$schema' in content) {
|
|
561
|
-
const schema = content
|
|
557
|
+
const schema = content.$schema ?? '';
|
|
562
558
|
if (/^https?:\/\/json-schema.org\/schema#?$/.test(schema)) {
|
|
563
559
|
return { type: 'Latest' };
|
|
564
560
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
2
|
|
|
4
3
|
export namespace JsonSchemaDraft04 {
|
|
@@ -31,22 +30,13 @@ export namespace JsonSchemaDraft04 {
|
|
|
31
30
|
minProperties?: Schema.Definitions.PositiveIntegerDefault0;
|
|
32
31
|
required?: Schema.Definitions.StringArray;
|
|
33
32
|
additionalProperties?: boolean | Schema;
|
|
34
|
-
definitions?:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
[name: string]: Schema;
|
|
39
|
-
};
|
|
40
|
-
patternProperties?: {
|
|
41
|
-
[name: string]: Schema;
|
|
42
|
-
};
|
|
43
|
-
dependencies?: {
|
|
44
|
-
[name: string]: Schema | Schema.Definitions.StringArray;
|
|
45
|
-
};
|
|
33
|
+
definitions?: Record<string, Schema>;
|
|
34
|
+
properties?: Record<string, Schema>;
|
|
35
|
+
patternProperties?: Record<string, Schema>;
|
|
36
|
+
dependencies?: Record<string, Schema | Schema.Definitions.StringArray>;
|
|
46
37
|
enum?: any[];
|
|
47
38
|
type?:
|
|
48
|
-
| Schema.Definitions.SimpleTypes
|
|
49
|
-
| Schema.Definitions.SimpleTypes[];
|
|
39
|
+
Schema.Definitions.SimpleTypes | Schema.Definitions.SimpleTypes[];
|
|
50
40
|
format?: string;
|
|
51
41
|
allOf?: Schema.Definitions.SchemaArray;
|
|
52
42
|
anyOf?: Schema.Definitions.SchemaArray;
|
|
@@ -89,8 +79,7 @@ export namespace JsonSchemaDraft04 {
|
|
|
89
79
|
export type Required = Definitions.StringArray;
|
|
90
80
|
export type Title = string;
|
|
91
81
|
export type Type =
|
|
92
|
-
| Definitions.SimpleTypes
|
|
93
|
-
| Definitions.SimpleTypes[];
|
|
82
|
+
Definitions.SimpleTypes | Definitions.SimpleTypes[];
|
|
94
83
|
export type UniqueItems = boolean;
|
|
95
84
|
}
|
|
96
85
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
2
|
|
|
4
3
|
export namespace JsonSchemaDraft07 {
|
|
5
|
-
export
|
|
4
|
+
export interface SchemaObject {
|
|
6
5
|
$id?: string; // uri-reference
|
|
7
6
|
$schema?: string; // uri
|
|
8
7
|
$ref?: string; // uri-reference
|
|
@@ -31,24 +30,15 @@ export namespace JsonSchemaDraft07 {
|
|
|
31
30
|
minProperties?: Schema.Definitions.NonNegativeIntegerDefault0;
|
|
32
31
|
required?: Schema.Definitions.StringArray;
|
|
33
32
|
additionalProperties?: Schema;
|
|
34
|
-
definitions?:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
[name: string]: Schema;
|
|
39
|
-
};
|
|
40
|
-
patternProperties?: {
|
|
41
|
-
[name: string]: Schema;
|
|
42
|
-
};
|
|
43
|
-
dependencies?: {
|
|
44
|
-
[name: string]: Schema | Schema.Definitions.StringArray;
|
|
45
|
-
};
|
|
33
|
+
definitions?: Record<string, Schema>;
|
|
34
|
+
properties?: Record<string, Schema>;
|
|
35
|
+
patternProperties?: Record<string, Schema>;
|
|
36
|
+
dependencies?: Record<string, Schema | Schema.Definitions.StringArray>;
|
|
46
37
|
propertyNames?: Schema;
|
|
47
38
|
const?: any;
|
|
48
39
|
enum?: any[];
|
|
49
40
|
type?:
|
|
50
|
-
| Schema.Definitions.SimpleTypes
|
|
51
|
-
| Schema.Definitions.SimpleTypes[];
|
|
41
|
+
Schema.Definitions.SimpleTypes | Schema.Definitions.SimpleTypes[];
|
|
52
42
|
format?: string;
|
|
53
43
|
contentMediaType?: string;
|
|
54
44
|
contentEncoding?: string;
|
|
@@ -59,7 +49,7 @@ export namespace JsonSchemaDraft07 {
|
|
|
59
49
|
anyOf?: Schema.Definitions.SchemaArray;
|
|
60
50
|
oneOf?: Schema.Definitions.SchemaArray;
|
|
61
51
|
not?: Schema;
|
|
62
|
-
}
|
|
52
|
+
}
|
|
63
53
|
export type Schema = SchemaObject | boolean;
|
|
64
54
|
export namespace Schema {
|
|
65
55
|
export namespace Definitions {
|