dtsgenerator 3.19.0 → 3.19.2
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/CHANGELOG.md +157 -2
- package/README.md +11 -154
- package/dist/core/astBuilder.js +5 -3
- package/dist/core/config.d.ts +1 -3
- package/dist/core/jsonSchema.js +1 -1
- 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/type.d.ts +2 -2
- package/package.json +26 -26
- package/src/core/astBuilder.ts +17 -10
- package/src/core/config.ts +1 -3
- package/src/core/dtsGenerator.ts +5 -5
- package/src/core/jsonSchema.ts +5 -8
- package/src/core/jsonSchemaDraft04.ts +4 -13
- package/src/core/jsonSchemaDraft07.ts +6 -15
- package/src/core/openApiV2.ts +20 -48
- package/src/core/openApiV3.ts +36 -52
- package/src/core/type.ts +3 -3
- package/src/core/utils.ts +0 -1
- package/src/core/validateIdentifier.ts +4 -5
- package/src/jsonPointer.ts +0 -2
package/dist/core/openApiV3.d.ts
CHANGED
|
@@ -12,19 +12,13 @@ export declare namespace OpenApisV3 {
|
|
|
12
12
|
}
|
|
13
13
|
namespace SchemaJson {
|
|
14
14
|
namespace Definitions {
|
|
15
|
-
|
|
16
|
-
[name: string]: any;
|
|
17
|
-
}
|
|
15
|
+
type Any = Record<string, any>;
|
|
18
16
|
type AnyOrExpression = Any | Expression;
|
|
19
|
-
|
|
20
|
-
[name: string]: AnyOrExpression;
|
|
21
|
-
}
|
|
17
|
+
type AnysOrExpressions = Record<string, AnyOrExpression>;
|
|
22
18
|
interface Callback {
|
|
23
19
|
}
|
|
24
20
|
type CallbackOrReference = Callback | Reference;
|
|
25
|
-
|
|
26
|
-
[name: string]: CallbackOrReference;
|
|
27
|
-
}
|
|
21
|
+
type CallbacksOrReferences = Record<string, CallbackOrReference>;
|
|
28
22
|
interface Components {
|
|
29
23
|
schemas?: SchemasOrReferences;
|
|
30
24
|
responses?: ResponsesOrReferences;
|
|
@@ -53,9 +47,7 @@ export declare namespace OpenApisV3 {
|
|
|
53
47
|
explode?: boolean;
|
|
54
48
|
allowReserved?: boolean;
|
|
55
49
|
}
|
|
56
|
-
|
|
57
|
-
[name: string]: Encoding;
|
|
58
|
-
}
|
|
50
|
+
type Encodings = Record<string, Encoding>;
|
|
59
51
|
interface Example {
|
|
60
52
|
summary?: string;
|
|
61
53
|
description?: string;
|
|
@@ -63,12 +55,8 @@ export declare namespace OpenApisV3 {
|
|
|
63
55
|
externalValue?: string;
|
|
64
56
|
}
|
|
65
57
|
type ExampleOrReference = Example | Reference;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
interface Expression {
|
|
70
|
-
[name: string]: any;
|
|
71
|
-
}
|
|
58
|
+
type ExamplesOrReferences = Record<string, ExampleOrReference>;
|
|
59
|
+
type Expression = Record<string, any>;
|
|
72
60
|
interface ExternalDocs {
|
|
73
61
|
description?: string;
|
|
74
62
|
url: string;
|
|
@@ -87,9 +75,7 @@ export declare namespace OpenApisV3 {
|
|
|
87
75
|
content?: MediaTypes;
|
|
88
76
|
}
|
|
89
77
|
type HeaderOrReference = Header | Reference;
|
|
90
|
-
|
|
91
|
-
[name: string]: HeaderOrReference;
|
|
92
|
-
}
|
|
78
|
+
type HeadersOrReferences = Record<string, HeaderOrReference>;
|
|
93
79
|
interface Info {
|
|
94
80
|
title: string;
|
|
95
81
|
description?: string;
|
|
@@ -111,18 +97,14 @@ export declare namespace OpenApisV3 {
|
|
|
111
97
|
server?: Server;
|
|
112
98
|
}
|
|
113
99
|
type LinkOrReference = Link | Reference;
|
|
114
|
-
|
|
115
|
-
[name: string]: LinkOrReference;
|
|
116
|
-
}
|
|
100
|
+
type LinksOrReferences = Record<string, LinkOrReference>;
|
|
117
101
|
interface MediaType {
|
|
118
102
|
schema?: SchemaOrReference;
|
|
119
103
|
example?: Any;
|
|
120
104
|
examples?: ExamplesOrReferences;
|
|
121
105
|
encoding?: Encodings;
|
|
122
106
|
}
|
|
123
|
-
|
|
124
|
-
[name: string]: MediaType;
|
|
125
|
-
}
|
|
107
|
+
type MediaTypes = Record<string, MediaType>;
|
|
126
108
|
interface OauthFlow {
|
|
127
109
|
authorizationUrl?: string;
|
|
128
110
|
tokenUrl?: string;
|
|
@@ -165,9 +147,7 @@ export declare namespace OpenApisV3 {
|
|
|
165
147
|
content?: MediaTypes;
|
|
166
148
|
}
|
|
167
149
|
type ParameterOrReference = Parameter | Reference;
|
|
168
|
-
|
|
169
|
-
[name: string]: ParameterOrReference;
|
|
170
|
-
}
|
|
150
|
+
type ParametersOrReferences = Record<string, ParameterOrReference>;
|
|
171
151
|
interface PathItem {
|
|
172
152
|
$ref?: string;
|
|
173
153
|
summary?: string;
|
|
@@ -184,15 +164,11 @@ export declare namespace OpenApisV3 {
|
|
|
184
164
|
parameters?: ParameterOrReference[];
|
|
185
165
|
}
|
|
186
166
|
type PathItemOrReference = PathItem | Reference;
|
|
187
|
-
|
|
188
|
-
[name: string]: PathItemOrReference;
|
|
189
|
-
}
|
|
167
|
+
type Paths = Record<string, PathItemOrReference>;
|
|
190
168
|
interface Reference {
|
|
191
169
|
$ref: string;
|
|
192
170
|
}
|
|
193
|
-
|
|
194
|
-
[name: string]: RequestBodyOrReference;
|
|
195
|
-
}
|
|
171
|
+
type RequestBodiesOrReferences = Record<string, RequestBodyOrReference>;
|
|
196
172
|
interface RequestBody {
|
|
197
173
|
description?: string;
|
|
198
174
|
content: MediaTypes;
|
|
@@ -206,13 +182,9 @@ export declare namespace OpenApisV3 {
|
|
|
206
182
|
links?: LinksOrReferences;
|
|
207
183
|
}
|
|
208
184
|
type ResponseOrReference = Response | Reference;
|
|
209
|
-
|
|
210
|
-
[name: string]: ResponseOrReference;
|
|
211
|
-
}
|
|
185
|
+
type ResponsesOrReferences = Record<string, ResponseOrReference>;
|
|
212
186
|
type SchemaOrReference = JsonSchemaDraft07.SchemaObject | Reference;
|
|
213
|
-
|
|
214
|
-
[name: string]: SchemaOrReference;
|
|
215
|
-
}
|
|
187
|
+
type SchemasOrReferences = Record<string, SchemaOrReference>;
|
|
216
188
|
interface SecurityRequirement {
|
|
217
189
|
}
|
|
218
190
|
interface SecurityScheme {
|
|
@@ -226,9 +198,7 @@ export declare namespace OpenApisV3 {
|
|
|
226
198
|
openIdConnectUrl?: string;
|
|
227
199
|
}
|
|
228
200
|
type SecuritySchemeOrReference = SecurityScheme | Reference;
|
|
229
|
-
|
|
230
|
-
[name: string]: SecuritySchemeOrReference;
|
|
231
|
-
}
|
|
201
|
+
type SecuritySchemesOrReferences = Record<string, SecuritySchemeOrReference>;
|
|
232
202
|
interface Server {
|
|
233
203
|
url: string;
|
|
234
204
|
description?: string;
|
|
@@ -239,13 +209,9 @@ export declare namespace OpenApisV3 {
|
|
|
239
209
|
default: string;
|
|
240
210
|
description?: string;
|
|
241
211
|
}
|
|
242
|
-
|
|
243
|
-
[name: string]: ServerVariable;
|
|
244
|
-
}
|
|
212
|
+
type ServerVariables = Record<string, ServerVariable>;
|
|
245
213
|
type SpecificationExtension = null | number | boolean | string | any[];
|
|
246
|
-
|
|
247
|
-
[name: string]: string;
|
|
248
|
-
}
|
|
214
|
+
type Strings = Record<string, string>;
|
|
249
215
|
interface Tag {
|
|
250
216
|
name: string;
|
|
251
217
|
description?: string;
|
package/dist/core/type.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface PluginContext {
|
|
|
27
27
|
inputSchemas: IterableIterator<[string, Schema]>;
|
|
28
28
|
}
|
|
29
29
|
export type PreProcessHandler = (contents: Schema[]) => Schema[];
|
|
30
|
-
export
|
|
30
|
+
export interface Plugin {
|
|
31
31
|
meta: {
|
|
32
32
|
name: string;
|
|
33
33
|
version: string;
|
|
@@ -35,5 +35,5 @@ export type Plugin = {
|
|
|
35
35
|
};
|
|
36
36
|
preProcess?: (context: PluginContext) => Promise<PreProcessHandler | undefined>;
|
|
37
37
|
postProcess?: (context: PluginContext) => Promise<TransformerFactory<SourceFile> | undefined>;
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
39
|
export declare function loadPlugin(name: string, option: boolean | Record<string, unknown>): Promise<Plugin | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtsgenerator",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.2",
|
|
4
4
|
"description": "TypeScript d.ts file generator for JSON Schema file",
|
|
5
5
|
"bin": {
|
|
6
6
|
"dtsgen": "bin/dtsgen"
|
|
@@ -11,7 +11,7 @@
|
|
|
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 --fix --ext ts src/ test/",
|
|
14
|
+
"lint": "eslint --fix --report-unused-disable-directives --ext ts src/ test/",
|
|
15
15
|
"format": "prettier --cache --write 'src/**/*.ts' 'test/*.ts' 'test/core/*.ts'",
|
|
16
16
|
"precompile": "npm run lint && npm run format",
|
|
17
17
|
"prepublishOnly": "npm run build",
|
|
@@ -41,40 +41,40 @@
|
|
|
41
41
|
"url": "https://github.com/horiuchi/dtsgenerator/issues"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": ">=
|
|
44
|
+
"node": ">= 18.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"commander": "^
|
|
47
|
+
"commander": "^12.1.0",
|
|
48
48
|
"cross-fetch": "^4.0.0",
|
|
49
|
-
"debug": "^4.3.
|
|
50
|
-
"glob": "^10.
|
|
51
|
-
"http-proxy-agent": "^7.0.
|
|
52
|
-
"https-proxy-agent": "^7.0.
|
|
49
|
+
"debug": "^4.3.5",
|
|
50
|
+
"glob": "^10.4.1",
|
|
51
|
+
"http-proxy-agent": "^7.0.2",
|
|
52
|
+
"https-proxy-agent": "^7.0.4",
|
|
53
53
|
"js-yaml": "^4.1.0",
|
|
54
|
-
"tslib": "^2.6.
|
|
55
|
-
"typescript": "^5.
|
|
54
|
+
"tslib": "^2.6.3",
|
|
55
|
+
"typescript": "^5.4.5"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@dtsgenerator/do-nothing": "^2.
|
|
59
|
-
"@dtsgenerator/eslint-config": "^0.
|
|
60
|
-
"@dtsgenerator/replace-namespace": "^1.
|
|
61
|
-
"@dtsgenerator/single-quote": "^1.
|
|
58
|
+
"@dtsgenerator/do-nothing": "^2.6.0",
|
|
59
|
+
"@dtsgenerator/eslint-config": "^0.7.1",
|
|
60
|
+
"@dtsgenerator/replace-namespace": "^1.6.0",
|
|
61
|
+
"@dtsgenerator/single-quote": "^1.7.0",
|
|
62
62
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
63
|
-
"@types/debug": "^4.1.
|
|
63
|
+
"@types/debug": "^4.1.12",
|
|
64
64
|
"@types/glob": "^8.1.0",
|
|
65
|
-
"@types/js-yaml": "^4.0.
|
|
66
|
-
"@types/mocha": "^10.0.
|
|
67
|
-
"@types/node": "^
|
|
65
|
+
"@types/js-yaml": "^4.0.9",
|
|
66
|
+
"@types/mocha": "^10.0.6",
|
|
67
|
+
"@types/node": "^18.19.34",
|
|
68
68
|
"cross-env": "^7.0.3",
|
|
69
|
-
"eslint": "^8.
|
|
70
|
-
"husky": "^
|
|
71
|
-
"lint-staged": "^
|
|
72
|
-
"mocha": "^10.
|
|
73
|
-
"nyc": "^
|
|
74
|
-
"prettier": "^3.
|
|
75
|
-
"rimraf": "^5.0.
|
|
69
|
+
"eslint": "^8.56.0",
|
|
70
|
+
"husky": "^9.0.11",
|
|
71
|
+
"lint-staged": "^15.2.5",
|
|
72
|
+
"mocha": "^10.4.0",
|
|
73
|
+
"nyc": "^17.0.0",
|
|
74
|
+
"prettier": "^3.3.1",
|
|
75
|
+
"rimraf": "^5.0.7",
|
|
76
76
|
"source-map-support": "^0.5.21",
|
|
77
|
-
"ts-node": "^10.9.
|
|
77
|
+
"ts-node": "^10.9.2"
|
|
78
78
|
},
|
|
79
79
|
"lint-staged": {
|
|
80
80
|
"**/*.ts": [
|
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
|
|
@@ -553,14 +553,14 @@ export default class DtsGenerator {
|
|
|
553
553
|
const additionalItems = schema.content.additionalItems
|
|
554
554
|
? this.normalizeContent(schema, '/additionalItems')
|
|
555
555
|
: schema.content.additionalItems === false
|
|
556
|
-
|
|
557
|
-
|
|
556
|
+
? false
|
|
557
|
+
: undefined;
|
|
558
558
|
|
|
559
559
|
return additionalItems === undefined
|
|
560
560
|
? undefined
|
|
561
561
|
: additionalItems === false
|
|
562
|
-
|
|
563
|
-
|
|
562
|
+
? false
|
|
563
|
+
: this.generateTypeProperty(additionalItems, false);
|
|
564
564
|
};
|
|
565
565
|
|
|
566
566
|
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)),
|
|
@@ -347,7 +346,6 @@ export function searchAllSubSchema(
|
|
|
347
346
|
}
|
|
348
347
|
const operationId = ops.operationId;
|
|
349
348
|
if (operationId) {
|
|
350
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
351
349
|
keys = [keys[0]!, convertKeyToTypeName(operationId)];
|
|
352
350
|
}
|
|
353
351
|
setSubIdToParameters(ops.parameters, keys.concat('parameters'));
|
|
@@ -446,7 +444,6 @@ export function searchAllSubSchema(
|
|
|
446
444
|
}
|
|
447
445
|
const operationId = ops.operationId;
|
|
448
446
|
if (operationId) {
|
|
449
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
450
447
|
keys = [keys[0]!, convertKeyToTypeName(operationId)];
|
|
451
448
|
}
|
|
452
449
|
setSubIdToParameters(ops.parameters, keys.concat('parameters'));
|
|
@@ -476,7 +473,7 @@ export function searchAllSubSchema(
|
|
|
476
473
|
}
|
|
477
474
|
|
|
478
475
|
function setSubIdToObject(
|
|
479
|
-
obj:
|
|
476
|
+
obj: Record<string, JsonSchema> | undefined,
|
|
480
477
|
paths: string[],
|
|
481
478
|
): void {
|
|
482
479
|
if (obj == null) {
|
|
@@ -558,7 +555,7 @@ export function selectSchemaType(content: JsonSchema | OpenApiSchema): {
|
|
|
558
555
|
);
|
|
559
556
|
}
|
|
560
557
|
if ('$schema' in content) {
|
|
561
|
-
const schema = content
|
|
558
|
+
const schema = content.$schema ?? '';
|
|
562
559
|
if (/^https?:\/\/json-schema.org\/schema#?$/.test(schema)) {
|
|
563
560
|
return { type: 'Latest' };
|
|
564
561
|
}
|
|
@@ -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,18 +30,10 @@ 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
39
|
| Schema.Definitions.SimpleTypes
|
|
@@ -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,18 +30,10 @@ 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[];
|
|
@@ -59,7 +50,7 @@ export namespace JsonSchemaDraft07 {
|
|
|
59
50
|
anyOf?: Schema.Definitions.SchemaArray;
|
|
60
51
|
oneOf?: Schema.Definitions.SchemaArray;
|
|
61
52
|
not?: Schema;
|
|
62
|
-
}
|
|
53
|
+
}
|
|
63
54
|
export type Schema = SchemaObject | boolean;
|
|
64
55
|
export namespace Schema {
|
|
65
56
|
export namespace Definitions {
|
package/src/core/openApiV2.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
1
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
4
2
|
import { JsonSchemaDraft04 } from './jsonSchemaDraft04';
|
|
5
3
|
|
|
@@ -98,15 +96,9 @@ export namespace OpenApisV2 {
|
|
|
98
96
|
/**
|
|
99
97
|
* One or more JSON objects describing the schemas being consumed and produced by the API.
|
|
100
98
|
*/
|
|
101
|
-
export
|
|
102
|
-
[
|
|
103
|
-
name: string
|
|
104
|
-
]: /* A deterministic version of a JSON Schema object. */ Schema;
|
|
105
|
-
}
|
|
99
|
+
export type Definitions = Record<string, Schema>;
|
|
106
100
|
export type Enum = JsonSchemaDraft04.Schema.Properties.Enum;
|
|
107
|
-
export
|
|
108
|
-
[name: string]: any;
|
|
109
|
-
}
|
|
101
|
+
export type Examples = Record<string, any>;
|
|
110
102
|
export type ExclusiveMaximum =
|
|
111
103
|
JsonSchemaDraft04.Schema.Properties.ExclusiveMaximum;
|
|
112
104
|
export type ExclusiveMinimum =
|
|
@@ -232,9 +224,7 @@ export namespace OpenApisV2 {
|
|
|
232
224
|
enum?: Enum;
|
|
233
225
|
multipleOf?: MultipleOf;
|
|
234
226
|
}
|
|
235
|
-
export
|
|
236
|
-
[name: string]: Header;
|
|
237
|
-
}
|
|
227
|
+
export type Headers = Record<string, Header>;
|
|
238
228
|
/**
|
|
239
229
|
* General information about the API.
|
|
240
230
|
*/
|
|
@@ -323,9 +313,7 @@ export namespace OpenApisV2 {
|
|
|
323
313
|
tokenUrl: string; // uri
|
|
324
314
|
description?: string;
|
|
325
315
|
}
|
|
326
|
-
export
|
|
327
|
-
[name: string]: string;
|
|
328
|
-
}
|
|
316
|
+
export type Oauth2Scopes = Record<string, string>;
|
|
329
317
|
export interface Operation {
|
|
330
318
|
tags?: string[];
|
|
331
319
|
/**
|
|
@@ -359,9 +347,7 @@ export namespace OpenApisV2 {
|
|
|
359
347
|
/**
|
|
360
348
|
* One or more JSON representations for parameters
|
|
361
349
|
*/
|
|
362
|
-
export
|
|
363
|
-
[name: string]: Parameter;
|
|
364
|
-
}
|
|
350
|
+
export type ParameterDefinitions = Record<string, Parameter>;
|
|
365
351
|
/**
|
|
366
352
|
* The parameters needed to send a valid API call.
|
|
367
353
|
*/
|
|
@@ -415,9 +401,7 @@ export namespace OpenApisV2 {
|
|
|
415
401
|
/**
|
|
416
402
|
* Relative paths to the individual endpoints. They must be relative to the 'basePath'.
|
|
417
403
|
*/
|
|
418
|
-
export
|
|
419
|
-
[pattern: string]: PathItem;
|
|
420
|
-
}
|
|
404
|
+
export type Paths = Record<string, PathItem>;
|
|
421
405
|
export type Pattern =
|
|
422
406
|
JsonSchemaDraft04.Schema.Properties.Pattern /* regex */;
|
|
423
407
|
export interface PrimitivesItems {
|
|
@@ -489,18 +473,12 @@ export namespace OpenApisV2 {
|
|
|
489
473
|
/**
|
|
490
474
|
* One or more JSON representations for responses
|
|
491
475
|
*/
|
|
492
|
-
export
|
|
493
|
-
[name: string]: Response;
|
|
494
|
-
}
|
|
476
|
+
export type ResponseDefinitions = Record<string, Response>;
|
|
495
477
|
export type ResponseValue = Response | JsonReference;
|
|
496
478
|
/**
|
|
497
479
|
* Response objects names can either be any valid HTTP status code or 'default'.
|
|
498
480
|
*/
|
|
499
|
-
export
|
|
500
|
-
[
|
|
501
|
-
pattern: string
|
|
502
|
-
]: ResponseValue /* Patterns: ^([0-9]{3})$|^(default)$ | ^x- */;
|
|
503
|
-
}
|
|
481
|
+
export type Responses = Record<string, ResponseValue>;
|
|
504
482
|
/**
|
|
505
483
|
* A deterministic version of a JSON Schema object.
|
|
506
484
|
*/
|
|
@@ -538,11 +516,7 @@ export namespace OpenApisV2 {
|
|
|
538
516
|
/* A deterministic version of a JSON Schema object. */ Schema,
|
|
539
517
|
.../* A deterministic version of a JSON Schema object. */ Schema[],
|
|
540
518
|
];
|
|
541
|
-
properties?:
|
|
542
|
-
[
|
|
543
|
-
name: string
|
|
544
|
-
]: /* A deterministic version of a JSON Schema object. */ Schema;
|
|
545
|
-
};
|
|
519
|
+
properties?: Record<string, Schema>;
|
|
546
520
|
discriminator?: string;
|
|
547
521
|
readOnly?: boolean;
|
|
548
522
|
xml?: Xml;
|
|
@@ -554,18 +528,16 @@ export namespace OpenApisV2 {
|
|
|
554
528
|
*/
|
|
555
529
|
export type SchemesList = ('http' | 'https' | 'ws' | 'wss')[];
|
|
556
530
|
export type Security = SecurityRequirement[];
|
|
557
|
-
export
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
export
|
|
567
|
-
[name: string]: string[];
|
|
568
|
-
}
|
|
531
|
+
export type SecurityDefinitions = Record<
|
|
532
|
+
string,
|
|
533
|
+
| BasicAuthenticationSecurity
|
|
534
|
+
| ApiKeySecurity
|
|
535
|
+
| Oauth2ImplicitSecurity
|
|
536
|
+
| Oauth2PasswordSecurity
|
|
537
|
+
| Oauth2ApplicationSecurity
|
|
538
|
+
| Oauth2AccessCodeSecurity
|
|
539
|
+
>;
|
|
540
|
+
export type SecurityRequirement = Record<string, string[]>;
|
|
569
541
|
export interface Tag {
|
|
570
542
|
name: string;
|
|
571
543
|
description?: string;
|
|
@@ -583,5 +555,5 @@ export namespace OpenApisV2 {
|
|
|
583
555
|
}
|
|
584
556
|
}
|
|
585
557
|
}
|
|
586
|
-
|
|
558
|
+
|
|
587
559
|
export import SwaggerIo = OpenApisV2;
|