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.
Files changed (43) hide show
  1. package/.husky/pre-commit +0 -3
  2. package/.nycrc +1 -1
  3. package/README.md +7 -1
  4. package/dist/commandOptions.js +4 -3
  5. package/dist/core/astBuilder.js +29 -28
  6. package/dist/core/config.d.ts +1 -3
  7. package/dist/core/config.js +3 -4
  8. package/dist/core/index.js +1 -1
  9. package/dist/core/jsonSchema.js +7 -8
  10. package/dist/core/jsonSchemaDraft04.d.ts +4 -12
  11. package/dist/core/jsonSchemaDraft07.d.ts +6 -14
  12. package/dist/core/openApiV2.d.ts +11 -33
  13. package/dist/core/openApiV3.d.ts +17 -51
  14. package/dist/core/schemaId.d.ts +0 -1
  15. package/dist/core/type.d.ts +2 -2
  16. package/dist/core/type.js +7 -8
  17. package/dist/core/typeTree.js +1 -2
  18. package/dist/core/utils.js +4 -5
  19. package/dist/core/validateIdentifier.js +3 -4
  20. package/dist/jsonPointer.js +4 -5
  21. package/dist/utils.d.ts +0 -2
  22. package/dist/utils.js +16 -18
  23. package/docs/dependency-modernization.md +189 -0
  24. package/docs/npm-trusted-publishing.md +60 -0
  25. package/eslint.config.cjs +24 -0
  26. package/package.json +31 -30
  27. package/src/commandOptions.ts +2 -1
  28. package/src/core/astBuilder.ts +17 -10
  29. package/src/core/config.ts +1 -3
  30. package/src/core/dtsGenerator.ts +5 -7
  31. package/src/core/jsonSchema.ts +8 -12
  32. package/src/core/jsonSchemaDraft04.ts +6 -17
  33. package/src/core/jsonSchemaDraft07.ts +7 -17
  34. package/src/core/openApiV2.ts +31 -60
  35. package/src/core/openApiV3.ts +39 -60
  36. package/src/core/type.ts +6 -10
  37. package/src/core/utils.ts +1 -1
  38. package/src/core/validateIdentifier.ts +4 -5
  39. package/src/jsonPointer.ts +0 -2
  40. package/src/utils.ts +11 -11
  41. package/tsconfig.json +1 -1
  42. package/.eslintignore +0 -1
  43. package/.eslintrc.json +0 -30
package/.husky/pre-commit CHANGED
@@ -1,4 +1 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
1
  npx lint-staged
package/.nycrc CHANGED
@@ -4,10 +4,10 @@
4
4
  "check-coverage": true,
5
5
  "exclude": [
6
6
  "**/*.js",
7
+ "**/*.cjs",
7
8
  "coverage/**",
8
9
  "node_modules/**",
9
10
  "**/*.d.ts",
10
11
  "**/*_test.ts"
11
12
  ]
12
13
  }
13
-
package/README.md CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  TypeScript d.ts file generator from JSON Schema file or OpenAPI(Swagger) spec file.
4
4
 
5
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/horiuchi/dtsgenerator)
5
6
  [![nodejs version](https://img.shields.io/node/v/dtsgenerator.svg)](#)
6
7
  [![npm version](https://badge.fury.io/js/dtsgenerator.svg)](https://www.npmjs.com/package/dtsgenerator)
7
8
  [![Build Status](https://github.com/horiuchi/dtsgenerator/actions/workflows/workflow-ci.yaml/badge.svg)](https://github.com/horiuchi/dtsgenerator/actions/workflows/workflow-ci.yaml)
8
9
  [![Coverage Status](https://coveralls.io/repos/github/horiuchi/dtsgenerator/badge.svg?branch=master)](https://coveralls.io/github/horiuchi/dtsgenerator?branch=master)
9
10
  [![npm download count](https://img.shields.io/npm/dt/dtsgenerator.svg)](https://www.npmjs.com/package/dtsgenerator)
10
- [![Stake to support us](https://badge.devprotocol.xyz/0x68c824db5A1634940BB838468Ff2aee2bDa5794B/descriptive)](https://stakes.social/0x68c824db5A1634940BB838468Ff2aee2bDa5794B)
11
+ <!-- [![Stake to support us](https://badge.devprotocol.xyz/0x68c824db5A1634940BB838468Ff2aee2bDa5794B/descriptive)](https://stakes.social/0x68c824db5A1634940BB838468Ff2aee2bDa5794B) -->
11
12
  [![MIT license](https://img.shields.io/npm/l/dtsgenerator.svg)](#)
12
13
 
13
14
  ## Table of Contents
@@ -143,6 +144,11 @@ Output debug message by [debug](https://www.npmjs.com/package/debug) library.
143
144
 
144
145
  ## ChangeLog
145
146
 
147
+ ### [v3.19.2](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.19.2) (2024-06-11)
148
+
149
+ - fixed:
150
+ - Support a negative number by #566. Thank you @maximebiloe :+1:
151
+
146
152
  ### [v3.19.1](https://github.com/horiuchi/dtsgenerator/releases/tag/v3.19.1) (2023-08-25)
147
153
 
148
154
  - features:
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clear = exports.initialize = exports.CommandOptions = exports.defaultConfigFile = void 0;
3
+ exports.CommandOptions = exports.defaultConfigFile = void 0;
4
+ exports.initialize = initialize;
5
+ exports.clear = clear;
4
6
  const tslib_1 = require("tslib");
5
7
  const commander = tslib_1.__importStar(require("commander"));
6
8
  exports.defaultConfigFile = 'dtsgen.json';
@@ -17,7 +19,6 @@ exports.default = opts;
17
19
  function initialize(argv) {
18
20
  return parse(opts, argv);
19
21
  }
20
- exports.initialize = initialize;
21
22
  function clear() {
22
23
  opts.configFile = undefined;
23
24
  opts.files = [];
@@ -28,7 +29,6 @@ function clear() {
28
29
  opts.info = undefined;
29
30
  opts.outputAST = undefined;
30
31
  }
31
- exports.clear = clear;
32
32
  function parse(options, argv) {
33
33
  const program = new commander.Command();
34
34
  function collectUrl(val, memo) {
@@ -47,6 +47,7 @@ function parse(options, argv) {
47
47
  .option('-t, --target <version>', "Specify ECMAScript target version: 'ES3', 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT' (default).")
48
48
  .option('--info', 'for developer mode. output loaded config and plugin details only.')
49
49
  .option('--output-ast', 'output TypeScript AST instead of d.ts file.')
50
+ .allowExcessArguments(true)
50
51
  .addHelpText('afterAll', `
51
52
  Examples:
52
53
  $ dtsgen --help
@@ -1,6 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addOptionalInformation = exports.addComment = exports.buildTypeReferenceNode = exports.buildTupleTypeNode = exports.buildIntersectionTypeNode = exports.buildUnionTypeNode = exports.buildFreeFormObjectTypeLiteralNode = exports.buildTypeLiteralNode = exports.buildIndexSignatureNode = exports.buildPropertySignature = exports.buildTypeAliasNode = exports.buildInterfaceNode = exports.buildNamespaceNode = exports.buildBooleanLiteralTypeNode = exports.buildNumericLiteralTypeNode = exports.buildStringLiteralTypeNode = exports.buildNullKeyword = exports.buildSimpleArrayNode = exports.buildStringKeyword = exports.buildVoidKeyword = exports.buildUnknownKeyword = exports.buildNeverKeyword = exports.buildAnyKeyword = exports.buildKeyword = void 0;
3
+ exports.buildKeyword = buildKeyword;
4
+ exports.buildAnyKeyword = buildAnyKeyword;
5
+ exports.buildNeverKeyword = buildNeverKeyword;
6
+ exports.buildUnknownKeyword = buildUnknownKeyword;
7
+ exports.buildVoidKeyword = buildVoidKeyword;
8
+ exports.buildStringKeyword = buildStringKeyword;
9
+ exports.buildSimpleArrayNode = buildSimpleArrayNode;
10
+ exports.buildNullKeyword = buildNullKeyword;
11
+ exports.buildStringLiteralTypeNode = buildStringLiteralTypeNode;
12
+ exports.buildNumericLiteralTypeNode = buildNumericLiteralTypeNode;
13
+ exports.buildBooleanLiteralTypeNode = buildBooleanLiteralTypeNode;
14
+ exports.buildNamespaceNode = buildNamespaceNode;
15
+ exports.buildInterfaceNode = buildInterfaceNode;
16
+ exports.buildTypeAliasNode = buildTypeAliasNode;
17
+ exports.buildPropertySignature = buildPropertySignature;
18
+ exports.buildIndexSignatureNode = buildIndexSignatureNode;
19
+ exports.buildTypeLiteralNode = buildTypeLiteralNode;
20
+ exports.buildFreeFormObjectTypeLiteralNode = buildFreeFormObjectTypeLiteralNode;
21
+ exports.buildUnionTypeNode = buildUnionTypeNode;
22
+ exports.buildIntersectionTypeNode = buildIntersectionTypeNode;
23
+ exports.buildTupleTypeNode = buildTupleTypeNode;
24
+ exports.buildTypeReferenceNode = buildTypeReferenceNode;
25
+ exports.addComment = addComment;
26
+ exports.addOptionalInformation = addOptionalInformation;
4
27
  const tslib_1 = require("tslib");
5
28
  const ts = tslib_1.__importStar(require("typescript"));
6
29
  const config_1 = tslib_1.__importDefault(require("./config"));
@@ -19,47 +42,39 @@ function buildPropertyNameIdentifier(name) {
19
42
  function buildKeyword(kind) {
20
43
  return ts.factory.createKeywordTypeNode(kind);
21
44
  }
22
- exports.buildKeyword = buildKeyword;
23
45
  function buildAnyKeyword() {
24
46
  return buildKeyword(ts.SyntaxKind.AnyKeyword);
25
47
  }
26
- exports.buildAnyKeyword = buildAnyKeyword;
27
48
  function buildNeverKeyword() {
28
49
  return buildKeyword(ts.SyntaxKind.NeverKeyword);
29
50
  }
30
- exports.buildNeverKeyword = buildNeverKeyword;
31
51
  function buildUnknownKeyword() {
32
52
  return buildKeyword(ts.SyntaxKind.UnknownKeyword);
33
53
  }
34
- exports.buildUnknownKeyword = buildUnknownKeyword;
35
54
  function buildVoidKeyword() {
36
55
  return buildKeyword(ts.SyntaxKind.VoidKeyword);
37
56
  }
38
- exports.buildVoidKeyword = buildVoidKeyword;
39
57
  function buildStringKeyword() {
40
58
  return buildKeyword(ts.SyntaxKind.StringKeyword);
41
59
  }
42
- exports.buildStringKeyword = buildStringKeyword;
43
60
  function buildSimpleArrayNode(element) {
44
61
  return ts.factory.createArrayTypeNode(element);
45
62
  }
46
- exports.buildSimpleArrayNode = buildSimpleArrayNode;
47
63
  function buildNullKeyword() {
48
64
  return ts.factory.createLiteralTypeNode(ts.factory.createToken(ts.SyntaxKind.NullKeyword));
49
65
  }
50
- exports.buildNullKeyword = buildNullKeyword;
51
66
  function buildStringLiteralTypeNode(s) {
52
67
  return ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(s));
53
68
  }
54
- exports.buildStringLiteralTypeNode = buildStringLiteralTypeNode;
55
69
  function buildNumericLiteralTypeNode(n) {
70
+ if (!isNaN(parseFloat(n)) && parseFloat(n) < 0) {
71
+ return ts.factory.createLiteralTypeNode(ts.factory.createPrefixUnaryExpression(ts.SyntaxKind.MinusToken, ts.factory.createNumericLiteral(Math.abs(parseFloat(n)))));
72
+ }
56
73
  return ts.factory.createLiteralTypeNode(ts.factory.createNumericLiteral(n));
57
74
  }
58
- exports.buildNumericLiteralTypeNode = buildNumericLiteralTypeNode;
59
75
  function buildBooleanLiteralTypeNode(b) {
60
76
  return ts.factory.createLiteralTypeNode(b ? ts.factory.createTrue() : ts.factory.createFalse());
61
77
  }
62
- exports.buildBooleanLiteralTypeNode = buildBooleanLiteralTypeNode;
63
78
  function buildNamespaceNode(name, statements, root) {
64
79
  const modifiers = root
65
80
  ? [ts.factory.createModifier(ts.SyntaxKind.DeclareKeyword)]
@@ -68,7 +83,6 @@ function buildNamespaceNode(name, statements, root) {
68
83
  ts.NodeFlags.ExportContext |
69
84
  ts.NodeFlags.ContextFlags);
70
85
  }
71
- exports.buildNamespaceNode = buildNamespaceNode;
72
86
  function buildInterfaceNode(id, members, root) {
73
87
  const name = getLastTypeName(id);
74
88
  const modifiers = root
@@ -76,7 +90,6 @@ function buildInterfaceNode(id, members, root) {
76
90
  : [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)];
77
91
  return ts.factory.createInterfaceDeclaration(modifiers, buildTypeNameIdentifier(name), undefined, undefined, members);
78
92
  }
79
- exports.buildInterfaceNode = buildInterfaceNode;
80
93
  function buildTypeAliasNode(id, type, root) {
81
94
  const name = getLastTypeName(id);
82
95
  const modifiers = root
@@ -84,10 +97,9 @@ function buildTypeAliasNode(id, type, root) {
84
97
  : [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)];
85
98
  return ts.factory.createTypeAliasDeclaration(modifiers, buildTypeNameIdentifier(name), undefined, type);
86
99
  }
87
- exports.buildTypeAliasNode = buildTypeAliasNode;
88
100
  function buildPropertySignature(_schema, propertyName, valueType, required, isPattern) {
89
101
  const modifiers = undefined;
90
- const questionToken = required == null || !required.includes(propertyName)
102
+ const questionToken = !(required === null || required === void 0 ? void 0 : required.includes(propertyName))
91
103
  ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
92
104
  : undefined;
93
105
  if (isPattern) {
@@ -97,23 +109,19 @@ function buildPropertySignature(_schema, propertyName, valueType, required, isPa
97
109
  }
98
110
  return ts.factory.createPropertySignature(modifiers, buildPropertyNameIdentifier(propertyName), questionToken, valueType);
99
111
  }
100
- exports.buildPropertySignature = buildPropertySignature;
101
112
  function buildIndexSignatureNode(name, indexType, valueType) {
102
113
  return ts.factory.createIndexSignature(undefined, [
103
114
  ts.factory.createParameterDeclaration(undefined, undefined, buildTypeNameIdentifier(name), undefined, indexType, undefined),
104
115
  ], valueType);
105
116
  }
106
- exports.buildIndexSignatureNode = buildIndexSignatureNode;
107
117
  function buildTypeLiteralNode(elements) {
108
118
  return ts.factory.createTypeLiteralNode(elements);
109
119
  }
110
- exports.buildTypeLiteralNode = buildTypeLiteralNode;
111
120
  function buildFreeFormObjectTypeLiteralNode() {
112
121
  return ts.factory.createTypeLiteralNode([
113
122
  buildIndexSignatureNode('key', buildStringKeyword(), buildAnyKeyword()),
114
123
  ]);
115
124
  }
116
- exports.buildFreeFormObjectTypeLiteralNode = buildFreeFormObjectTypeLiteralNode;
117
125
  function buildUnionTypeNode(types, builder, terminate) {
118
126
  const node = ts.factory.createUnionTypeNode(types.map(builder));
119
127
  if (terminate) {
@@ -121,7 +129,6 @@ function buildUnionTypeNode(types, builder, terminate) {
121
129
  }
122
130
  return ts.factory.createParenthesizedType(node);
123
131
  }
124
- exports.buildUnionTypeNode = buildUnionTypeNode;
125
132
  function buildIntersectionTypeNode(types, terminate) {
126
133
  const node = ts.factory.createIntersectionTypeNode(types);
127
134
  if (terminate) {
@@ -129,7 +136,6 @@ function buildIntersectionTypeNode(types, terminate) {
129
136
  }
130
137
  return ts.factory.createParenthesizedType(node);
131
138
  }
132
- exports.buildIntersectionTypeNode = buildIntersectionTypeNode;
133
139
  function buildTupleTypeNode(types, minItems, maxItems, additionalItems) {
134
140
  function typesIsArray(types) {
135
141
  return Array.isArray(types);
@@ -147,8 +153,7 @@ function buildTupleTypeNode(types, minItems, maxItems, additionalItems) {
147
153
  for (let i = 0; i < itemCount; i++) {
148
154
  let node = typesIsArray(types)
149
155
  ? i < types.length
150
- ?
151
- types[i]
156
+ ? types[i]
152
157
  : additionalItems !== undefined
153
158
  ? additionalItems === false
154
159
  ? buildNeverKeyword()
@@ -170,7 +175,6 @@ function buildTupleTypeNode(types, minItems, maxItems, additionalItems) {
170
175
  }
171
176
  return ts.factory.createTupleTypeNode(nodes);
172
177
  }
173
- exports.buildTupleTypeNode = buildTupleTypeNode;
174
178
  function buildTypeReferenceNode(schema, currentSchema) {
175
179
  const typeName = getTypename(schema.id, currentSchema);
176
180
  let node;
@@ -187,7 +191,6 @@ function buildTypeReferenceNode(schema, currentSchema) {
187
191
  }
188
192
  return ts.factory.createTypeReferenceNode(node, undefined);
189
193
  }
190
- exports.buildTypeReferenceNode = buildTypeReferenceNode;
191
194
  function getTypename(id, baseSchema) {
192
195
  const result = id.toNames();
193
196
  const baseId = baseSchema.id;
@@ -223,7 +226,6 @@ function addComment(node, schema, terminate) {
223
226
  return ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, result, true);
224
227
  }
225
228
  }
226
- exports.addComment = addComment;
227
229
  function getComment(schema) {
228
230
  const content = schema.content;
229
231
  let comments = [];
@@ -279,7 +281,6 @@ function addOptionalInformation(node, schema, terminate) {
279
281
  : ts.SyntaxKind.MultiLineCommentTrivia;
280
282
  return ts.addSyntheticTrailingComment(node, kind, comment, false);
281
283
  }
282
- exports.addOptionalInformation = addOptionalInformation;
283
284
  function getLastTypeName(id) {
284
285
  var _a;
285
286
  const names = id.toNames();
@@ -5,9 +5,7 @@ export interface Config {
5
5
  outputFile?: string;
6
6
  target: ScriptTarget;
7
7
  outputAST: boolean;
8
- plugins: {
9
- [pluginName: string]: boolean | Record<string, unknown>;
10
- };
8
+ plugins: Record<string, boolean | Record<string, unknown>>;
11
9
  }
12
10
  interface InputConfig {
13
11
  files: string[];
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.showConfig = exports.clearToDefault = exports.setConfig = void 0;
3
+ exports.setConfig = setConfig;
4
+ exports.clearToDefault = clearToDefault;
5
+ exports.showConfig = showConfig;
4
6
  const typescript_1 = require("typescript");
5
7
  const type_1 = require("./type");
6
8
  const defaultConfig = {
@@ -19,11 +21,9 @@ let config = Object.assign({}, defaultConfig);
19
21
  function setConfig(input) {
20
22
  config = Object.assign(config, input);
21
23
  }
22
- exports.setConfig = setConfig;
23
24
  function clearToDefault() {
24
25
  setConfig(defaultConfig);
25
26
  }
26
- exports.clearToDefault = clearToDefault;
27
27
  async function showConfig(version, c) {
28
28
  var _a, _b, _c;
29
29
  console.log('Version: ' + version);
@@ -65,7 +65,6 @@ async function showConfig(version, c) {
65
65
  }
66
66
  console.log();
67
67
  }
68
- exports.showConfig = showConfig;
69
68
  function showScriptTarget(target) {
70
69
  switch (target) {
71
70
  case typescript_1.ScriptTarget.ES3:
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SchemaId = void 0;
4
+ exports.default = dtsGenerator;
4
5
  const tslib_1 = require("tslib");
5
6
  const config_1 = require("./config");
6
7
  const dtsGenerator_1 = tslib_1.__importDefault(require("./dtsGenerator"));
@@ -14,4 +15,3 @@ async function dtsGenerator(options) {
14
15
  const generator = new dtsGenerator_1.default(options.contents);
15
16
  return await generator.generate();
16
17
  }
17
- exports.default = dtsGenerator;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.selectSchemaType = exports.searchAllSubSchema = exports.setId = exports.getId = exports.getSubSchema = void 0;
3
+ exports.getSubSchema = getSubSchema;
4
+ exports.getId = getId;
5
+ exports.setId = setId;
6
+ exports.searchAllSubSchema = searchAllSubSchema;
7
+ exports.selectSchemaType = selectSchemaType;
4
8
  const tslib_1 = require("tslib");
5
9
  const JsonPointer = tslib_1.__importStar(require("../jsonPointer"));
6
10
  const schemaId_1 = tslib_1.__importDefault(require("./schemaId"));
@@ -32,7 +36,6 @@ function getSubSchema(rootSchema, pointer, id) {
32
36
  rootSchema,
33
37
  };
34
38
  }
35
- exports.getSubSchema = getSubSchema;
36
39
  const Draft04Id = 'id';
37
40
  const Draft07Id = '$id';
38
41
  function getId(type, content) {
@@ -44,7 +47,6 @@ function getId(type, content) {
44
47
  return (_b = content[Draft07Id]) !== null && _b !== void 0 ? _b : '';
45
48
  }
46
49
  }
47
- exports.getId = getId;
48
50
  function setId(type, content, id) {
49
51
  var _a, _b;
50
52
  if ((0, type_1.isJsonSchemaDraft04)(content, type)) {
@@ -54,7 +56,6 @@ function setId(type, content, id) {
54
56
  (_b = content[Draft07Id]) !== null && _b !== void 0 ? _b : (content[Draft07Id] = id);
55
57
  }
56
58
  }
57
- exports.setId = setId;
58
59
  function searchAllSubSchema(schema, onFoundSchema, onFoundReference) {
59
60
  const walkArray = (array, paths, parentIds) => {
60
61
  if (array == null) {
@@ -226,7 +227,7 @@ function searchAllSubSchema(schema, onFoundSchema, onFoundReference) {
226
227
  }
227
228
  if ('schema' in response) {
228
229
  const s = response.schema;
229
- if (s != null && s.type === 'file') {
230
+ if ((s === null || s === void 0 ? void 0 : s.type) === 'file') {
230
231
  return;
231
232
  }
232
233
  setSubId(s, keys);
@@ -385,7 +386,6 @@ function searchAllSubSchema(schema, onFoundSchema, onFoundReference) {
385
386
  }
386
387
  walk(schema.content, ['#'], []);
387
388
  }
388
- exports.searchAllSubSchema = searchAllSubSchema;
389
389
  function selectSchemaType(content) {
390
390
  var _a;
391
391
  if (typeof content === 'boolean') {
@@ -395,7 +395,7 @@ function selectSchemaType(content) {
395
395
  throw new Error(`expect parameter of type object, received ${typeof content}`);
396
396
  }
397
397
  if ('$schema' in content) {
398
- const schema = (_a = content['$schema']) !== null && _a !== void 0 ? _a : '';
398
+ const schema = (_a = content.$schema) !== null && _a !== void 0 ? _a : '';
399
399
  if (/^https?:\/\/json-schema.org\/schema#?$/.test(schema)) {
400
400
  return { type: 'Latest' };
401
401
  }
@@ -435,4 +435,3 @@ function selectSchemaType(content) {
435
435
  }
436
436
  return { type: 'Draft04' };
437
437
  }
438
- exports.selectSchemaType = selectSchemaType;
@@ -25,18 +25,10 @@ export declare namespace JsonSchemaDraft04 {
25
25
  minProperties?: Schema.Definitions.PositiveIntegerDefault0;
26
26
  required?: Schema.Definitions.StringArray;
27
27
  additionalProperties?: boolean | Schema;
28
- definitions?: {
29
- [name: string]: Schema;
30
- };
31
- properties?: {
32
- [name: string]: Schema;
33
- };
34
- patternProperties?: {
35
- [name: string]: Schema;
36
- };
37
- dependencies?: {
38
- [name: string]: Schema | Schema.Definitions.StringArray;
39
- };
28
+ definitions?: Record<string, Schema>;
29
+ properties?: Record<string, Schema>;
30
+ patternProperties?: Record<string, Schema>;
31
+ dependencies?: Record<string, Schema | Schema.Definitions.StringArray>;
40
32
  enum?: any[];
41
33
  type?: Schema.Definitions.SimpleTypes | Schema.Definitions.SimpleTypes[];
42
34
  format?: string;
@@ -1,5 +1,5 @@
1
1
  export declare namespace JsonSchemaDraft07 {
2
- type SchemaObject = {
2
+ interface SchemaObject {
3
3
  $id?: string;
4
4
  $schema?: string;
5
5
  $ref?: string;
@@ -28,18 +28,10 @@ export declare namespace JsonSchemaDraft07 {
28
28
  minProperties?: Schema.Definitions.NonNegativeIntegerDefault0;
29
29
  required?: Schema.Definitions.StringArray;
30
30
  additionalProperties?: Schema;
31
- definitions?: {
32
- [name: string]: Schema;
33
- };
34
- properties?: {
35
- [name: string]: Schema;
36
- };
37
- patternProperties?: {
38
- [name: string]: Schema;
39
- };
40
- dependencies?: {
41
- [name: string]: Schema | Schema.Definitions.StringArray;
42
- };
31
+ definitions?: Record<string, Schema>;
32
+ properties?: Record<string, Schema>;
33
+ patternProperties?: Record<string, Schema>;
34
+ dependencies?: Record<string, Schema | Schema.Definitions.StringArray>;
43
35
  propertyNames?: Schema;
44
36
  const?: any;
45
37
  enum?: any[];
@@ -54,7 +46,7 @@ export declare namespace JsonSchemaDraft07 {
54
46
  anyOf?: Schema.Definitions.SchemaArray;
55
47
  oneOf?: Schema.Definitions.SchemaArray;
56
48
  not?: Schema;
57
- };
49
+ }
58
50
  type Schema = SchemaObject | boolean;
59
51
  namespace Schema {
60
52
  namespace Definitions {
@@ -44,13 +44,9 @@ export declare namespace OpenApisV2 {
44
44
  email?: string;
45
45
  }
46
46
  type Default = JsonSchemaDraft04.Schema.Properties.Default;
47
- interface Definitions {
48
- [name: string]: Schema;
49
- }
47
+ type Definitions = Record<string, Schema>;
50
48
  type Enum = JsonSchemaDraft04.Schema.Properties.Enum;
51
- interface Examples {
52
- [name: string]: any;
53
- }
49
+ type Examples = Record<string, any>;
54
50
  type ExclusiveMaximum = JsonSchemaDraft04.Schema.Properties.ExclusiveMaximum;
55
51
  type ExclusiveMinimum = JsonSchemaDraft04.Schema.Properties.ExclusiveMinimum;
56
52
  interface ExternalDocs {
@@ -135,9 +131,7 @@ export declare namespace OpenApisV2 {
135
131
  enum?: Enum;
136
132
  multipleOf?: MultipleOf;
137
133
  }
138
- interface Headers {
139
- [name: string]: Header;
140
- }
134
+ type Headers = Record<string, Header>;
141
135
  interface Info {
142
136
  title: string;
143
137
  version: string;
@@ -192,9 +186,7 @@ export declare namespace OpenApisV2 {
192
186
  tokenUrl: string;
193
187
  description?: string;
194
188
  }
195
- interface Oauth2Scopes {
196
- [name: string]: string;
197
- }
189
+ type Oauth2Scopes = Record<string, string>;
198
190
  interface Operation {
199
191
  tags?: string[];
200
192
  summary?: string;
@@ -210,9 +202,7 @@ export declare namespace OpenApisV2 {
210
202
  security?: Security;
211
203
  }
212
204
  type Parameter = BodyParameter | NonBodyParameter;
213
- interface ParameterDefinitions {
214
- [name: string]: Parameter;
215
- }
205
+ type ParameterDefinitions = Record<string, Parameter>;
216
206
  type ParametersList = (Parameter | JsonReference)[];
217
207
  interface PathItem {
218
208
  $ref?: string;
@@ -248,9 +238,7 @@ export declare namespace OpenApisV2 {
248
238
  enum?: Enum;
249
239
  multipleOf?: MultipleOf;
250
240
  }
251
- interface Paths {
252
- [pattern: string]: PathItem;
253
- }
241
+ type Paths = Record<string, PathItem>;
254
242
  type Pattern = JsonSchemaDraft04.Schema.Properties.Pattern;
255
243
  interface PrimitivesItems {
256
244
  type?: 'string' | 'number' | 'integer' | 'boolean' | 'array';
@@ -301,13 +289,9 @@ export declare namespace OpenApisV2 {
301
289
  headers?: Headers;
302
290
  examples?: Examples;
303
291
  }
304
- interface ResponseDefinitions {
305
- [name: string]: Response;
306
- }
292
+ type ResponseDefinitions = Record<string, Response>;
307
293
  type ResponseValue = Response | JsonReference;
308
- interface Responses {
309
- [pattern: string]: ResponseValue;
310
- }
294
+ type Responses = Record<string, ResponseValue>;
311
295
  interface Schema {
312
296
  $ref?: string;
313
297
  format?: string;
@@ -339,9 +323,7 @@ export declare namespace OpenApisV2 {
339
323
  Schema,
340
324
  ...Schema[]
341
325
  ];
342
- properties?: {
343
- [name: string]: Schema;
344
- };
326
+ properties?: Record<string, Schema>;
345
327
  discriminator?: string;
346
328
  readOnly?: boolean;
347
329
  xml?: Xml;
@@ -350,12 +332,8 @@ export declare namespace OpenApisV2 {
350
332
  }
351
333
  type SchemesList = ('http' | 'https' | 'ws' | 'wss')[];
352
334
  type Security = SecurityRequirement[];
353
- interface SecurityDefinitions {
354
- [name: string]: BasicAuthenticationSecurity | ApiKeySecurity | Oauth2ImplicitSecurity | Oauth2PasswordSecurity | Oauth2ApplicationSecurity | Oauth2AccessCodeSecurity;
355
- }
356
- interface SecurityRequirement {
357
- [name: string]: string[];
358
- }
335
+ type SecurityDefinitions = Record<string, BasicAuthenticationSecurity | ApiKeySecurity | Oauth2ImplicitSecurity | Oauth2PasswordSecurity | Oauth2ApplicationSecurity | Oauth2AccessCodeSecurity>;
336
+ type SecurityRequirement = Record<string, string[]>;
359
337
  interface Tag {
360
338
  name: string;
361
339
  description?: string;