@redocly/openapi-core 1.0.0-beta.77 → 1.0.0-beta.81
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/__tests__/utils.ts +11 -1
- package/lib/bundle.d.ts +3 -1
- package/lib/bundle.js +30 -8
- package/lib/config/builtIn.js +18 -4
- package/lib/config/config.d.ts +2 -9
- package/lib/{rules → decorators}/common/info-description-override.d.ts +0 -0
- package/lib/{rules → decorators}/common/info-description-override.js +0 -0
- package/lib/{rules → decorators}/common/operation-description-override.d.ts +0 -0
- package/lib/{rules → decorators}/common/operation-description-override.js +0 -0
- package/lib/{rules → decorators}/common/registry-dependencies.d.ts +0 -0
- package/lib/{rules → decorators}/common/registry-dependencies.js +0 -0
- package/lib/decorators/common/remove-x-internal.d.ts +2 -0
- package/lib/decorators/common/remove-x-internal.js +58 -0
- package/lib/{rules → decorators}/common/tag-description-override.d.ts +0 -0
- package/lib/{rules → decorators}/common/tag-description-override.js +0 -0
- package/lib/decorators/oas2/index.d.ts +8 -0
- package/lib/decorators/oas2/index.js +15 -0
- package/lib/decorators/oas3/index.d.ts +8 -0
- package/lib/decorators/oas3/index.js +15 -0
- package/lib/js-yaml/index.js +1 -1
- package/lib/redocly/registry-api.js +4 -1
- package/lib/resolve.d.ts +1 -0
- package/lib/resolve.js +7 -3
- package/lib/rules/common/operation-security-defined.js +1 -4
- package/lib/rules/common/spec.js +18 -3
- package/lib/rules/oas2/index.d.ts +1 -7
- package/lib/rules/oas2/index.js +1 -11
- package/lib/rules/oas2/remove-unused-components.d.ts +2 -0
- package/lib/rules/oas2/remove-unused-components.js +73 -0
- package/lib/rules/oas3/index.d.ts +0 -7
- package/lib/rules/oas3/index.js +1 -11
- package/lib/rules/oas3/no-invalid-media-type-examples.js +12 -11
- package/lib/rules/oas3/remove-unused-components.d.ts +2 -0
- package/lib/rules/oas3/remove-unused-components.js +83 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/oas2.js +42 -35
- package/lib/types/oas3.js +68 -139
- package/lib/types/oas3_1.js +52 -49
- package/lib/typings/swagger.d.ts +14 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +10 -2
- package/lib/walk.js +5 -8
- package/package.json +1 -1
- package/src/__tests__/js-yaml.test.ts +29 -5
- package/src/__tests__/lint.test.ts +1 -3
- package/src/bundle.ts +37 -8
- package/src/config/builtIn.ts +20 -7
- package/src/config/config.ts +2 -3
- package/src/decorators/__tests__/remove-x-internal.test.ts +316 -0
- package/src/{rules → decorators}/common/info-description-override.ts +0 -0
- package/src/{rules → decorators}/common/operation-description-override.ts +0 -0
- package/src/{rules → decorators}/common/registry-dependencies.ts +0 -0
- package/src/decorators/common/remove-x-internal.ts +59 -0
- package/src/{rules → decorators}/common/tag-description-override.ts +0 -0
- package/src/decorators/oas2/index.ts +14 -0
- package/src/decorators/oas3/index.ts +14 -0
- package/src/js-yaml/index.ts +1 -2
- package/src/redocly/registry-api.ts +7 -1
- package/src/resolve.ts +6 -6
- package/src/rules/__tests__/no-unresolved-refs.test.ts +1 -4
- package/src/rules/common/__tests__/info-description.test.ts +1 -3
- package/src/rules/common/__tests__/info-license.test.ts +1 -2
- package/src/rules/common/__tests__/license-url.test.ts +1 -2
- package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -2
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -2
- package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -2
- package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +1 -2
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +1 -2
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +1 -2
- package/src/rules/common/__tests__/operation-operationId-unique.test.ts +1 -2
- package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -2
- package/src/rules/common/__tests__/operation-parameters-unique.test.ts +1 -2
- package/src/rules/common/__tests__/operation-security-defined.test.ts +1 -2
- package/src/rules/common/__tests__/operation-singular-tag.test.ts +1 -2
- package/src/rules/common/__tests__/path-http-verbs-order.test.ts +1 -2
- package/src/rules/common/__tests__/path-not-include-query.test.ts +1 -2
- package/src/rules/common/__tests__/path-params-defined.test.ts +1 -2
- package/src/rules/common/__tests__/paths-kebab-case.test.ts +1 -2
- package/src/rules/common/__tests__/tag-description.test.ts +1 -2
- package/src/rules/common/__tests__/tags-alphabetical.test.ts +1 -2
- package/src/rules/common/operation-security-defined.ts +4 -5
- package/src/rules/common/spec.ts +18 -0
- package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +1 -2
- package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -2
- package/src/rules/oas2/index.ts +1 -11
- package/src/rules/oas2/remove-unused-components.ts +76 -0
- package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-server-example.com.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +1 -2
- package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -2
- package/src/rules/oas3/index.ts +0 -12
- package/src/rules/oas3/no-invalid-media-type-examples.ts +17 -21
- package/src/rules/oas3/remove-unused-components.ts +84 -0
- package/src/types/index.ts +4 -0
- package/src/types/oas2.ts +42 -43
- package/src/types/oas3.ts +68 -141
- package/src/types/oas3_1.ts +51 -50
- package/src/typings/swagger.ts +7 -0
- package/src/utils.ts +9 -1
- package/src/walk.ts +6 -13
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/builtin.d.ts +0 -20
- package/lib/rules/builtin.js +0 -17
- package/src/rules/__tests__/config.ts +0 -10
- package/src/rules/builtin.ts +0 -18
|
@@ -13,22 +13,23 @@ const ValidContentExamples = (opts) => {
|
|
|
13
13
|
if (!mediaType.schema)
|
|
14
14
|
return;
|
|
15
15
|
if (mediaType.example) {
|
|
16
|
-
|
|
16
|
+
resolveAndValidateExample(mediaType.example, location.child('example'));
|
|
17
17
|
}
|
|
18
18
|
else if (mediaType.examples) {
|
|
19
19
|
for (const exampleName of Object.keys(mediaType.examples)) {
|
|
20
|
-
|
|
21
|
-
let dataLoc = location.child(['examples', exampleName, 'value']);
|
|
22
|
-
if (ref_utils_1.isRef(example)) {
|
|
23
|
-
const resolved = resolve(example);
|
|
24
|
-
if (!resolved.location)
|
|
25
|
-
continue;
|
|
26
|
-
dataLoc = resolved.location.child('value');
|
|
27
|
-
example = resolved.node;
|
|
28
|
-
}
|
|
29
|
-
utils_1.validateExample(example.value, mediaType.schema, dataLoc, ctx, disallowAdditionalProperties);
|
|
20
|
+
resolveAndValidateExample(mediaType.examples[exampleName], location.child(['examples', exampleName, 'value']), true);
|
|
30
21
|
}
|
|
31
22
|
}
|
|
23
|
+
function resolveAndValidateExample(example, location, isMultiple) {
|
|
24
|
+
if (ref_utils_1.isRef(example)) {
|
|
25
|
+
const resolved = resolve(example);
|
|
26
|
+
if (!resolved.location)
|
|
27
|
+
return;
|
|
28
|
+
location = isMultiple ? resolved.location.child('value') : resolved.location;
|
|
29
|
+
example = resolved.node;
|
|
30
|
+
}
|
|
31
|
+
utils_1.validateExample(isMultiple ? example.value : example, mediaType.schema, location, ctx, disallowAdditionalProperties);
|
|
32
|
+
}
|
|
32
33
|
},
|
|
33
34
|
},
|
|
34
35
|
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RemoveUnusedComponents = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const RemoveUnusedComponents = () => {
|
|
6
|
+
let components = new Map();
|
|
7
|
+
function registerComponent(location, componentType, name) {
|
|
8
|
+
var _a;
|
|
9
|
+
components.set(location.absolutePointer, {
|
|
10
|
+
used: ((_a = components.get(location.absolutePointer)) === null || _a === void 0 ? void 0 : _a.used) || false,
|
|
11
|
+
componentType,
|
|
12
|
+
name,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
ref: {
|
|
17
|
+
leave(ref, { type, resolve, key }) {
|
|
18
|
+
if (['Schema', 'Header', 'Parameter', 'Response', 'Example', 'RequestBody'].includes(type.name)) {
|
|
19
|
+
const resolvedRef = resolve(ref);
|
|
20
|
+
if (!resolvedRef.location)
|
|
21
|
+
return;
|
|
22
|
+
components.set(resolvedRef.location.absolutePointer, {
|
|
23
|
+
used: true,
|
|
24
|
+
name: key.toString(),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
DefinitionRoot: {
|
|
30
|
+
leave(root, ctx) {
|
|
31
|
+
const data = ctx.getVisitorData();
|
|
32
|
+
data.removedCount = 0;
|
|
33
|
+
components.forEach(usageInfo => {
|
|
34
|
+
const { used, componentType, name } = usageInfo;
|
|
35
|
+
if (!used && componentType) {
|
|
36
|
+
let componentChild = root.components[componentType];
|
|
37
|
+
delete componentChild[name];
|
|
38
|
+
data.removedCount++;
|
|
39
|
+
if (utils_1.isEmptyObject(componentChild)) {
|
|
40
|
+
delete root.components[componentType];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (utils_1.isEmptyObject(root.components)) {
|
|
45
|
+
delete root.components;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
NamedSchemas: {
|
|
50
|
+
Schema(schema, { location, key }) {
|
|
51
|
+
if (!schema.allOf) {
|
|
52
|
+
registerComponent(location, 'schemas', key.toString());
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
NamedParameters: {
|
|
57
|
+
Parameter(_parameter, { location, key }) {
|
|
58
|
+
registerComponent(location, 'parameters', key.toString());
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
NamedResponses: {
|
|
62
|
+
Response(_response, { location, key }) {
|
|
63
|
+
registerComponent(location, 'responses', key.toString());
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
NamedExamples: {
|
|
67
|
+
Example(_example, { location, key }) {
|
|
68
|
+
registerComponent(location, 'examples', key.toString());
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
NamedRequestBodies: {
|
|
72
|
+
RequestBody(_requestBody, { location, key }) {
|
|
73
|
+
registerComponent(location, 'requestBodies', key.toString());
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
NamedHeaders: {
|
|
77
|
+
Header(_header, { location, key }) {
|
|
78
|
+
registerComponent(location, 'headers', key.toString());
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
exports.RemoveUnusedComponents = RemoveUnusedComponents;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export declare type NodeType = {
|
|
|
22
22
|
items?: string;
|
|
23
23
|
required?: string[] | ((value: any, key: string | number | undefined) => string[]);
|
|
24
24
|
requiredOneOf?: string[];
|
|
25
|
+
allowed?: ((value: any) => string[] | undefined);
|
|
26
|
+
extensionsPrefix?: string;
|
|
25
27
|
};
|
|
26
28
|
declare type PropType = string | NodeType | ScalarSchema | undefined | null;
|
|
27
29
|
declare type ResolveTypeFn = (value: any, key: string) => string | PropType;
|
|
@@ -32,6 +34,8 @@ export declare type NormalizedNodeType = {
|
|
|
32
34
|
items?: NormalizedNodeType;
|
|
33
35
|
required?: string[] | ((value: any, key: string | number | undefined) => string[]);
|
|
34
36
|
requiredOneOf?: string[];
|
|
37
|
+
allowed?: ((value: any) => string[] | undefined);
|
|
38
|
+
extensionsPrefix?: string;
|
|
35
39
|
};
|
|
36
40
|
declare type NormalizedPropType = NormalizedNodeType | NormalizedScalarSchema | undefined | null;
|
|
37
41
|
declare type NormalizedResolveTypeFn = (value: any, key: string) => NormalizedNodeType | NormalizedScalarSchema | undefined | null;
|
package/lib/types/oas2.js
CHANGED
|
@@ -68,9 +68,7 @@ const PathItem = {
|
|
|
68
68
|
const Operation = {
|
|
69
69
|
properties: {
|
|
70
70
|
tags: { type: 'array', items: { type: 'string' } },
|
|
71
|
-
summary: {
|
|
72
|
-
type: 'string',
|
|
73
|
-
},
|
|
71
|
+
summary: { type: 'string' },
|
|
74
72
|
description: { type: 'string' },
|
|
75
73
|
externalDocs: 'ExternalDocs',
|
|
76
74
|
operationId: { type: 'string' },
|
|
@@ -180,9 +178,7 @@ const ResponsesMap = {
|
|
|
180
178
|
};
|
|
181
179
|
const Response = {
|
|
182
180
|
properties: {
|
|
183
|
-
description: {
|
|
184
|
-
type: 'string',
|
|
185
|
-
},
|
|
181
|
+
description: { type: 'string' },
|
|
186
182
|
schema: 'Schema',
|
|
187
183
|
headers: _1.mapOf('Header'),
|
|
188
184
|
examples: 'Examples',
|
|
@@ -299,44 +295,55 @@ const SecurityScheme = {
|
|
|
299
295
|
type: { enum: ['basic', 'apiKey', 'oauth2'] },
|
|
300
296
|
description: { type: 'string' },
|
|
301
297
|
name: { type: 'string' },
|
|
302
|
-
in: { type: 'string', enum: ['query', 'header'
|
|
298
|
+
in: { type: 'string', enum: ['query', 'header'] },
|
|
303
299
|
flow: { enum: ['implicit', 'password', 'application', 'accessCode'] },
|
|
304
300
|
authorizationUrl: { type: 'string' },
|
|
305
301
|
tokenUrl: { type: 'string' },
|
|
306
302
|
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
307
303
|
},
|
|
308
304
|
required(value) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
305
|
+
switch (value === null || value === void 0 ? void 0 : value.type) {
|
|
306
|
+
case 'apiKey':
|
|
307
|
+
return ['type', 'name', 'in'];
|
|
308
|
+
case 'oauth2':
|
|
309
|
+
switch (value === null || value === void 0 ? void 0 : value.flow) {
|
|
310
|
+
case 'implicit':
|
|
311
|
+
return ['type', 'flow', 'authorizationUrl', 'scopes'];
|
|
312
|
+
case 'accessCode':
|
|
313
|
+
return ['type', 'flow', 'authorizationUrl', 'tokenUrl', 'scopes'];
|
|
314
|
+
case 'application':
|
|
315
|
+
case 'password':
|
|
316
|
+
return ['type', 'flow', 'tokenUrl', 'scopes'];
|
|
317
|
+
default:
|
|
318
|
+
return ['type', 'flow', 'scopes'];
|
|
319
|
+
}
|
|
320
|
+
default:
|
|
321
|
+
return ['type'];
|
|
317
322
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
323
|
+
},
|
|
324
|
+
allowed(value) {
|
|
325
|
+
switch (value === null || value === void 0 ? void 0 : value.type) {
|
|
326
|
+
case 'basic':
|
|
327
|
+
return ['type', 'description'];
|
|
328
|
+
case 'apiKey':
|
|
329
|
+
return ['type', 'name', 'in', 'description'];
|
|
330
|
+
case 'oauth2':
|
|
331
|
+
switch (value === null || value === void 0 ? void 0 : value.flow) {
|
|
332
|
+
case 'implicit':
|
|
333
|
+
return ['type', 'flow', 'authorizationUrl', 'description', 'scopes'];
|
|
334
|
+
case 'accessCode':
|
|
335
|
+
return ['type', 'flow', 'authorizationUrl', 'tokenUrl', 'description', 'scopes'];
|
|
336
|
+
case 'application':
|
|
337
|
+
case 'password':
|
|
338
|
+
return ['type', 'flow', 'tokenUrl', 'description', 'scopes'];
|
|
339
|
+
default:
|
|
340
|
+
return ['type', 'flow', 'tokenUrl', 'authorizationUrl', 'description', 'scopes'];
|
|
341
|
+
}
|
|
342
|
+
default:
|
|
343
|
+
return ['type', 'description'];
|
|
337
344
|
}
|
|
338
|
-
return ['type'];
|
|
339
345
|
},
|
|
346
|
+
extensionsPrefix: 'x-',
|
|
340
347
|
};
|
|
341
348
|
const SecurityRequirement = {
|
|
342
349
|
properties: {},
|
package/lib/types/oas3.js
CHANGED
|
@@ -28,23 +28,15 @@ const Tag = {
|
|
|
28
28
|
};
|
|
29
29
|
const ExternalDocs = {
|
|
30
30
|
properties: {
|
|
31
|
-
description: {
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
url: {
|
|
35
|
-
type: 'string',
|
|
36
|
-
},
|
|
31
|
+
description: { type: 'string' },
|
|
32
|
+
url: { type: 'string' },
|
|
37
33
|
},
|
|
38
34
|
required: ['url'],
|
|
39
35
|
};
|
|
40
36
|
const Server = {
|
|
41
37
|
properties: {
|
|
42
|
-
url: {
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
description: {
|
|
46
|
-
type: 'string',
|
|
47
|
-
},
|
|
38
|
+
url: { type: 'string' },
|
|
39
|
+
description: { type: 'string' },
|
|
48
40
|
variables: _1.mapOf('ServerVariable'),
|
|
49
41
|
},
|
|
50
42
|
required: ['url'],
|
|
@@ -55,9 +47,7 @@ const ServerVariable = {
|
|
|
55
47
|
type: 'array',
|
|
56
48
|
items: { type: 'string' },
|
|
57
49
|
},
|
|
58
|
-
default: {
|
|
59
|
-
type: 'string',
|
|
60
|
-
},
|
|
50
|
+
default: { type: 'string' },
|
|
61
51
|
description: null,
|
|
62
52
|
},
|
|
63
53
|
required: ['default'],
|
|
@@ -68,18 +58,10 @@ const SecurityRequirement = {
|
|
|
68
58
|
};
|
|
69
59
|
const Info = {
|
|
70
60
|
properties: {
|
|
71
|
-
title: {
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
type: 'string',
|
|
76
|
-
},
|
|
77
|
-
description: {
|
|
78
|
-
type: 'string',
|
|
79
|
-
},
|
|
80
|
-
termsOfService: {
|
|
81
|
-
type: 'string',
|
|
82
|
-
},
|
|
61
|
+
title: { type: 'string' },
|
|
62
|
+
version: { type: 'string' },
|
|
63
|
+
description: { type: 'string' },
|
|
64
|
+
termsOfService: { type: 'string' },
|
|
83
65
|
contact: 'Contact',
|
|
84
66
|
license: 'License',
|
|
85
67
|
},
|
|
@@ -87,25 +69,15 @@ const Info = {
|
|
|
87
69
|
};
|
|
88
70
|
const Contact = {
|
|
89
71
|
properties: {
|
|
90
|
-
name: {
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
url: {
|
|
94
|
-
type: 'string',
|
|
95
|
-
},
|
|
96
|
-
email: {
|
|
97
|
-
type: 'string',
|
|
98
|
-
},
|
|
72
|
+
name: { type: 'string' },
|
|
73
|
+
url: { type: 'string' },
|
|
74
|
+
email: { type: 'string' },
|
|
99
75
|
},
|
|
100
76
|
};
|
|
101
77
|
const License = {
|
|
102
78
|
properties: {
|
|
103
|
-
name: {
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
url: {
|
|
107
|
-
type: 'string',
|
|
108
|
-
},
|
|
79
|
+
name: { type: 'string' },
|
|
80
|
+
url: { type: 'string' },
|
|
109
81
|
},
|
|
110
82
|
required: ['name'],
|
|
111
83
|
};
|
|
@@ -122,12 +94,8 @@ const PathItem = {
|
|
|
122
94
|
$ref: { type: 'string' },
|
|
123
95
|
servers: _1.listOf('Server'),
|
|
124
96
|
parameters: _1.listOf('Parameter'),
|
|
125
|
-
summary: {
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
description: {
|
|
129
|
-
type: 'string',
|
|
130
|
-
},
|
|
97
|
+
summary: { type: 'string' },
|
|
98
|
+
description: { type: 'string' },
|
|
131
99
|
get: 'Operation',
|
|
132
100
|
put: 'Operation',
|
|
133
101
|
post: 'Operation',
|
|
@@ -140,33 +108,17 @@ const PathItem = {
|
|
|
140
108
|
};
|
|
141
109
|
const Parameter = {
|
|
142
110
|
properties: {
|
|
143
|
-
name: {
|
|
144
|
-
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
description: {
|
|
150
|
-
type: 'string',
|
|
151
|
-
},
|
|
152
|
-
required: {
|
|
153
|
-
type: 'boolean',
|
|
154
|
-
},
|
|
155
|
-
deprecated: {
|
|
156
|
-
type: 'boolean',
|
|
157
|
-
},
|
|
158
|
-
allowEmptyValue: {
|
|
159
|
-
type: 'boolean',
|
|
160
|
-
},
|
|
111
|
+
name: { type: 'string' },
|
|
112
|
+
in: { enum: ['query', 'header', 'path', 'cookie'] },
|
|
113
|
+
description: { type: 'string' },
|
|
114
|
+
required: { type: 'boolean' },
|
|
115
|
+
deprecated: { type: 'boolean' },
|
|
116
|
+
allowEmptyValue: { type: 'boolean' },
|
|
161
117
|
style: {
|
|
162
118
|
enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
|
|
163
119
|
},
|
|
164
|
-
explode: {
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
allowReserved: {
|
|
168
|
-
type: 'boolean',
|
|
169
|
-
},
|
|
120
|
+
explode: { type: 'boolean' },
|
|
121
|
+
allowReserved: { type: 'boolean' },
|
|
170
122
|
schema: 'Schema',
|
|
171
123
|
example: { isExample: true },
|
|
172
124
|
examples: _1.mapOf('Example'),
|
|
@@ -193,9 +145,7 @@ const Operation = {
|
|
|
193
145
|
servers: _1.listOf('Server'),
|
|
194
146
|
requestBody: 'RequestBody',
|
|
195
147
|
responses: 'ResponsesMap',
|
|
196
|
-
deprecated: {
|
|
197
|
-
type: 'boolean',
|
|
198
|
-
},
|
|
148
|
+
deprecated: { type: 'boolean' },
|
|
199
149
|
callbacks: _1.mapOf('Callback'),
|
|
200
150
|
'x-codeSamples': _1.listOf('XCodeSample'),
|
|
201
151
|
'x-code-samples': _1.listOf('XCodeSample'), // deprecated
|
|
@@ -211,12 +161,8 @@ const XCodeSample = {
|
|
|
211
161
|
};
|
|
212
162
|
const RequestBody = {
|
|
213
163
|
properties: {
|
|
214
|
-
description: {
|
|
215
|
-
|
|
216
|
-
},
|
|
217
|
-
required: {
|
|
218
|
-
type: 'boolean',
|
|
219
|
-
},
|
|
164
|
+
description: { type: 'string' },
|
|
165
|
+
required: { type: 'boolean' },
|
|
220
166
|
content: 'MediaTypeMap',
|
|
221
167
|
},
|
|
222
168
|
required: ['content'],
|
|
@@ -236,57 +182,33 @@ const MediaType = {
|
|
|
236
182
|
const Example = {
|
|
237
183
|
properties: {
|
|
238
184
|
value: { isExample: true },
|
|
239
|
-
summary: {
|
|
240
|
-
|
|
241
|
-
},
|
|
242
|
-
description: {
|
|
243
|
-
type: 'string',
|
|
244
|
-
},
|
|
245
|
-
externalValue: {
|
|
246
|
-
type: 'string',
|
|
247
|
-
},
|
|
185
|
+
summary: { type: 'string' },
|
|
186
|
+
description: { type: 'string' },
|
|
187
|
+
externalValue: { type: 'string' },
|
|
248
188
|
},
|
|
249
189
|
};
|
|
250
190
|
const Encoding = {
|
|
251
191
|
properties: {
|
|
252
|
-
contentType: {
|
|
253
|
-
type: 'string',
|
|
254
|
-
},
|
|
192
|
+
contentType: { type: 'string' },
|
|
255
193
|
headers: _1.mapOf('Header'),
|
|
256
194
|
style: {
|
|
257
195
|
enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
|
|
258
196
|
},
|
|
259
|
-
explode: {
|
|
260
|
-
|
|
261
|
-
},
|
|
262
|
-
allowReserved: {
|
|
263
|
-
type: 'boolean',
|
|
264
|
-
},
|
|
197
|
+
explode: { type: 'boolean' },
|
|
198
|
+
allowReserved: { type: 'boolean' },
|
|
265
199
|
},
|
|
266
200
|
};
|
|
267
201
|
const Header = {
|
|
268
202
|
properties: {
|
|
269
|
-
description: {
|
|
270
|
-
|
|
271
|
-
},
|
|
272
|
-
|
|
273
|
-
type: 'boolean',
|
|
274
|
-
},
|
|
275
|
-
deprecated: {
|
|
276
|
-
type: 'boolean',
|
|
277
|
-
},
|
|
278
|
-
allowEmptyValue: {
|
|
279
|
-
type: 'boolean',
|
|
280
|
-
},
|
|
203
|
+
description: { type: 'string' },
|
|
204
|
+
required: { type: 'boolean' },
|
|
205
|
+
deprecated: { type: 'boolean' },
|
|
206
|
+
allowEmptyValue: { type: 'boolean' },
|
|
281
207
|
style: {
|
|
282
208
|
enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
|
|
283
209
|
},
|
|
284
|
-
explode: {
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
allowReserved: {
|
|
288
|
-
type: 'boolean',
|
|
289
|
-
},
|
|
210
|
+
explode: { type: 'boolean' },
|
|
211
|
+
allowReserved: { type: 'boolean' },
|
|
290
212
|
schema: 'Schema',
|
|
291
213
|
example: { isExample: true },
|
|
292
214
|
examples: _1.mapOf('Example'),
|
|
@@ -294,16 +216,12 @@ const Header = {
|
|
|
294
216
|
},
|
|
295
217
|
};
|
|
296
218
|
const ResponsesMap = {
|
|
297
|
-
properties: {
|
|
298
|
-
default: 'Response',
|
|
299
|
-
},
|
|
219
|
+
properties: { default: 'Response' },
|
|
300
220
|
additionalProperties: (_v, key) => responseCodeRegexp.test(key) ? 'Response' : undefined,
|
|
301
221
|
};
|
|
302
222
|
const Response = {
|
|
303
223
|
properties: {
|
|
304
|
-
description: {
|
|
305
|
-
type: 'string',
|
|
306
|
-
},
|
|
224
|
+
description: { type: 'string' },
|
|
307
225
|
headers: _1.mapOf('Header'),
|
|
308
226
|
content: 'MediaTypeMap',
|
|
309
227
|
links: _1.mapOf('Link'),
|
|
@@ -425,7 +343,7 @@ const ImplicitFlow = {
|
|
|
425
343
|
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
426
344
|
authorizationUrl: { type: 'string' },
|
|
427
345
|
},
|
|
428
|
-
required: ['authorizationUrl', 'scopes']
|
|
346
|
+
required: ['authorizationUrl', 'scopes']
|
|
429
347
|
};
|
|
430
348
|
const PasswordFlow = {
|
|
431
349
|
properties: {
|
|
@@ -465,30 +383,41 @@ const SecurityScheme = {
|
|
|
465
383
|
type: { enum: ['apiKey', 'http', 'oauth2', 'openIdConnect'] },
|
|
466
384
|
description: { type: 'string' },
|
|
467
385
|
name: { type: 'string' },
|
|
468
|
-
in: { type: 'string' },
|
|
386
|
+
in: { type: 'string', enum: ['query', 'header', 'cookie'] },
|
|
469
387
|
scheme: { type: 'string' },
|
|
470
388
|
bearerFormat: { type: 'string' },
|
|
471
389
|
flows: 'SecuritySchemeFlows',
|
|
472
390
|
openIdConnectUrl: { type: 'string' },
|
|
473
391
|
},
|
|
474
392
|
required(value) {
|
|
475
|
-
|
|
476
|
-
|
|
393
|
+
switch (value === null || value === void 0 ? void 0 : value.type) {
|
|
394
|
+
case 'apiKey':
|
|
395
|
+
return ['type', 'name', 'in'];
|
|
396
|
+
case 'http':
|
|
397
|
+
return ['type', 'scheme'];
|
|
398
|
+
case 'oauth2':
|
|
399
|
+
return ['type', 'flows'];
|
|
400
|
+
case 'openIdConnect':
|
|
401
|
+
return ['type', 'openIdConnectUrl'];
|
|
402
|
+
default:
|
|
403
|
+
return ['type'];
|
|
477
404
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
405
|
+
},
|
|
406
|
+
allowed(value) {
|
|
407
|
+
switch (value === null || value === void 0 ? void 0 : value.type) {
|
|
408
|
+
case 'apiKey':
|
|
409
|
+
return ['type', 'name', 'in', 'description'];
|
|
410
|
+
case 'http':
|
|
411
|
+
return ['type', 'scheme', 'bearerFormat', 'description'];
|
|
412
|
+
case 'oauth2':
|
|
413
|
+
return ['type', 'flows', 'description'];
|
|
414
|
+
case 'openIdConnect':
|
|
415
|
+
return ['type', 'openIdConnectUrl', 'description'];
|
|
416
|
+
default:
|
|
417
|
+
return ['type', 'description'];
|
|
489
418
|
}
|
|
490
|
-
return ['type'];
|
|
491
419
|
},
|
|
420
|
+
extensionsPrefix: 'x-',
|
|
492
421
|
};
|
|
493
422
|
exports.Oas3Types = {
|
|
494
423
|
DefinitionRoot,
|