@redocly/openapi-core 1.25.15 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/__tests__/utils.ts +0 -3
- package/lib/bundle.js +3 -3
- package/lib/config/all.js +130 -48
- package/lib/config/builtIn.d.ts +1 -1
- package/lib/config/builtIn.js +5 -3
- package/lib/config/config-resolvers.js +9 -9
- package/lib/config/config.d.ts +2 -2
- package/lib/config/config.js +38 -20
- package/lib/config/minimal.js +125 -49
- package/lib/config/recommended-strict.js +124 -48
- package/lib/config/recommended.js +123 -47
- package/lib/config/rules.d.ts +2 -2
- package/lib/config/spec.d.ts +3 -0
- package/lib/config/spec.js +31 -0
- package/lib/config/types.d.ts +23 -23
- package/lib/config/utils.d.ts +1 -1
- package/lib/config/utils.js +33 -23
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/lint.js +3 -3
- package/lib/oas-types.d.ts +11 -11
- package/lib/oas-types.js +6 -6
- package/lib/rules/arazzo/criteria-unique.d.ts +2 -2
- package/lib/rules/arazzo/index.d.ts +2 -2
- package/lib/rules/arazzo/index.js +6 -4
- package/lib/rules/arazzo/parameters-unique.d.ts +2 -2
- package/lib/rules/arazzo/requestBody-replacements-unique.d.ts +2 -2
- package/lib/rules/arazzo/sourceDescription-type.d.ts +2 -0
- package/lib/rules/arazzo/{source-description-type.js → sourceDescription-type.js} +5 -3
- package/lib/rules/arazzo/sourceDescriptions-name-unique.d.ts +2 -2
- package/lib/rules/arazzo/sourceDescriptions-not-empty.d.ts +2 -0
- package/lib/rules/arazzo/sourceDescriptions-not-empty.js +18 -0
- package/lib/rules/arazzo/step-onFailure-unique.d.ts +2 -2
- package/lib/rules/arazzo/step-onSuccess-unique.d.ts +2 -2
- package/lib/rules/arazzo/stepId-unique.d.ts +2 -2
- package/lib/rules/arazzo/workflow-dependsOn.d.ts +2 -2
- package/lib/rules/arazzo/workflowId-unique.d.ts +2 -2
- package/lib/rules/async2/index.js +5 -2
- package/lib/rules/async3/index.js +5 -2
- package/lib/rules/common/assertions/index.d.ts +2 -2
- package/lib/rules/common/struct.d.ts +2 -0
- package/lib/rules/common/{spec.js → struct.js} +3 -3
- package/lib/rules/oas2/index.js +5 -2
- package/lib/rules/oas3/index.js +5 -2
- package/lib/rules/spot/no-actions-type-end.d.ts +2 -2
- package/lib/rules/spot/no-criteria-xpath.d.ts +2 -2
- package/lib/rules/spot/parameters-not-in-body.d.ts +2 -2
- package/lib/rules/spot/version-enum.d.ts +2 -2
- package/lib/types/arazzo.d.ts +1 -1
- package/lib/types/arazzo.js +3 -16
- package/lib/types/redocly-yaml.d.ts +6 -8
- package/lib/types/redocly-yaml.js +47 -12
- package/lib/typings/arazzo.d.ts +1 -6
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +3 -2
- package/lib/visitors.d.ts +5 -6
- package/package.json +1 -1
- package/src/__tests__/lint.test.ts +3 -3
- package/src/bundle.ts +3 -3
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +228 -70
- package/src/config/__tests__/__snapshots__/config.test.ts.snap +16 -3
- package/src/config/__tests__/config-resolvers.test.ts +14 -2
- package/src/config/__tests__/config.test.ts +11 -6
- package/src/config/all.ts +130 -48
- package/src/config/builtIn.ts +10 -8
- package/src/config/config-resolvers.ts +9 -9
- package/src/config/config.ts +46 -22
- package/src/config/minimal.ts +125 -49
- package/src/config/recommended-strict.ts +124 -48
- package/src/config/recommended.ts +123 -47
- package/src/config/rules.ts +2 -2
- package/src/config/spec.ts +32 -0
- package/src/config/types.ts +27 -33
- package/src/config/utils.ts +38 -26
- package/src/index.ts +1 -1
- package/src/lint.ts +6 -6
- package/src/oas-types.ts +19 -20
- package/src/rules/arazzo/__tests__/criteria-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/no-actions-type-end.test.ts +1 -2
- package/src/rules/arazzo/__tests__/no-criteria-xpath.test.ts +1 -2
- package/src/rules/arazzo/__tests__/parameters-not-in-body.test.ts +1 -2
- package/src/rules/arazzo/__tests__/parameters-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/requestBody-replacements-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/source-description-type.test.ts +2 -4
- package/src/rules/arazzo/__tests__/sourceDescription-name-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/sourceDescriptions-not-empty.test.ts +104 -0
- package/src/rules/arazzo/__tests__/step-onFailure-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/step-onSuccess-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/stepId-unique.test.ts +1 -2
- package/src/rules/arazzo/__tests__/version-enum.test.ts +1 -2
- package/src/rules/arazzo/__tests__/workflow-dependsOn.test.ts +3 -6
- package/src/rules/arazzo/__tests__/workflowId-unique.test.ts +2 -4
- package/src/rules/arazzo/criteria-unique.ts +2 -2
- package/src/rules/arazzo/index.ts +23 -21
- package/src/rules/arazzo/parameters-unique.ts +2 -2
- package/src/rules/arazzo/requestBody-replacements-unique.ts +2 -2
- package/src/rules/arazzo/{source-description-type.ts → sourceDescription-type.ts} +6 -5
- package/src/rules/arazzo/sourceDescriptions-name-unique.ts +2 -2
- package/src/rules/arazzo/sourceDescriptions-not-empty.ts +17 -0
- package/src/rules/arazzo/step-onFailure-unique.ts +2 -2
- package/src/rules/arazzo/step-onSuccess-unique.ts +2 -2
- package/src/rules/arazzo/stepId-unique.ts +2 -2
- package/src/rules/arazzo/workflow-dependsOn.ts +2 -2
- package/src/rules/arazzo/workflowId-unique.ts +2 -2
- package/src/rules/async2/index.ts +5 -2
- package/src/rules/async3/index.ts +5 -2
- package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -1
- package/src/rules/common/__tests__/{spec.test.ts → struct.test.ts} +35 -35
- package/src/rules/common/assertions/index.ts +2 -2
- package/src/rules/common/{spec.ts → struct.ts} +2 -2
- package/src/rules/oas2/index.ts +5 -2
- package/src/rules/oas3/__tests__/spec/spec.test.ts +10 -10
- package/src/rules/oas3/index.ts +5 -2
- package/src/rules/spot/no-actions-type-end.ts +2 -2
- package/src/rules/spot/no-criteria-xpath.ts +2 -2
- package/src/rules/spot/parameters-not-in-body.ts +2 -2
- package/src/rules/spot/version-enum.ts +2 -2
- package/src/types/arazzo.ts +2 -14
- package/src/types/redocly-yaml.ts +48 -16
- package/src/typings/arazzo.ts +1 -10
- package/src/utils.ts +4 -2
- package/src/visitors.ts +4 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/rules/arazzo/source-description-type.d.ts +0 -2
- package/lib/rules/common/spec.d.ts +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Assertions } from '../common/assertions';
|
|
2
|
-
import {
|
|
2
|
+
import { Struct } from '../common/struct';
|
|
3
3
|
import { InfoContact } from '../common/info-contact';
|
|
4
4
|
import { InfoLicenseStrict } from '../common/info-license-strict';
|
|
5
5
|
import { OperationOperationId } from '../common/operation-operationId';
|
|
@@ -12,7 +12,10 @@ import type { Async3Rule } from '../../visitors';
|
|
|
12
12
|
import type { Async3RuleSet } from '../../oas-types';
|
|
13
13
|
|
|
14
14
|
export const rules: Async3RuleSet<'built-in'> = {
|
|
15
|
-
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future
|
|
17
|
+
spec: Struct as Async3Rule,
|
|
18
|
+
struct: Struct as Async3Rule,
|
|
16
19
|
assertions: Assertions as Async3Rule,
|
|
17
20
|
'info-contact': InfoContact as Async3Rule,
|
|
18
21
|
'info-license-strict': InfoLicenseStrict as Async3Rule,
|
|
@@ -3,7 +3,7 @@ import { lintDocument } from '../../../lint';
|
|
|
3
3
|
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
|
|
4
4
|
import { BaseResolver } from '../../../resolve';
|
|
5
5
|
|
|
6
|
-
describe('Oas3
|
|
6
|
+
describe('Oas3 struct', () => {
|
|
7
7
|
it('should report missing schema property', async () => {
|
|
8
8
|
const document = parseYamlToDocument(
|
|
9
9
|
outdent`
|
|
@@ -25,7 +25,7 @@ describe('Oas3 spec', () => {
|
|
|
25
25
|
const results = await lintDocument({
|
|
26
26
|
externalRefResolver: new BaseResolver(),
|
|
27
27
|
document,
|
|
28
|
-
config: await makeConfig({ rules: {
|
|
28
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -40,7 +40,7 @@ describe('Oas3 spec', () => {
|
|
|
40
40
|
},
|
|
41
41
|
],
|
|
42
42
|
"message": "The field \`info\` must be present on this level.",
|
|
43
|
-
"ruleId": "
|
|
43
|
+
"ruleId": "struct",
|
|
44
44
|
"severity": "error",
|
|
45
45
|
"suggest": [],
|
|
46
46
|
},
|
|
@@ -54,7 +54,7 @@ describe('Oas3 spec', () => {
|
|
|
54
54
|
},
|
|
55
55
|
],
|
|
56
56
|
"message": "Must contain at least one of the following fields: schema, content.",
|
|
57
|
-
"ruleId": "
|
|
57
|
+
"ruleId": "struct",
|
|
58
58
|
"severity": "error",
|
|
59
59
|
"suggest": [],
|
|
60
60
|
},
|
|
@@ -85,7 +85,7 @@ describe('Oas3 spec', () => {
|
|
|
85
85
|
const results = await lintDocument({
|
|
86
86
|
externalRefResolver: new BaseResolver(),
|
|
87
87
|
document,
|
|
88
|
-
config: await makeConfig({ rules: {
|
|
88
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -100,7 +100,7 @@ describe('Oas3 spec', () => {
|
|
|
100
100
|
},
|
|
101
101
|
],
|
|
102
102
|
"message": "The field \`paths\` must be present on this level.",
|
|
103
|
-
"ruleId": "
|
|
103
|
+
"ruleId": "struct",
|
|
104
104
|
"severity": "error",
|
|
105
105
|
"suggest": [],
|
|
106
106
|
},
|
|
@@ -114,7 +114,7 @@ describe('Oas3 spec', () => {
|
|
|
114
114
|
},
|
|
115
115
|
],
|
|
116
116
|
"message": "The field \`info\` must be present on this level.",
|
|
117
|
-
"ruleId": "
|
|
117
|
+
"ruleId": "struct",
|
|
118
118
|
"severity": "error",
|
|
119
119
|
"suggest": [],
|
|
120
120
|
},
|
|
@@ -131,7 +131,7 @@ describe('Oas3 spec', () => {
|
|
|
131
131
|
},
|
|
132
132
|
],
|
|
133
133
|
"message": "Property \`content\` is not expected here.",
|
|
134
|
-
"ruleId": "
|
|
134
|
+
"ruleId": "struct",
|
|
135
135
|
"severity": "error",
|
|
136
136
|
"suggest": [],
|
|
137
137
|
},
|
|
@@ -157,7 +157,7 @@ describe('Oas3 spec', () => {
|
|
|
157
157
|
const results = await lintDocument({
|
|
158
158
|
externalRefResolver: new BaseResolver(),
|
|
159
159
|
document,
|
|
160
|
-
config: await makeConfig({ rules: {
|
|
160
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -172,7 +172,7 @@ describe('Oas3 spec', () => {
|
|
|
172
172
|
},
|
|
173
173
|
],
|
|
174
174
|
"message": "The field \`paths\` must be present on this level.",
|
|
175
|
-
"ruleId": "
|
|
175
|
+
"ruleId": "struct",
|
|
176
176
|
"severity": "error",
|
|
177
177
|
"suggest": [],
|
|
178
178
|
},
|
|
@@ -186,7 +186,7 @@ describe('Oas3 spec', () => {
|
|
|
186
186
|
},
|
|
187
187
|
],
|
|
188
188
|
"message": "The field \`info\` must be present on this level.",
|
|
189
|
-
"ruleId": "
|
|
189
|
+
"ruleId": "struct",
|
|
190
190
|
"severity": "error",
|
|
191
191
|
"suggest": [],
|
|
192
192
|
},
|
|
@@ -199,7 +199,7 @@ describe('Oas3 spec', () => {
|
|
|
199
199
|
},
|
|
200
200
|
],
|
|
201
201
|
"message": "The \`type\` field must be defined when the \`nullable\` field is used.",
|
|
202
|
-
"ruleId": "
|
|
202
|
+
"ruleId": "struct",
|
|
203
203
|
"severity": "error",
|
|
204
204
|
"suggest": [],
|
|
205
205
|
},
|
|
@@ -231,7 +231,7 @@ describe('Oas3 spec', () => {
|
|
|
231
231
|
const results = await lintDocument({
|
|
232
232
|
externalRefResolver: new BaseResolver(),
|
|
233
233
|
document,
|
|
234
|
-
config: await makeConfig({ rules: {
|
|
234
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
235
235
|
});
|
|
236
236
|
|
|
237
237
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -246,7 +246,7 @@ describe('Oas3 spec', () => {
|
|
|
246
246
|
},
|
|
247
247
|
],
|
|
248
248
|
"message": "The field \`paths\` must be present on this level.",
|
|
249
|
-
"ruleId": "
|
|
249
|
+
"ruleId": "struct",
|
|
250
250
|
"severity": "error",
|
|
251
251
|
"suggest": [],
|
|
252
252
|
},
|
|
@@ -260,7 +260,7 @@ describe('Oas3 spec', () => {
|
|
|
260
260
|
},
|
|
261
261
|
],
|
|
262
262
|
"message": "The field \`info\` must be present on this level.",
|
|
263
|
-
"ruleId": "
|
|
263
|
+
"ruleId": "struct",
|
|
264
264
|
"severity": "error",
|
|
265
265
|
"suggest": [],
|
|
266
266
|
},
|
|
@@ -273,7 +273,7 @@ describe('Oas3 spec', () => {
|
|
|
273
273
|
},
|
|
274
274
|
],
|
|
275
275
|
"message": "The \`type\` field must be defined when the \`nullable\` field is used.",
|
|
276
|
-
"ruleId": "
|
|
276
|
+
"ruleId": "struct",
|
|
277
277
|
"severity": "error",
|
|
278
278
|
"suggest": [],
|
|
279
279
|
},
|
|
@@ -287,7 +287,7 @@ describe('Oas3 spec', () => {
|
|
|
287
287
|
},
|
|
288
288
|
],
|
|
289
289
|
"message": "The field \`content\` must be present on this level.",
|
|
290
|
-
"ruleId": "
|
|
290
|
+
"ruleId": "struct",
|
|
291
291
|
"severity": "error",
|
|
292
292
|
"suggest": [],
|
|
293
293
|
},
|
|
@@ -301,7 +301,7 @@ describe('Oas3 spec', () => {
|
|
|
301
301
|
},
|
|
302
302
|
],
|
|
303
303
|
"message": "Property \`TestSchema\` is not expected here.",
|
|
304
|
-
"ruleId": "
|
|
304
|
+
"ruleId": "struct",
|
|
305
305
|
"severity": "error",
|
|
306
306
|
"suggest": [],
|
|
307
307
|
},
|
|
@@ -322,7 +322,7 @@ describe('Oas3 spec', () => {
|
|
|
322
322
|
const results = await lintDocument({
|
|
323
323
|
externalRefResolver: new BaseResolver(),
|
|
324
324
|
document,
|
|
325
|
-
config: await makeConfig({ rules: {
|
|
325
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
326
326
|
});
|
|
327
327
|
|
|
328
328
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -337,7 +337,7 @@ describe('Oas3 spec', () => {
|
|
|
337
337
|
},
|
|
338
338
|
],
|
|
339
339
|
"message": "The field \`paths\` must be present on this level.",
|
|
340
|
-
"ruleId": "
|
|
340
|
+
"ruleId": "struct",
|
|
341
341
|
"severity": "error",
|
|
342
342
|
"suggest": [],
|
|
343
343
|
},
|
|
@@ -351,7 +351,7 @@ describe('Oas3 spec', () => {
|
|
|
351
351
|
},
|
|
352
352
|
],
|
|
353
353
|
"message": "The field \`info\` must be present on this level.",
|
|
354
|
-
"ruleId": "
|
|
354
|
+
"ruleId": "struct",
|
|
355
355
|
"severity": "error",
|
|
356
356
|
"suggest": [],
|
|
357
357
|
},
|
|
@@ -360,7 +360,7 @@ describe('Oas3 spec', () => {
|
|
|
360
360
|
});
|
|
361
361
|
});
|
|
362
362
|
|
|
363
|
-
describe('Oas3.1
|
|
363
|
+
describe('Oas3.1 struct', () => {
|
|
364
364
|
it('should report with "type can be one of the following only"', async () => {
|
|
365
365
|
const document = parseYamlToDocument(
|
|
366
366
|
outdent`
|
|
@@ -384,7 +384,7 @@ describe('Oas3.1 spec', () => {
|
|
|
384
384
|
const results = await lintDocument({
|
|
385
385
|
externalRefResolver: new BaseResolver(),
|
|
386
386
|
document,
|
|
387
|
-
config: await makeConfig({ rules: {
|
|
387
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
388
388
|
});
|
|
389
389
|
|
|
390
390
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -399,7 +399,7 @@ describe('Oas3.1 spec', () => {
|
|
|
399
399
|
},
|
|
400
400
|
],
|
|
401
401
|
"message": "\`type\` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".",
|
|
402
|
-
"ruleId": "
|
|
402
|
+
"ruleId": "struct",
|
|
403
403
|
"severity": "error",
|
|
404
404
|
"suggest": [],
|
|
405
405
|
},
|
|
@@ -432,7 +432,7 @@ describe('Oas3.1 spec', () => {
|
|
|
432
432
|
const results = await lintDocument({
|
|
433
433
|
externalRefResolver: new BaseResolver(),
|
|
434
434
|
document,
|
|
435
|
-
config: await makeConfig({ rules: {
|
|
435
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
436
436
|
});
|
|
437
437
|
|
|
438
438
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -447,7 +447,7 @@ describe('Oas3.1 spec', () => {
|
|
|
447
447
|
},
|
|
448
448
|
],
|
|
449
449
|
"message": "\`type\` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".",
|
|
450
|
-
"ruleId": "
|
|
450
|
+
"ruleId": "struct",
|
|
451
451
|
"severity": "error",
|
|
452
452
|
"suggest": [],
|
|
453
453
|
},
|
|
@@ -486,7 +486,7 @@ describe('Oas3.1 spec', () => {
|
|
|
486
486
|
const results = await lintDocument({
|
|
487
487
|
externalRefResolver: new BaseResolver(),
|
|
488
488
|
document,
|
|
489
|
-
config: await makeConfig({ rules: {
|
|
489
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
490
490
|
});
|
|
491
491
|
|
|
492
492
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -501,7 +501,7 @@ describe('Oas3.1 spec', () => {
|
|
|
501
501
|
},
|
|
502
502
|
],
|
|
503
503
|
"message": "\`type\` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".",
|
|
504
|
-
"ruleId": "
|
|
504
|
+
"ruleId": "struct",
|
|
505
505
|
"severity": "error",
|
|
506
506
|
"suggest": [
|
|
507
507
|
"object",
|
|
@@ -523,7 +523,7 @@ describe('Oas3.1 spec', () => {
|
|
|
523
523
|
},
|
|
524
524
|
],
|
|
525
525
|
"message": "\`type\` can be one of the following only: "object", "array", "string", "number", "integer", "boolean", "null".",
|
|
526
|
-
"ruleId": "
|
|
526
|
+
"ruleId": "struct",
|
|
527
527
|
"severity": "error",
|
|
528
528
|
"suggest": [
|
|
529
529
|
"object",
|
|
@@ -557,7 +557,7 @@ describe('Oas3.1 spec', () => {
|
|
|
557
557
|
const results = await lintDocument({
|
|
558
558
|
externalRefResolver: new BaseResolver(),
|
|
559
559
|
document,
|
|
560
|
-
config: await makeConfig({ rules: {
|
|
560
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
561
561
|
});
|
|
562
562
|
|
|
563
563
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -572,7 +572,7 @@ describe('Oas3.1 spec', () => {
|
|
|
572
572
|
},
|
|
573
573
|
],
|
|
574
574
|
"message": "Must contain at least one of the following fields: paths, components, webhooks.",
|
|
575
|
-
"ruleId": "
|
|
575
|
+
"ruleId": "struct",
|
|
576
576
|
"severity": "error",
|
|
577
577
|
"suggest": [],
|
|
578
578
|
},
|
|
@@ -586,7 +586,7 @@ describe('Oas3.1 spec', () => {
|
|
|
586
586
|
},
|
|
587
587
|
],
|
|
588
588
|
"message": "The field \`title\` must be present on this level.",
|
|
589
|
-
"ruleId": "
|
|
589
|
+
"ruleId": "struct",
|
|
590
590
|
"severity": "error",
|
|
591
591
|
"suggest": [],
|
|
592
592
|
},
|
|
@@ -600,7 +600,7 @@ describe('Oas3.1 spec', () => {
|
|
|
600
600
|
},
|
|
601
601
|
],
|
|
602
602
|
"message": "The field \`version\` must be present on this level.",
|
|
603
|
-
"ruleId": "
|
|
603
|
+
"ruleId": "struct",
|
|
604
604
|
"severity": "error",
|
|
605
605
|
"suggest": [],
|
|
606
606
|
},
|
|
@@ -632,7 +632,7 @@ describe('Oas3.1 spec', () => {
|
|
|
632
632
|
const results = await lintDocument({
|
|
633
633
|
externalRefResolver: new BaseResolver(),
|
|
634
634
|
document,
|
|
635
|
-
config: await makeConfig({ rules: {
|
|
635
|
+
config: await makeConfig({ rules: { struct: 'error' } }),
|
|
636
636
|
});
|
|
637
637
|
|
|
638
638
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
@@ -647,7 +647,7 @@ describe('Oas3.1 spec', () => {
|
|
|
647
647
|
},
|
|
648
648
|
],
|
|
649
649
|
"message": "Expected type \`SchemaMap\` (object) but got \`array\`",
|
|
650
|
-
"ruleId": "
|
|
650
|
+
"ruleId": "struct",
|
|
651
651
|
"severity": "error",
|
|
652
652
|
"suggest": [],
|
|
653
653
|
},
|
|
@@ -3,7 +3,7 @@ import { isString } from '../../../utils';
|
|
|
3
3
|
|
|
4
4
|
import type { asserts, AssertionFn } from './asserts';
|
|
5
5
|
import type {
|
|
6
|
-
|
|
6
|
+
Arazzo1Visitor,
|
|
7
7
|
Async2Visitor,
|
|
8
8
|
Async3Visitor,
|
|
9
9
|
Oas2Visitor,
|
|
@@ -35,7 +35,7 @@ export type RawAssertion = AssertionDefinition & {
|
|
|
35
35
|
export type Assertion = RawAssertion & { assertionId: string };
|
|
36
36
|
|
|
37
37
|
export const Assertions = (opts: Record<string, Assertion>) => {
|
|
38
|
-
const visitors: (Oas2Visitor | Oas3Visitor | Async2Visitor | Async3Visitor |
|
|
38
|
+
const visitors: (Oas2Visitor | Oas3Visitor | Async2Visitor | Async3Visitor | Arazzo1Visitor)[] =
|
|
39
39
|
[];
|
|
40
40
|
|
|
41
41
|
// As 'Assertions' has an array of asserts,
|
|
@@ -4,9 +4,9 @@ import { isRef } from '../../ref-utils';
|
|
|
4
4
|
import { isPlainObject } from '../../utils';
|
|
5
5
|
|
|
6
6
|
import type { UserContext } from '../../walk';
|
|
7
|
-
import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule,
|
|
7
|
+
import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule, Arazzo1Rule } from '../../visitors';
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const Struct: Oas3Rule | Oas2Rule | Async2Rule | Async3Rule | Arazzo1Rule = () => {
|
|
10
10
|
return {
|
|
11
11
|
any(
|
|
12
12
|
node: any,
|
package/src/rules/oas2/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Struct } from '../common/struct';
|
|
2
2
|
import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples';
|
|
3
3
|
import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples';
|
|
4
4
|
import { InfoContact } from '../common/info-contact';
|
|
@@ -47,7 +47,10 @@ import type { Oas2Rule } from '../../visitors';
|
|
|
47
47
|
import type { Oas2RuleSet } from '../../oas-types';
|
|
48
48
|
|
|
49
49
|
export const rules: Oas2RuleSet<'built-in'> = {
|
|
50
|
-
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
51
|
+
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future
|
|
52
|
+
spec: Struct as Oas2Rule,
|
|
53
|
+
struct: Struct as Oas2Rule,
|
|
51
54
|
'no-invalid-schema-examples': NoInvalidSchemaExamples,
|
|
52
55
|
'no-invalid-parameter-examples': NoInvalidParameterExamples,
|
|
53
56
|
'info-contact': InfoContact as Oas2Rule,
|
|
@@ -65,7 +65,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
65
65
|
},
|
|
66
66
|
],
|
|
67
67
|
"message": "Expected type \`string\` but got \`array\`.",
|
|
68
|
-
"ruleId": "
|
|
68
|
+
"ruleId": "struct",
|
|
69
69
|
"severity": "error",
|
|
70
70
|
"suggest": [],
|
|
71
71
|
},
|
|
@@ -79,7 +79,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
79
79
|
},
|
|
80
80
|
],
|
|
81
81
|
"message": "Expected type \`string\` but got \`boolean\`.",
|
|
82
|
-
"ruleId": "
|
|
82
|
+
"ruleId": "struct",
|
|
83
83
|
"severity": "error",
|
|
84
84
|
"suggest": [],
|
|
85
85
|
},
|
|
@@ -93,7 +93,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
93
93
|
},
|
|
94
94
|
],
|
|
95
95
|
"message": "Expected type \`License\` (object) but got \`string\`",
|
|
96
|
-
"ruleId": "
|
|
96
|
+
"ruleId": "struct",
|
|
97
97
|
"severity": "error",
|
|
98
98
|
"suggest": [],
|
|
99
99
|
},
|
|
@@ -124,7 +124,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
124
124
|
},
|
|
125
125
|
],
|
|
126
126
|
"message": "Expected type \`string\` but got \`integer\`.",
|
|
127
|
-
"ruleId": "
|
|
127
|
+
"ruleId": "struct",
|
|
128
128
|
"severity": "error",
|
|
129
129
|
"suggest": [],
|
|
130
130
|
},
|
|
@@ -138,7 +138,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
138
138
|
},
|
|
139
139
|
],
|
|
140
140
|
"message": "Expected type \`Tag\` (object) but got \`number\`",
|
|
141
|
-
"ruleId": "
|
|
141
|
+
"ruleId": "struct",
|
|
142
142
|
"severity": "error",
|
|
143
143
|
"suggest": [],
|
|
144
144
|
},
|
|
@@ -152,7 +152,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
152
152
|
},
|
|
153
153
|
],
|
|
154
154
|
"message": "Expected type \`Tag\` (object) but got \`string\`",
|
|
155
|
-
"ruleId": "
|
|
155
|
+
"ruleId": "struct",
|
|
156
156
|
"severity": "error",
|
|
157
157
|
"suggest": [],
|
|
158
158
|
},
|
|
@@ -199,7 +199,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
199
199
|
},
|
|
200
200
|
],
|
|
201
201
|
"message": "Property \`components1\` is not expected here.",
|
|
202
|
-
"ruleId": "
|
|
202
|
+
"ruleId": "struct",
|
|
203
203
|
"severity": "error",
|
|
204
204
|
"suggest": [
|
|
205
205
|
"components",
|
|
@@ -228,7 +228,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
228
228
|
},
|
|
229
229
|
],
|
|
230
230
|
"message": "Property \`test\` is not expected here.",
|
|
231
|
-
"ruleId": "
|
|
231
|
+
"ruleId": "struct",
|
|
232
232
|
"severity": "error",
|
|
233
233
|
"suggest": [],
|
|
234
234
|
},
|
|
@@ -270,7 +270,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
270
270
|
},
|
|
271
271
|
],
|
|
272
272
|
"message": "The field \`paths\` must be present on this level.",
|
|
273
|
-
"ruleId": "
|
|
273
|
+
"ruleId": "struct",
|
|
274
274
|
"severity": "error",
|
|
275
275
|
"suggest": [],
|
|
276
276
|
},
|
|
@@ -297,7 +297,7 @@ describe('Oas3 Structural visitor basic', () => {
|
|
|
297
297
|
},
|
|
298
298
|
],
|
|
299
299
|
"message": "The field \`title\` must be present on this level.",
|
|
300
|
-
"ruleId": "
|
|
300
|
+
"ruleId": "struct",
|
|
301
301
|
"severity": "error",
|
|
302
302
|
"suggest": [],
|
|
303
303
|
},
|
package/src/rules/oas3/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Struct } from '../common/struct';
|
|
2
2
|
import { Operation2xxResponse } from '../common/operation-2xx-response';
|
|
3
3
|
import { Operation4xxResponse } from '../common/operation-4xx-response';
|
|
4
4
|
import { Assertions } from '../common/assertions';
|
|
@@ -59,7 +59,10 @@ import type { Oas3RuleSet } from '../../oas-types';
|
|
|
59
59
|
import type { Oas3Rule } from '../../visitors';
|
|
60
60
|
|
|
61
61
|
export const rules: Oas3RuleSet<'built-in'> = {
|
|
62
|
-
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
63
|
+
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future
|
|
64
|
+
spec: Struct as Oas3Rule,
|
|
65
|
+
struct: Struct as Oas3Rule,
|
|
63
66
|
'info-contact': InfoContact as Oas3Rule,
|
|
64
67
|
'info-license': InfoLicense as Oas3Rule,
|
|
65
68
|
'info-license-url': InfoLicenseUrl as Oas3Rule,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const NoActionsTypeEnd:
|
|
4
|
+
export const NoActionsTypeEnd: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
FailureActionObject: {
|
|
7
7
|
enter(action, { report, location }: UserContext) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const NoCriteriaXpath:
|
|
4
|
+
export const NoCriteriaXpath: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
CriterionObject: {
|
|
7
7
|
enter(criteria, { report, location }: UserContext) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
2
2
|
import type { UserContext } from '../../walk';
|
|
3
3
|
|
|
4
|
-
export const ParametersNotInBody:
|
|
4
|
+
export const ParametersNotInBody: Arazzo1Rule = () => {
|
|
5
5
|
return {
|
|
6
6
|
Parameter: {
|
|
7
7
|
enter(parameter, { report, location }: UserContext) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ARAZZO_VERSIONS_SUPPORTED_BY_SPOT } from '../../typings/arazzo';
|
|
2
2
|
import { pluralize } from '../../utils';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { Arazzo1Rule } from '../../visitors';
|
|
5
5
|
import type { UserContext } from '../../walk';
|
|
6
6
|
|
|
7
|
-
export const VersionEnum:
|
|
7
|
+
export const VersionEnum: Arazzo1Rule = () => {
|
|
8
8
|
const supportedVersions = ARAZZO_VERSIONS_SUPPORTED_BY_SPOT.join(', ');
|
|
9
9
|
return {
|
|
10
10
|
Root: {
|
package/src/types/arazzo.ts
CHANGED
|
@@ -50,10 +50,8 @@ const SourceDescriptions: NodeType = {
|
|
|
50
50
|
items: (value: any) => {
|
|
51
51
|
if (value?.type === 'openapi') {
|
|
52
52
|
return 'OpenAPISourceDescription';
|
|
53
|
-
} else if (value?.type === 'arazzo') {
|
|
54
|
-
return 'ArazzoSourceDescription';
|
|
55
53
|
} else {
|
|
56
|
-
return '
|
|
54
|
+
return 'ArazzoSourceDescription';
|
|
57
55
|
}
|
|
58
56
|
},
|
|
59
57
|
};
|
|
@@ -67,15 +65,6 @@ const OpenAPISourceDescription: NodeType = {
|
|
|
67
65
|
required: ['name', 'type', 'url'],
|
|
68
66
|
extensionsPrefix: 'x-',
|
|
69
67
|
};
|
|
70
|
-
const NoneSourceDescription: NodeType = {
|
|
71
|
-
properties: {
|
|
72
|
-
name: { type: 'string' },
|
|
73
|
-
type: { type: 'string', enum: ['none'] },
|
|
74
|
-
'x-serverUrl': { type: 'string' },
|
|
75
|
-
},
|
|
76
|
-
required: ['name', 'type', 'x-serverUrl'],
|
|
77
|
-
extensionsPrefix: 'x-',
|
|
78
|
-
};
|
|
79
68
|
const ArazzoSourceDescription: NodeType = {
|
|
80
69
|
properties: {
|
|
81
70
|
name: { type: 'string' },
|
|
@@ -273,12 +262,11 @@ const OnFailureActionList: NodeType = {
|
|
|
273
262
|
},
|
|
274
263
|
};
|
|
275
264
|
|
|
276
|
-
export const
|
|
265
|
+
export const Arazzo1Types: Record<string, NodeType> = {
|
|
277
266
|
Root,
|
|
278
267
|
Info,
|
|
279
268
|
SourceDescriptions,
|
|
280
269
|
OpenAPISourceDescription,
|
|
281
|
-
NoneSourceDescription,
|
|
282
270
|
ArazzoSourceDescription,
|
|
283
271
|
Parameters,
|
|
284
272
|
Parameter,
|