@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.
Files changed (108) hide show
  1. package/__tests__/utils.ts +11 -1
  2. package/lib/bundle.d.ts +3 -1
  3. package/lib/bundle.js +30 -8
  4. package/lib/config/builtIn.js +18 -4
  5. package/lib/config/config.d.ts +2 -9
  6. package/lib/{rules → decorators}/common/info-description-override.d.ts +0 -0
  7. package/lib/{rules → decorators}/common/info-description-override.js +0 -0
  8. package/lib/{rules → decorators}/common/operation-description-override.d.ts +0 -0
  9. package/lib/{rules → decorators}/common/operation-description-override.js +0 -0
  10. package/lib/{rules → decorators}/common/registry-dependencies.d.ts +0 -0
  11. package/lib/{rules → decorators}/common/registry-dependencies.js +0 -0
  12. package/lib/decorators/common/remove-x-internal.d.ts +2 -0
  13. package/lib/decorators/common/remove-x-internal.js +58 -0
  14. package/lib/{rules → decorators}/common/tag-description-override.d.ts +0 -0
  15. package/lib/{rules → decorators}/common/tag-description-override.js +0 -0
  16. package/lib/decorators/oas2/index.d.ts +8 -0
  17. package/lib/decorators/oas2/index.js +15 -0
  18. package/lib/decorators/oas3/index.d.ts +8 -0
  19. package/lib/decorators/oas3/index.js +15 -0
  20. package/lib/js-yaml/index.js +1 -1
  21. package/lib/redocly/registry-api.js +4 -1
  22. package/lib/resolve.d.ts +1 -0
  23. package/lib/resolve.js +7 -3
  24. package/lib/rules/common/operation-security-defined.js +1 -4
  25. package/lib/rules/common/spec.js +18 -3
  26. package/lib/rules/oas2/index.d.ts +1 -7
  27. package/lib/rules/oas2/index.js +1 -11
  28. package/lib/rules/oas2/remove-unused-components.d.ts +2 -0
  29. package/lib/rules/oas2/remove-unused-components.js +73 -0
  30. package/lib/rules/oas3/index.d.ts +0 -7
  31. package/lib/rules/oas3/index.js +1 -11
  32. package/lib/rules/oas3/no-invalid-media-type-examples.js +12 -11
  33. package/lib/rules/oas3/remove-unused-components.d.ts +2 -0
  34. package/lib/rules/oas3/remove-unused-components.js +83 -0
  35. package/lib/types/index.d.ts +4 -0
  36. package/lib/types/oas2.js +42 -35
  37. package/lib/types/oas3.js +68 -139
  38. package/lib/types/oas3_1.js +52 -49
  39. package/lib/typings/swagger.d.ts +14 -0
  40. package/lib/utils.d.ts +2 -0
  41. package/lib/utils.js +10 -2
  42. package/lib/walk.js +5 -8
  43. package/package.json +1 -1
  44. package/src/__tests__/js-yaml.test.ts +29 -5
  45. package/src/__tests__/lint.test.ts +1 -3
  46. package/src/bundle.ts +37 -8
  47. package/src/config/builtIn.ts +20 -7
  48. package/src/config/config.ts +2 -3
  49. package/src/decorators/__tests__/remove-x-internal.test.ts +316 -0
  50. package/src/{rules → decorators}/common/info-description-override.ts +0 -0
  51. package/src/{rules → decorators}/common/operation-description-override.ts +0 -0
  52. package/src/{rules → decorators}/common/registry-dependencies.ts +0 -0
  53. package/src/decorators/common/remove-x-internal.ts +59 -0
  54. package/src/{rules → decorators}/common/tag-description-override.ts +0 -0
  55. package/src/decorators/oas2/index.ts +14 -0
  56. package/src/decorators/oas3/index.ts +14 -0
  57. package/src/js-yaml/index.ts +1 -2
  58. package/src/redocly/registry-api.ts +7 -1
  59. package/src/resolve.ts +6 -6
  60. package/src/rules/__tests__/no-unresolved-refs.test.ts +1 -4
  61. package/src/rules/common/__tests__/info-description.test.ts +1 -3
  62. package/src/rules/common/__tests__/info-license.test.ts +1 -2
  63. package/src/rules/common/__tests__/license-url.test.ts +1 -2
  64. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -2
  65. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -2
  66. package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -2
  67. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +1 -2
  68. package/src/rules/common/__tests__/operation-2xx-response.test.ts +1 -2
  69. package/src/rules/common/__tests__/operation-4xx-response.test.ts +1 -2
  70. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +1 -2
  71. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -2
  72. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +1 -2
  73. package/src/rules/common/__tests__/operation-security-defined.test.ts +1 -2
  74. package/src/rules/common/__tests__/operation-singular-tag.test.ts +1 -2
  75. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +1 -2
  76. package/src/rules/common/__tests__/path-not-include-query.test.ts +1 -2
  77. package/src/rules/common/__tests__/path-params-defined.test.ts +1 -2
  78. package/src/rules/common/__tests__/paths-kebab-case.test.ts +1 -2
  79. package/src/rules/common/__tests__/tag-description.test.ts +1 -2
  80. package/src/rules/common/__tests__/tags-alphabetical.test.ts +1 -2
  81. package/src/rules/common/operation-security-defined.ts +4 -5
  82. package/src/rules/common/spec.ts +18 -0
  83. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +1 -2
  84. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -2
  85. package/src/rules/oas2/index.ts +1 -11
  86. package/src/rules/oas2/remove-unused-components.ts +76 -0
  87. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +1 -2
  88. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +1 -2
  89. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +1 -2
  90. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +1 -2
  91. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +1 -2
  92. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +1 -2
  93. package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -2
  94. package/src/rules/oas3/index.ts +0 -12
  95. package/src/rules/oas3/no-invalid-media-type-examples.ts +17 -21
  96. package/src/rules/oas3/remove-unused-components.ts +84 -0
  97. package/src/types/index.ts +4 -0
  98. package/src/types/oas2.ts +42 -43
  99. package/src/types/oas3.ts +68 -141
  100. package/src/types/oas3_1.ts +51 -50
  101. package/src/typings/swagger.ts +7 -0
  102. package/src/utils.ts +9 -1
  103. package/src/walk.ts +6 -13
  104. package/tsconfig.tsbuildinfo +1 -1
  105. package/lib/rules/builtin.d.ts +0 -20
  106. package/lib/rules/builtin.js +0 -17
  107. package/src/rules/__tests__/config.ts +0 -10
  108. 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', 'cookie'] },
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
- if (!value?.type) {
334
- return ['type'];
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
- if (value.type === 'apiKey') {
338
- return ['type', 'name', 'in'];
339
- } else if (value.type === 'http') {
340
- return ['type', 'scheme'];
341
- } else if (value.type === 'oauth2') {
342
- if (!value?.flow) {
343
- return ['type', 'flow'];
344
- } else if (value.flow === 'implicit') {
345
- return ['type', 'flow', 'authorizationUrl'];
346
- } else if (value.flow === 'accessCode') {
347
- return ['type', 'flow', 'authorizationUrl', 'tokenUrl'];
348
- } else if (value.flow === 'application') {
349
- return ['type', 'flow', 'tokenUrl'];
350
- } else if (value.flow === 'password') {
351
- return ['type', 'flow', 'tokenUrl'];
352
- } else {
353
- return ['type', 'flow'];
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 = {
@@ -383,13 +385,10 @@ export const Oas2Types: Record<string, NodeType> = {
383
385
  Schema,
384
386
  Xml,
385
387
  SchemaProperties,
386
-
387
388
  NamedSchemas: mapOf('Schema'),
388
389
  NamedResponses: mapOf('Response'),
389
390
  NamedParameters: mapOf('Parameter'),
390
391
  NamedSecuritySchemes: mapOf('SecurityScheme'),
391
-
392
392
  SecurityScheme,
393
-
394
393
  XCodeSample,
395
394
  };
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
- type: 'string',
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
- type: 'string',
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
- type: 'string',
78
- },
79
- version: {
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
- type: 'string',
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
- type: 'string',
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
- type: 'string',
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
- type: 'string',
157
- },
158
- in: {
159
- enum: ['query', 'header', 'path', 'cookie'],
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
- type: 'boolean',
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
- type: 'string',
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
- type: 'string',
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
- type: 'boolean',
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
- type: 'string',
292
- },
293
- required: {
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
- type: 'boolean',
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
- if (!value?.type) {
512
- return ['type'];
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
- if (value.type === 'apiKey') {
516
- return ['type', 'name', 'in'];
517
- } else if (value.type === 'http') {
518
- return ['type', 'scheme'];
519
- } else if (value.type === 'oauth2') {
520
- return ['type', 'flows'];
521
- } else if (value.type === 'openIdConnect') {
522
- return ['type', 'openIdConnectUrl'];
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> = {