@redocly/openapi-core 1.0.0-beta.78 → 1.0.0-beta.82
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.js +18 -7
- package/lib/config/builtIn.js +18 -4
- 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/{rules → decorators}/common/remove-x-internal.d.ts +0 -0
- package/lib/{rules → decorators}/common/remove-x-internal.js +20 -2
- 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/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 -8
- package/lib/rules/oas2/index.js +1 -13
- package/lib/rules/oas2/remove-unused-components.js +11 -9
- package/lib/rules/oas3/index.d.ts +0 -8
- package/lib/rules/oas3/index.js +1 -13
- package/lib/rules/oas3/no-invalid-media-type-examples.js +12 -11
- package/lib/rules/oas3/remove-unused-components.js +11 -9
- 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/utils.js +1 -1
- package/lib/walk.js +1 -1
- 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 +21 -8
- package/src/config/builtIn.ts +20 -7
- package/src/{rules/__tests__/hide-internals.test.ts → decorators/__tests__/remove-x-internal.test.ts} +124 -42
- 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/{rules → decorators}/common/remove-x-internal.ts +20 -3
- 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 +4 -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 -13
- package/src/rules/oas2/remove-unused-components.ts +12 -10
- 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 -14
- package/src/rules/oas3/no-invalid-media-type-examples.ts +17 -21
- package/src/rules/oas3/remove-unused-components.ts +12 -10
- package/src/types/index.ts +4 -0
- package/src/types/oas2.ts +42 -40
- package/src/types/oas3.ts +68 -141
- package/src/types/oas3_1.ts +51 -50
- package/src/utils.ts +1 -1
- package/src/walk.ts +2 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/builtin.d.ts +0 -22
- package/lib/rules/builtin.js +0 -17
- package/src/rules/__tests__/config.ts +0 -11
- package/src/rules/builtin.ts +0 -18
package/src/types/oas2.ts
CHANGED
|
@@ -12,12 +12,10 @@ const DefinitionRoot: NodeType = {
|
|
|
12
12
|
consumes: { type: 'array', items: { type: 'string' } },
|
|
13
13
|
produces: { type: 'array', items: { type: 'string' } },
|
|
14
14
|
paths: 'PathMap',
|
|
15
|
-
|
|
16
15
|
definitions: 'NamedSchemas',
|
|
17
16
|
parameters: 'NamedParameters',
|
|
18
17
|
responses: 'NamedResponses',
|
|
19
18
|
securityDefinitions: 'NamedSecuritySchemes',
|
|
20
|
-
|
|
21
19
|
security: listOf('SecurityRequirement'),
|
|
22
20
|
tags: listOf('Tag'),
|
|
23
21
|
externalDocs: 'ExternalDocs',
|
|
@@ -62,7 +60,6 @@ const PathMap: NodeType = {
|
|
|
62
60
|
const PathItem: NodeType = {
|
|
63
61
|
properties: {
|
|
64
62
|
$ref: { type: 'string' }, // TODO: verify special $ref handling for Path Item
|
|
65
|
-
|
|
66
63
|
get: 'Operation',
|
|
67
64
|
put: 'Operation',
|
|
68
65
|
post: 'Operation',
|
|
@@ -70,7 +67,6 @@ const PathItem: NodeType = {
|
|
|
70
67
|
options: 'Operation',
|
|
71
68
|
head: 'Operation',
|
|
72
69
|
patch: 'Operation',
|
|
73
|
-
|
|
74
70
|
parameters: listOf('Parameter'),
|
|
75
71
|
},
|
|
76
72
|
};
|
|
@@ -78,9 +74,7 @@ const PathItem: NodeType = {
|
|
|
78
74
|
const Operation: NodeType = {
|
|
79
75
|
properties: {
|
|
80
76
|
tags: { type: 'array', items: { type: 'string' } },
|
|
81
|
-
summary: {
|
|
82
|
-
type: 'string',
|
|
83
|
-
},
|
|
77
|
+
summary: { type: 'string' },
|
|
84
78
|
description: { type: 'string' },
|
|
85
79
|
externalDocs: 'ExternalDocs',
|
|
86
80
|
operationId: { type: 'string' },
|
|
@@ -119,11 +113,8 @@ const Parameter: NodeType = {
|
|
|
119
113
|
in: { type: 'string', enum: ['query', 'header', 'path', 'formData', 'body'] },
|
|
120
114
|
description: { type: 'string' },
|
|
121
115
|
required: { type: 'boolean' },
|
|
122
|
-
|
|
123
116
|
schema: 'Schema',
|
|
124
|
-
|
|
125
117
|
type: { type: 'string', enum: ['string', 'number', 'integer', 'boolean', 'array', 'file'] },
|
|
126
|
-
|
|
127
118
|
format: { type: 'string' },
|
|
128
119
|
allowEmptyValue: { type: 'boolean' },
|
|
129
120
|
items: 'ParameterItems',
|
|
@@ -197,9 +188,7 @@ const ResponsesMap: NodeType = {
|
|
|
197
188
|
|
|
198
189
|
const Response: NodeType = {
|
|
199
190
|
properties: {
|
|
200
|
-
description: {
|
|
201
|
-
type: 'string',
|
|
202
|
-
},
|
|
191
|
+
description: { type: 'string' },
|
|
203
192
|
schema: 'Schema',
|
|
204
193
|
headers: mapOf('Header'),
|
|
205
194
|
examples: 'Examples',
|
|
@@ -217,7 +206,6 @@ const Header: NodeType = {
|
|
|
217
206
|
description: { type: 'string' },
|
|
218
207
|
type: { type: 'string', enum: ['string', 'number', 'integer', 'boolean', 'array'] },
|
|
219
208
|
format: { type: 'string' },
|
|
220
|
-
|
|
221
209
|
items: 'ParameterItems',
|
|
222
210
|
collectionFormat: { type: 'string', enum: ['csv', 'ssv', 'tsv', 'pipes', 'multi'] },
|
|
223
211
|
default: null,
|
|
@@ -277,7 +265,6 @@ const Schema: NodeType = {
|
|
|
277
265
|
type: 'string',
|
|
278
266
|
enum: ['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'],
|
|
279
267
|
},
|
|
280
|
-
|
|
281
268
|
items: (value: any) => {
|
|
282
269
|
if (Array.isArray(value)) {
|
|
283
270
|
return listOf('Schema');
|
|
@@ -294,7 +281,6 @@ const Schema: NodeType = {
|
|
|
294
281
|
return 'Schema';
|
|
295
282
|
}
|
|
296
283
|
},
|
|
297
|
-
|
|
298
284
|
discriminator: { type: 'string' },
|
|
299
285
|
readOnly: { type: 'boolean' },
|
|
300
286
|
xml: 'Xml',
|
|
@@ -323,39 +309,55 @@ const SecurityScheme: NodeType = {
|
|
|
323
309
|
type: { enum: ['basic', 'apiKey', 'oauth2'] },
|
|
324
310
|
description: { type: 'string' },
|
|
325
311
|
name: { type: 'string' },
|
|
326
|
-
in: { type: 'string', enum: ['query', 'header'
|
|
312
|
+
in: { type: 'string', enum: ['query', 'header'] },
|
|
327
313
|
flow: { enum: ['implicit', 'password', 'application', 'accessCode'] },
|
|
328
314
|
authorizationUrl: { type: 'string' },
|
|
329
315
|
tokenUrl: { type: 'string' },
|
|
330
316
|
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
331
317
|
},
|
|
332
318
|
required(value) {
|
|
333
|
-
|
|
334
|
-
|
|
319
|
+
switch (value?.type) {
|
|
320
|
+
case 'apiKey':
|
|
321
|
+
return ['type', 'name', 'in'];
|
|
322
|
+
case 'oauth2':
|
|
323
|
+
switch (value?.flow) {
|
|
324
|
+
case 'implicit':
|
|
325
|
+
return ['type', 'flow', 'authorizationUrl', 'scopes'];
|
|
326
|
+
case 'accessCode':
|
|
327
|
+
return ['type', 'flow', 'authorizationUrl', 'tokenUrl', 'scopes'];
|
|
328
|
+
case 'application':
|
|
329
|
+
case 'password':
|
|
330
|
+
return ['type', 'flow', 'tokenUrl', 'scopes'];
|
|
331
|
+
default:
|
|
332
|
+
return ['type', 'flow', 'scopes'];
|
|
333
|
+
}
|
|
334
|
+
default:
|
|
335
|
+
return ['type'];
|
|
335
336
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
337
|
+
},
|
|
338
|
+
allowed(value) {
|
|
339
|
+
switch (value?.type) {
|
|
340
|
+
case 'basic':
|
|
341
|
+
return ['type', 'description'];
|
|
342
|
+
case 'apiKey':
|
|
343
|
+
return ['type', 'name', 'in', 'description'];
|
|
344
|
+
case 'oauth2':
|
|
345
|
+
switch (value?.flow) {
|
|
346
|
+
case 'implicit':
|
|
347
|
+
return ['type', 'flow', 'authorizationUrl', 'description', 'scopes'];
|
|
348
|
+
case 'accessCode':
|
|
349
|
+
return ['type', 'flow', 'authorizationUrl', 'tokenUrl', 'description', 'scopes'];
|
|
350
|
+
case 'application':
|
|
351
|
+
case 'password':
|
|
352
|
+
return ['type', 'flow', 'tokenUrl', 'description', 'scopes'];
|
|
353
|
+
default:
|
|
354
|
+
return ['type', 'flow', 'tokenUrl', 'authorizationUrl', 'description', 'scopes'];
|
|
355
|
+
}
|
|
356
|
+
default:
|
|
357
|
+
return ['type', 'description'];
|
|
355
358
|
}
|
|
356
|
-
|
|
357
|
-
return ['type'];
|
|
358
359
|
},
|
|
360
|
+
extensionsPrefix: 'x-',
|
|
359
361
|
};
|
|
360
362
|
|
|
361
363
|
const SecurityRequirement: NodeType = {
|
package/src/types/oas3.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NodeType, listOf, mapOf } from '.';
|
|
2
2
|
import { isMappingRef } from '../ref-utils';
|
|
3
|
-
|
|
4
3
|
const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/;
|
|
5
4
|
|
|
6
5
|
const DefinitionRoot: NodeType = {
|
|
@@ -29,24 +28,16 @@ const Tag: NodeType = {
|
|
|
29
28
|
|
|
30
29
|
const ExternalDocs: NodeType = {
|
|
31
30
|
properties: {
|
|
32
|
-
description: {
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
url: {
|
|
36
|
-
type: 'string',
|
|
37
|
-
},
|
|
31
|
+
description: { type: 'string' },
|
|
32
|
+
url: { type: 'string' },
|
|
38
33
|
},
|
|
39
34
|
required: ['url'],
|
|
40
35
|
};
|
|
41
36
|
|
|
42
37
|
const Server: NodeType = {
|
|
43
38
|
properties: {
|
|
44
|
-
url: {
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
description: {
|
|
48
|
-
type: 'string',
|
|
49
|
-
},
|
|
39
|
+
url: { type: 'string' },
|
|
40
|
+
description: { type: 'string' },
|
|
50
41
|
variables: mapOf('ServerVariable'),
|
|
51
42
|
},
|
|
52
43
|
required: ['url'],
|
|
@@ -58,9 +49,7 @@ const ServerVariable: NodeType = {
|
|
|
58
49
|
type: 'array',
|
|
59
50
|
items: { type: 'string' },
|
|
60
51
|
},
|
|
61
|
-
default: {
|
|
62
|
-
type: 'string',
|
|
63
|
-
},
|
|
52
|
+
default: { type: 'string' },
|
|
64
53
|
description: null,
|
|
65
54
|
},
|
|
66
55
|
required: ['default'],
|
|
@@ -73,18 +62,10 @@ const SecurityRequirement: NodeType = {
|
|
|
73
62
|
|
|
74
63
|
const Info: NodeType = {
|
|
75
64
|
properties: {
|
|
76
|
-
title: {
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
type: 'string',
|
|
81
|
-
},
|
|
82
|
-
description: {
|
|
83
|
-
type: 'string',
|
|
84
|
-
},
|
|
85
|
-
termsOfService: {
|
|
86
|
-
type: 'string',
|
|
87
|
-
},
|
|
65
|
+
title: { type: 'string' },
|
|
66
|
+
version: { type: 'string' },
|
|
67
|
+
description: { type: 'string' },
|
|
68
|
+
termsOfService: { type: 'string' },
|
|
88
69
|
contact: 'Contact',
|
|
89
70
|
license: 'License',
|
|
90
71
|
},
|
|
@@ -93,26 +74,16 @@ const Info: NodeType = {
|
|
|
93
74
|
|
|
94
75
|
const Contact: NodeType = {
|
|
95
76
|
properties: {
|
|
96
|
-
name: {
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
url: {
|
|
100
|
-
type: 'string',
|
|
101
|
-
},
|
|
102
|
-
email: {
|
|
103
|
-
type: 'string',
|
|
104
|
-
},
|
|
77
|
+
name: { type: 'string' },
|
|
78
|
+
url: { type: 'string' },
|
|
79
|
+
email: { type: 'string' },
|
|
105
80
|
},
|
|
106
81
|
};
|
|
107
82
|
|
|
108
83
|
const License: NodeType = {
|
|
109
84
|
properties: {
|
|
110
|
-
name: {
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
url: {
|
|
114
|
-
type: 'string',
|
|
115
|
-
},
|
|
85
|
+
name: { type: 'string' },
|
|
86
|
+
url: { type: 'string' },
|
|
116
87
|
},
|
|
117
88
|
required: ['name'],
|
|
118
89
|
};
|
|
@@ -133,12 +104,8 @@ const PathItem: NodeType = {
|
|
|
133
104
|
$ref: { type: 'string' }, // TODO: verify special $ref handling for Path Item
|
|
134
105
|
servers: listOf('Server'),
|
|
135
106
|
parameters: listOf('Parameter'),
|
|
136
|
-
summary: {
|
|
137
|
-
|
|
138
|
-
},
|
|
139
|
-
description: {
|
|
140
|
-
type: 'string',
|
|
141
|
-
},
|
|
107
|
+
summary: { type: 'string' },
|
|
108
|
+
description: { type: 'string' },
|
|
142
109
|
get: 'Operation',
|
|
143
110
|
put: 'Operation',
|
|
144
111
|
post: 'Operation',
|
|
@@ -152,33 +119,17 @@ const PathItem: NodeType = {
|
|
|
152
119
|
|
|
153
120
|
const Parameter: NodeType = {
|
|
154
121
|
properties: {
|
|
155
|
-
name: {
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
description: {
|
|
162
|
-
type: 'string',
|
|
163
|
-
},
|
|
164
|
-
required: {
|
|
165
|
-
type: 'boolean',
|
|
166
|
-
},
|
|
167
|
-
deprecated: {
|
|
168
|
-
type: 'boolean',
|
|
169
|
-
},
|
|
170
|
-
allowEmptyValue: {
|
|
171
|
-
type: 'boolean',
|
|
172
|
-
},
|
|
122
|
+
name: { type: 'string' },
|
|
123
|
+
in: { enum: ['query', 'header', 'path', 'cookie'] },
|
|
124
|
+
description: { type: 'string' },
|
|
125
|
+
required: { type: 'boolean' },
|
|
126
|
+
deprecated: { type: 'boolean' },
|
|
127
|
+
allowEmptyValue: { type: 'boolean' },
|
|
173
128
|
style: {
|
|
174
129
|
enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
|
|
175
130
|
},
|
|
176
|
-
explode: {
|
|
177
|
-
|
|
178
|
-
},
|
|
179
|
-
allowReserved: {
|
|
180
|
-
type: 'boolean',
|
|
181
|
-
},
|
|
131
|
+
explode: { type: 'boolean' },
|
|
132
|
+
allowReserved: { type: 'boolean' },
|
|
182
133
|
schema: 'Schema',
|
|
183
134
|
example: { isExample: true },
|
|
184
135
|
examples: mapOf('Example'),
|
|
@@ -207,9 +158,7 @@ const Operation: NodeType = {
|
|
|
207
158
|
servers: listOf('Server'),
|
|
208
159
|
requestBody: 'RequestBody',
|
|
209
160
|
responses: 'ResponsesMap',
|
|
210
|
-
deprecated: {
|
|
211
|
-
type: 'boolean',
|
|
212
|
-
},
|
|
161
|
+
deprecated: { type: 'boolean' },
|
|
213
162
|
callbacks: mapOf('Callback'),
|
|
214
163
|
'x-codeSamples': listOf('XCodeSample'),
|
|
215
164
|
'x-code-samples': listOf('XCodeSample'), // deprecated
|
|
@@ -227,12 +176,8 @@ const XCodeSample: NodeType = {
|
|
|
227
176
|
|
|
228
177
|
const RequestBody: NodeType = {
|
|
229
178
|
properties: {
|
|
230
|
-
description: {
|
|
231
|
-
|
|
232
|
-
},
|
|
233
|
-
required: {
|
|
234
|
-
type: 'boolean',
|
|
235
|
-
},
|
|
179
|
+
description: { type: 'string' },
|
|
180
|
+
required: { type: 'boolean' },
|
|
236
181
|
content: 'MediaTypeMap',
|
|
237
182
|
},
|
|
238
183
|
required: ['content'],
|
|
@@ -255,59 +200,35 @@ const MediaType: NodeType = {
|
|
|
255
200
|
const Example: NodeType = {
|
|
256
201
|
properties: {
|
|
257
202
|
value: { isExample: true },
|
|
258
|
-
summary: {
|
|
259
|
-
|
|
260
|
-
},
|
|
261
|
-
description: {
|
|
262
|
-
type: 'string',
|
|
263
|
-
},
|
|
264
|
-
externalValue: {
|
|
265
|
-
type: 'string',
|
|
266
|
-
},
|
|
203
|
+
summary: { type: 'string' },
|
|
204
|
+
description: { type: 'string' },
|
|
205
|
+
externalValue: { type: 'string' },
|
|
267
206
|
},
|
|
268
207
|
};
|
|
269
208
|
|
|
270
209
|
const Encoding: NodeType = {
|
|
271
210
|
properties: {
|
|
272
|
-
contentType: {
|
|
273
|
-
type: 'string',
|
|
274
|
-
},
|
|
211
|
+
contentType: { type: 'string' },
|
|
275
212
|
headers: mapOf('Header'),
|
|
276
213
|
style: {
|
|
277
214
|
enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
|
|
278
215
|
},
|
|
279
|
-
explode: {
|
|
280
|
-
|
|
281
|
-
},
|
|
282
|
-
allowReserved: {
|
|
283
|
-
type: 'boolean',
|
|
284
|
-
},
|
|
216
|
+
explode: { type: 'boolean' },
|
|
217
|
+
allowReserved: { type: 'boolean' },
|
|
285
218
|
},
|
|
286
219
|
};
|
|
287
220
|
|
|
288
221
|
const Header: NodeType = {
|
|
289
222
|
properties: {
|
|
290
|
-
description: {
|
|
291
|
-
|
|
292
|
-
},
|
|
293
|
-
|
|
294
|
-
type: 'boolean',
|
|
295
|
-
},
|
|
296
|
-
deprecated: {
|
|
297
|
-
type: 'boolean',
|
|
298
|
-
},
|
|
299
|
-
allowEmptyValue: {
|
|
300
|
-
type: 'boolean',
|
|
301
|
-
},
|
|
223
|
+
description: { type: 'string' },
|
|
224
|
+
required: { type: 'boolean' },
|
|
225
|
+
deprecated: { type: 'boolean' },
|
|
226
|
+
allowEmptyValue: { type: 'boolean' },
|
|
302
227
|
style: {
|
|
303
228
|
enum: ['form', 'simple', 'label', 'matrix', 'spaceDelimited', 'pipeDelimited', 'deepObject'],
|
|
304
229
|
},
|
|
305
|
-
explode: {
|
|
306
|
-
|
|
307
|
-
},
|
|
308
|
-
allowReserved: {
|
|
309
|
-
type: 'boolean',
|
|
310
|
-
},
|
|
230
|
+
explode: { type: 'boolean' },
|
|
231
|
+
allowReserved: { type: 'boolean' },
|
|
311
232
|
schema: 'Schema',
|
|
312
233
|
example: { isExample: true },
|
|
313
234
|
examples: mapOf('Example'),
|
|
@@ -316,18 +237,14 @@ const Header: NodeType = {
|
|
|
316
237
|
};
|
|
317
238
|
|
|
318
239
|
const ResponsesMap: NodeType = {
|
|
319
|
-
properties: {
|
|
320
|
-
default: 'Response',
|
|
321
|
-
},
|
|
240
|
+
properties: { default: 'Response' },
|
|
322
241
|
additionalProperties: (_v: any, key: string) =>
|
|
323
242
|
responseCodeRegexp.test(key) ? 'Response' : undefined,
|
|
324
243
|
};
|
|
325
244
|
|
|
326
245
|
const Response: NodeType = {
|
|
327
246
|
properties: {
|
|
328
|
-
description: {
|
|
329
|
-
type: 'string',
|
|
330
|
-
},
|
|
247
|
+
description: { type: 'string' },
|
|
331
248
|
headers: mapOf('Header'),
|
|
332
249
|
content: 'MediaTypeMap',
|
|
333
250
|
links: mapOf('Link'),
|
|
@@ -391,9 +308,7 @@ const Schema: NodeType = {
|
|
|
391
308
|
description: { type: 'string' },
|
|
392
309
|
format: { type: 'string' },
|
|
393
310
|
default: null,
|
|
394
|
-
|
|
395
311
|
nullable: { type: 'boolean' },
|
|
396
|
-
|
|
397
312
|
readOnly: { type: 'boolean' },
|
|
398
313
|
writeOnly: { type: 'boolean' },
|
|
399
314
|
xml: 'Xml',
|
|
@@ -456,7 +371,7 @@ const ImplicitFlow: NodeType = {
|
|
|
456
371
|
scopes: { type: 'object', additionalProperties: { type: 'string' } }, // TODO: validate scopes
|
|
457
372
|
authorizationUrl: { type: 'string' },
|
|
458
373
|
},
|
|
459
|
-
required: ['authorizationUrl', 'scopes']
|
|
374
|
+
required: ['authorizationUrl', 'scopes']
|
|
460
375
|
};
|
|
461
376
|
|
|
462
377
|
const PasswordFlow: NodeType = {
|
|
@@ -501,29 +416,41 @@ const SecurityScheme: NodeType = {
|
|
|
501
416
|
type: { enum: ['apiKey', 'http', 'oauth2', 'openIdConnect'] },
|
|
502
417
|
description: { type: 'string' },
|
|
503
418
|
name: { type: 'string' },
|
|
504
|
-
in: { type: 'string' },
|
|
419
|
+
in: { type: 'string', enum: ['query', 'header', 'cookie'] },
|
|
505
420
|
scheme: { type: 'string' },
|
|
506
421
|
bearerFormat: { type: 'string' },
|
|
507
422
|
flows: 'SecuritySchemeFlows',
|
|
508
423
|
openIdConnectUrl: { type: 'string' },
|
|
509
424
|
},
|
|
510
425
|
required(value) {
|
|
511
|
-
|
|
512
|
-
|
|
426
|
+
switch (value?.type) {
|
|
427
|
+
case 'apiKey':
|
|
428
|
+
return ['type', 'name', 'in'];
|
|
429
|
+
case 'http':
|
|
430
|
+
return ['type', 'scheme'];
|
|
431
|
+
case 'oauth2':
|
|
432
|
+
return ['type', 'flows'];
|
|
433
|
+
case 'openIdConnect':
|
|
434
|
+
return ['type', 'openIdConnectUrl'];
|
|
435
|
+
default:
|
|
436
|
+
return ['type'];
|
|
513
437
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
438
|
+
},
|
|
439
|
+
allowed(value) {
|
|
440
|
+
switch (value?.type) {
|
|
441
|
+
case 'apiKey':
|
|
442
|
+
return ['type', 'name', 'in', 'description'];
|
|
443
|
+
case 'http':
|
|
444
|
+
return ['type', 'scheme', 'bearerFormat', 'description'];
|
|
445
|
+
case 'oauth2':
|
|
446
|
+
return ['type', 'flows', 'description'];
|
|
447
|
+
case 'openIdConnect':
|
|
448
|
+
return ['type', 'openIdConnectUrl', 'description'];
|
|
449
|
+
default:
|
|
450
|
+
return ['type', 'description'];
|
|
523
451
|
}
|
|
524
|
-
|
|
525
|
-
return ['type'];
|
|
526
452
|
},
|
|
453
|
+
extensionsPrefix: 'x-',
|
|
527
454
|
};
|
|
528
455
|
|
|
529
456
|
export const Oas3Types: Record<string, NodeType> = {
|
package/src/types/oas3_1.ts
CHANGED
|
@@ -20,36 +20,20 @@ const DefinitionRoot: NodeType = {
|
|
|
20
20
|
|
|
21
21
|
const License: NodeType = {
|
|
22
22
|
properties: {
|
|
23
|
-
name: {
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
url: {
|
|
27
|
-
type: 'string',
|
|
28
|
-
},
|
|
29
|
-
identifier: {
|
|
30
|
-
type: 'string',
|
|
31
|
-
},
|
|
23
|
+
name: { type: 'string' },
|
|
24
|
+
url: { type: 'string' },
|
|
25
|
+
identifier: { type: 'string' },
|
|
32
26
|
},
|
|
33
27
|
required: ['name'],
|
|
34
28
|
};
|
|
35
29
|
|
|
36
30
|
const Info: NodeType = {
|
|
37
31
|
properties: {
|
|
38
|
-
title: {
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
description: {
|
|
45
|
-
type: 'string',
|
|
46
|
-
},
|
|
47
|
-
termsOfService: {
|
|
48
|
-
type: 'string',
|
|
49
|
-
},
|
|
50
|
-
summary: {
|
|
51
|
-
type: 'string',
|
|
52
|
-
},
|
|
32
|
+
title: { type: 'string' },
|
|
33
|
+
version: { type: 'string' },
|
|
34
|
+
description: { type: 'string' },
|
|
35
|
+
termsOfService: { type: 'string' },
|
|
36
|
+
summary: { type: 'string' },
|
|
53
37
|
contact: 'Contact',
|
|
54
38
|
license: 'License',
|
|
55
39
|
},
|
|
@@ -86,9 +70,7 @@ const Operation: NodeType = {
|
|
|
86
70
|
servers: listOf('Server'),
|
|
87
71
|
requestBody: 'RequestBody',
|
|
88
72
|
responses: 'ResponsesMap',
|
|
89
|
-
deprecated: {
|
|
90
|
-
type: 'boolean',
|
|
91
|
-
},
|
|
73
|
+
deprecated: { type: 'boolean' },
|
|
92
74
|
callbacks: mapOf('Callback'),
|
|
93
75
|
'x-codeSamples': listOf('XCodeSample'),
|
|
94
76
|
'x-code-samples': listOf('XCodeSample'), // deprecated
|
|
@@ -103,7 +85,6 @@ const Schema: NodeType = {
|
|
|
103
85
|
definitions: 'NamedSchemas',
|
|
104
86
|
$defs: 'NamedSchemas',
|
|
105
87
|
$vocabulary: { type: 'string' },
|
|
106
|
-
|
|
107
88
|
externalDocs: 'ExternalDocs',
|
|
108
89
|
discriminator: 'Discriminator',
|
|
109
90
|
myArbitraryKeyword: { type: 'boolean' },
|
|
@@ -140,35 +121,31 @@ const Schema: NodeType = {
|
|
|
140
121
|
then: 'Schema',
|
|
141
122
|
else: 'Schema',
|
|
142
123
|
dependentSchemas: listOf('Schema'),
|
|
143
|
-
prefixItems:
|
|
124
|
+
prefixItems: listOf('Schema'),
|
|
144
125
|
contains: 'Schema',
|
|
145
126
|
patternProperties: { type: 'object' },
|
|
146
127
|
propertyNames: 'Schema',
|
|
147
128
|
unevaluatedItems: 'Schema',
|
|
148
129
|
unevaluatedProperties: 'Schema',
|
|
149
130
|
summary: { type: 'string' },
|
|
150
|
-
|
|
151
131
|
properties: 'SchemaProperties',
|
|
152
132
|
items: (value: any) => {
|
|
153
133
|
if (Array.isArray(value)) {
|
|
154
134
|
return listOf('Schema');
|
|
135
|
+
} else if (typeof value === 'boolean') {
|
|
136
|
+
return { type: 'boolean' };
|
|
155
137
|
} else {
|
|
156
138
|
return 'Schema';
|
|
157
139
|
}
|
|
158
140
|
},
|
|
159
141
|
additionalProperties: (value: any) => {
|
|
160
|
-
|
|
161
|
-
return { type: 'boolean' };
|
|
162
|
-
} else {
|
|
163
|
-
return 'Schema';
|
|
164
|
-
}
|
|
142
|
+
return typeof value === 'boolean' ? { type: 'boolean' } : 'Schema';
|
|
165
143
|
},
|
|
166
144
|
description: { type: 'string' },
|
|
167
145
|
format: { type: 'string' },
|
|
168
146
|
contentEncoding: { type: 'string' },
|
|
169
147
|
contentMediaType: { type: 'string' },
|
|
170
148
|
default: null,
|
|
171
|
-
|
|
172
149
|
readOnly: { type: 'boolean' },
|
|
173
150
|
writeOnly: { type: 'boolean' },
|
|
174
151
|
xml: 'Xml',
|
|
@@ -185,29 +162,53 @@ const SecurityScheme: NodeType = {
|
|
|
185
162
|
type: { enum: ['apiKey', 'http', 'oauth2', 'openIdConnect', 'mutualTLS'] },
|
|
186
163
|
description: { type: 'string' },
|
|
187
164
|
name: { type: 'string' },
|
|
188
|
-
in: { type: 'string' },
|
|
165
|
+
in: { type: 'string', enum: ['query', 'header', 'cookie'] },
|
|
189
166
|
scheme: { type: 'string' },
|
|
190
167
|
bearerFormat: { type: 'string' },
|
|
191
168
|
flows: 'SecuritySchemeFlows',
|
|
192
169
|
openIdConnectUrl: { type: 'string' },
|
|
193
170
|
},
|
|
194
171
|
required(value) {
|
|
195
|
-
|
|
196
|
-
|
|
172
|
+
switch (value?.type) {
|
|
173
|
+
case 'apiKey':
|
|
174
|
+
return ['type', 'name', 'in'];
|
|
175
|
+
case 'http':
|
|
176
|
+
return ['type', 'scheme'];
|
|
177
|
+
case 'oauth2':
|
|
178
|
+
return ['type', 'flows'];
|
|
179
|
+
case 'openIdConnect':
|
|
180
|
+
return ['type', 'openIdConnectUrl'];
|
|
181
|
+
default:
|
|
182
|
+
return ['type'];
|
|
197
183
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
184
|
+
},
|
|
185
|
+
allowed(value) {
|
|
186
|
+
switch (value?.type) {
|
|
187
|
+
case 'apiKey':
|
|
188
|
+
return ['type', 'name', 'in', 'description'];
|
|
189
|
+
case 'http':
|
|
190
|
+
return ['type', 'scheme', 'bearerFormat', 'description'];
|
|
191
|
+
case 'oauth2':
|
|
192
|
+
switch (value?.flows) {
|
|
193
|
+
case 'implicit':
|
|
194
|
+
return ['type', 'flows', 'authorizationUrl', 'refreshUrl', 'description', 'scopes'];
|
|
195
|
+
case 'password':
|
|
196
|
+
case 'clientCredentials':
|
|
197
|
+
return ['type', 'flows', 'tokenUrl', 'refreshUrl', 'description', 'scopes'];
|
|
198
|
+
case 'authorizationCode':
|
|
199
|
+
return ['type', 'flows', 'authorizationUrl', 'refreshUrl', 'tokenUrl', 'description', 'scopes'];
|
|
200
|
+
default:
|
|
201
|
+
return ['type', 'flows', 'authorizationUrl', 'refreshUrl', 'tokenUrl', 'description', 'scopes'];
|
|
202
|
+
}
|
|
203
|
+
case 'openIdConnect':
|
|
204
|
+
return ['type', 'openIdConnectUrl', 'description'];
|
|
205
|
+
case 'mutualTLS':
|
|
206
|
+
return ['type', 'description'];
|
|
207
|
+
default:
|
|
208
|
+
return ['type', 'description'];
|
|
207
209
|
}
|
|
208
|
-
|
|
209
|
-
return ['type'];
|
|
210
210
|
},
|
|
211
|
+
extensionsPrefix: 'x-',
|
|
211
212
|
};
|
|
212
213
|
|
|
213
214
|
export const Oas3_1Types: Record<string, NodeType> = {
|