@redocly/openapi-core 1.0.0-beta.108 → 1.0.0-beta.110

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 (159) hide show
  1. package/README.md +2 -2
  2. package/lib/benchmark/benches/resolve-with-no-external.bench.js +1 -1
  3. package/lib/bundle.d.ts +1 -1
  4. package/lib/bundle.js +4 -4
  5. package/lib/config/all.js +3 -1
  6. package/lib/config/config-resolvers.js +22 -4
  7. package/lib/config/config.d.ts +1 -0
  8. package/lib/config/config.js +1 -0
  9. package/lib/config/load.d.ts +8 -2
  10. package/lib/config/load.js +4 -2
  11. package/lib/config/minimal.js +3 -1
  12. package/lib/config/recommended.js +3 -1
  13. package/lib/config/rules.js +1 -1
  14. package/lib/config/types.d.ts +17 -0
  15. package/lib/config/utils.d.ts +2 -2
  16. package/lib/config/utils.js +44 -6
  17. package/lib/decorators/common/registry-dependencies.js +1 -1
  18. package/lib/format/format.d.ts +1 -1
  19. package/lib/format/format.js +22 -1
  20. package/lib/lint.js +2 -2
  21. package/lib/redocly/registry-api.d.ts +0 -1
  22. package/lib/redocly/registry-api.js +5 -4
  23. package/lib/resolve.js +3 -1
  24. package/lib/rules/ajv.d.ts +1 -1
  25. package/lib/rules/ajv.js +5 -5
  26. package/lib/rules/common/assertions/asserts.d.ts +3 -5
  27. package/lib/rules/common/assertions/asserts.js +137 -97
  28. package/lib/rules/common/assertions/index.js +2 -6
  29. package/lib/rules/common/assertions/utils.d.ts +12 -6
  30. package/lib/rules/common/assertions/utils.js +33 -20
  31. package/lib/rules/common/no-ambiguous-paths.js +1 -1
  32. package/lib/rules/common/no-identical-paths.js +1 -1
  33. package/lib/rules/common/operation-2xx-response.js +1 -1
  34. package/lib/rules/common/operation-4xx-response.js +1 -1
  35. package/lib/rules/common/operation-operationId.js +1 -1
  36. package/lib/rules/common/operation-tag-defined.js +1 -1
  37. package/lib/rules/common/path-not-include-query.js +1 -1
  38. package/lib/rules/common/security-defined.d.ts +2 -0
  39. package/lib/rules/common/{operation-security-defined.js → security-defined.js} +18 -4
  40. package/lib/rules/common/spec.js +12 -1
  41. package/lib/rules/common/tags-alphabetical.js +1 -1
  42. package/lib/rules/oas2/index.d.ts +1 -1
  43. package/lib/rules/oas2/index.js +2 -2
  44. package/lib/rules/oas2/remove-unused-components.js +1 -1
  45. package/lib/rules/oas2/request-mime-type.js +1 -1
  46. package/lib/rules/oas2/response-mime-type.js +1 -1
  47. package/lib/rules/oas3/index.js +6 -2
  48. package/lib/rules/oas3/no-empty-servers.js +1 -1
  49. package/lib/rules/oas3/no-server-variables-empty-enum.js +1 -1
  50. package/lib/rules/oas3/no-unused-components.js +1 -1
  51. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +5 -0
  52. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +36 -0
  53. package/lib/rules/oas3/remove-unused-components.js +1 -1
  54. package/lib/rules/oas3/request-mime-type.js +1 -1
  55. package/lib/rules/oas3/response-mime-type.js +1 -1
  56. package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +2 -0
  57. package/lib/rules/oas3/spec-components-invalid-map-name.js +46 -0
  58. package/lib/rules/other/stats.d.ts +2 -2
  59. package/lib/rules/other/stats.js +2 -2
  60. package/lib/rules/utils.js +1 -1
  61. package/lib/types/oas2.js +5 -5
  62. package/lib/types/oas3.js +27 -20
  63. package/lib/types/oas3_1.js +3 -3
  64. package/lib/types/redocly-yaml.js +60 -54
  65. package/lib/utils.d.ts +3 -3
  66. package/lib/utils.js +5 -5
  67. package/lib/visitors.d.ts +11 -11
  68. package/lib/visitors.js +13 -1
  69. package/package.json +3 -5
  70. package/src/__tests__/__snapshots__/bundle.test.ts.snap +3 -3
  71. package/src/__tests__/fixtures/extension.js +3 -3
  72. package/src/__tests__/format.test.ts +76 -0
  73. package/src/__tests__/lint.test.ts +184 -121
  74. package/src/__tests__/resolve-http.test.ts +1 -1
  75. package/src/__tests__/resolve.test.ts +9 -9
  76. package/src/__tests__/walk.test.ts +78 -10
  77. package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
  78. package/src/bundle.ts +4 -4
  79. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +6 -2
  80. package/src/config/__tests__/config-resolvers.test.ts +37 -1
  81. package/src/config/__tests__/config.test.ts +5 -0
  82. package/src/config/__tests__/fixtures/plugin-config.yaml +2 -3
  83. package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +11 -12
  84. package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +7 -8
  85. package/src/config/__tests__/fixtures/resolve-config/local-config-with-custom-function.yaml +16 -0
  86. package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +18 -19
  87. package/src/config/__tests__/fixtures/resolve-config/local-config-with-wrong-custom-function.yaml +16 -0
  88. package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +9 -10
  89. package/src/config/__tests__/fixtures/resolve-config/plugin.js +11 -0
  90. package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +3 -4
  91. package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +4 -5
  92. package/src/config/__tests__/load.test.ts +13 -16
  93. package/src/config/__tests__/resolve-plugins.test.ts +3 -3
  94. package/src/config/__tests__/utils.test.ts +64 -4
  95. package/src/config/all.ts +3 -1
  96. package/src/config/config-resolvers.ts +30 -7
  97. package/src/config/config.ts +2 -0
  98. package/src/config/load.ts +13 -6
  99. package/src/config/minimal.ts +3 -1
  100. package/src/config/recommended.ts +3 -1
  101. package/src/config/rules.ts +2 -2
  102. package/src/config/types.ts +24 -0
  103. package/src/config/utils.ts +103 -13
  104. package/src/decorators/common/registry-dependencies.ts +1 -1
  105. package/src/format/format.ts +32 -2
  106. package/src/lint.ts +2 -2
  107. package/src/redocly/registry-api.ts +5 -4
  108. package/src/resolve.ts +3 -1
  109. package/src/rules/__tests__/utils.test.ts +1 -1
  110. package/src/rules/ajv.ts +4 -4
  111. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +1 -0
  112. package/src/rules/common/__tests__/operation-2xx-response.test.ts +1 -1
  113. package/src/rules/common/__tests__/operation-4xx-response.test.ts +26 -3
  114. package/src/rules/common/__tests__/security-defined.test.ts +175 -0
  115. package/src/rules/common/__tests__/spec.test.ts +79 -0
  116. package/src/rules/common/assertions/__tests__/asserts.test.ts +491 -428
  117. package/src/rules/common/assertions/__tests__/utils.test.ts +2 -2
  118. package/src/rules/common/assertions/asserts.ts +155 -97
  119. package/src/rules/common/assertions/index.ts +2 -11
  120. package/src/rules/common/assertions/utils.ts +66 -36
  121. package/src/rules/common/no-ambiguous-paths.ts +1 -1
  122. package/src/rules/common/no-identical-paths.ts +1 -1
  123. package/src/rules/common/operation-2xx-response.ts +1 -1
  124. package/src/rules/common/operation-4xx-response.ts +1 -1
  125. package/src/rules/common/operation-operationId.ts +1 -1
  126. package/src/rules/common/operation-tag-defined.ts +1 -1
  127. package/src/rules/common/path-not-include-query.ts +1 -1
  128. package/src/rules/common/{operation-security-defined.ts → security-defined.ts} +19 -4
  129. package/src/rules/common/spec.ts +15 -1
  130. package/src/rules/common/tags-alphabetical.ts +1 -1
  131. package/src/rules/oas2/index.ts +2 -2
  132. package/src/rules/oas2/remove-unused-components.ts +1 -1
  133. package/src/rules/oas2/request-mime-type.ts +1 -1
  134. package/src/rules/oas2/response-mime-type.ts +1 -1
  135. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +51 -2
  136. package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +145 -0
  137. package/src/rules/oas3/__tests__/spec/spec.test.ts +10 -0
  138. package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +217 -0
  139. package/src/rules/oas3/index.ts +6 -2
  140. package/src/rules/oas3/no-empty-servers.ts +1 -1
  141. package/src/rules/oas3/no-server-variables-empty-enum.ts +1 -1
  142. package/src/rules/oas3/no-unused-components.ts +1 -1
  143. package/src/rules/oas3/operation-4xx-problem-details-rfc7807.ts +36 -0
  144. package/src/rules/oas3/remove-unused-components.ts +1 -1
  145. package/src/rules/oas3/request-mime-type.ts +1 -1
  146. package/src/rules/oas3/response-mime-type.ts +1 -1
  147. package/src/rules/oas3/spec-components-invalid-map-name.ts +53 -0
  148. package/src/rules/other/stats.ts +2 -2
  149. package/src/rules/utils.ts +2 -1
  150. package/src/types/index.ts +2 -2
  151. package/src/types/oas2.ts +5 -5
  152. package/src/types/oas3.ts +27 -20
  153. package/src/types/oas3_1.ts +3 -3
  154. package/src/types/redocly-yaml.ts +66 -38
  155. package/src/utils.ts +11 -7
  156. package/src/visitors.ts +29 -13
  157. package/tsconfig.tsbuildinfo +1 -1
  158. package/lib/rules/common/operation-security-defined.d.ts +0 -2
  159. package/src/rules/common/__tests__/operation-security-defined.test.ts +0 -69
@@ -12,16 +12,16 @@ describe('lint', () => {
12
12
  const results = await lintFromString({
13
13
  absoluteRef: '/test/spec.yaml',
14
14
  source: outdent`
15
- openapi: 3.0.0
16
- info:
17
- title: Test API
18
- version: "1.0"
19
- description: Test
20
- license: Fail
15
+ openapi: 3.0.0
16
+ info:
17
+ title: Test API
18
+ version: "1.0"
19
+ description: Test
20
+ license: Fail
21
21
 
22
- servers:
23
- - url: http://example.com
24
- paths: {}
22
+ servers:
23
+ - url: http://example.com
24
+ paths: {}
25
25
  `,
26
26
  config: await loadConfig(),
27
27
  });
@@ -29,6 +29,7 @@ describe('lint', () => {
29
29
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
30
30
  Array [
31
31
  Object {
32
+ "from": undefined,
32
33
  "location": Array [
33
34
  Object {
34
35
  "pointer": "#/info/license",
@@ -48,8 +49,7 @@ describe('lint', () => {
48
49
  it('lintConfig should work', async () => {
49
50
  const document = parseYamlToDocument(
50
51
  outdent`
51
- apis: error string
52
- styleguide:
52
+ apis: error string
53
53
  plugins:
54
54
  - './local-plugin.js'
55
55
  extends:
@@ -60,6 +60,12 @@ describe('lint', () => {
60
60
  no-invalid-media-type-examples: error
61
61
  path-http-verbs-order: error
62
62
  boolean-parameter-prefixes: off
63
+ assert/operation-summary-length:
64
+ subject: Operation
65
+ property: summary
66
+ message: Operation summary should start with an active verb
67
+ local/checkWordsCount:
68
+ min: 3
63
69
  features.openapi:
64
70
  showConsole: true
65
71
  layout:
@@ -70,6 +76,16 @@ describe('lint', () => {
70
76
  backgroundColor: '#263238'
71
77
  links:
72
78
  color: '#6CC496'
79
+ features.openapi:
80
+ showConsole: true
81
+ layout:
82
+ scope: section
83
+ routingStrategy: browser
84
+ theme:
85
+ rightPanel:
86
+ backgroundColor: '#263238'
87
+ links:
88
+ color: '#6CC496'
73
89
  `,
74
90
  ''
75
91
  );
@@ -78,6 +94,79 @@ describe('lint', () => {
78
94
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
79
95
  Array [
80
96
  Object {
97
+ "from": undefined,
98
+ "location": Array [
99
+ Object {
100
+ "pointer": "#/atures.openapi",
101
+ "reportOnKey": true,
102
+ "source": "",
103
+ },
104
+ ],
105
+ "message": "Property \`atures.openapi\` is not expected here.",
106
+ "ruleId": "configuration spec",
107
+ "severity": "error",
108
+ "suggest": Array [
109
+ "features.openapi",
110
+ ],
111
+ },
112
+ Object {
113
+ "from": undefined,
114
+ "location": Array [
115
+ Object {
116
+ "pointer": "#/showConsole",
117
+ "reportOnKey": true,
118
+ "source": "",
119
+ },
120
+ ],
121
+ "message": "Property \`showConsole\` is not expected here.",
122
+ "ruleId": "configuration spec",
123
+ "severity": "error",
124
+ "suggest": Array [],
125
+ },
126
+ Object {
127
+ "from": undefined,
128
+ "location": Array [
129
+ Object {
130
+ "pointer": "#/layout",
131
+ "reportOnKey": true,
132
+ "source": "",
133
+ },
134
+ ],
135
+ "message": "Property \`layout\` is not expected here.",
136
+ "ruleId": "configuration spec",
137
+ "severity": "error",
138
+ "suggest": Array [],
139
+ },
140
+ Object {
141
+ "from": undefined,
142
+ "location": Array [
143
+ Object {
144
+ "pointer": "#/routingStrategy",
145
+ "reportOnKey": true,
146
+ "source": "",
147
+ },
148
+ ],
149
+ "message": "Property \`routingStrategy\` is not expected here.",
150
+ "ruleId": "configuration spec",
151
+ "severity": "error",
152
+ "suggest": Array [],
153
+ },
154
+ Object {
155
+ "from": undefined,
156
+ "location": Array [
157
+ Object {
158
+ "pointer": "#/theme",
159
+ "reportOnKey": true,
160
+ "source": "",
161
+ },
162
+ ],
163
+ "message": "Property \`theme\` is not expected here.",
164
+ "ruleId": "configuration spec",
165
+ "severity": "error",
166
+ "suggest": Array [],
167
+ },
168
+ Object {
169
+ "from": undefined,
81
170
  "location": Array [
82
171
  Object {
83
172
  "pointer": "#/apis",
@@ -91,6 +180,7 @@ describe('lint', () => {
91
180
  "suggest": Array [],
92
181
  },
93
182
  Object {
183
+ "from": undefined,
94
184
  "location": Array [
95
185
  Object {
96
186
  "pointer": "#/features.openapi/layout",
@@ -110,10 +200,9 @@ describe('lint', () => {
110
200
  it('lintConfig should detect wrong fields and suggest correct ones', async () => {
111
201
  const document = parseYamlToDocument(
112
202
  outdent`
113
- api:
114
- name@version:
115
- root: ./file.yaml
116
- syleguide:
203
+ api:
204
+ name@version:
205
+ root: ./file.yaml
117
206
  rules:
118
207
  operation-2xx-response: warn
119
208
  `,
@@ -124,6 +213,7 @@ describe('lint', () => {
124
213
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
125
214
  Array [
126
215
  Object {
216
+ "from": undefined,
127
217
  "location": Array [
128
218
  Object {
129
219
  "pointer": "#/api",
@@ -138,21 +228,6 @@ describe('lint', () => {
138
228
  "apis",
139
229
  ],
140
230
  },
141
- Object {
142
- "location": Array [
143
- Object {
144
- "pointer": "#/syleguide",
145
- "reportOnKey": true,
146
- "source": "",
147
- },
148
- ],
149
- "message": "Property \`syleguide\` is not expected here.",
150
- "ruleId": "configuration spec",
151
- "severity": "error",
152
- "suggest": Array [
153
- "styleguide",
154
- ],
155
- },
156
231
  ]
157
232
  `);
158
233
  });
@@ -160,13 +235,13 @@ describe('lint', () => {
160
235
  it('lintConfig should work with legacy fields', async () => {
161
236
  const document = parseYamlToDocument(
162
237
  outdent`
163
- apiDefinitions:
164
- entry: ./file.yaml
165
- lint:
238
+ apis:
239
+ entry:
240
+ root: ./file.yaml
166
241
  rules:
167
242
  operation-2xx-response: warn
168
- referenceDocs:
169
- showConsole: true
243
+ referenceDocs:
244
+ showConsole: true
170
245
  `,
171
246
  ''
172
247
  );
@@ -175,16 +250,16 @@ describe('lint', () => {
175
250
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
176
251
  });
177
252
 
178
- it("'plugins' shouldn't be allowed in 'apis' -> 'styleguide' field", async () => {
253
+ it("'plugins' shouldn't be allowed in 'apis'", async () => {
179
254
  const document = parseYamlToDocument(
180
255
  outdent`
181
- apis:
182
- styleguide:
183
- plugins:
256
+ apis:
257
+ main:
258
+ root: ./main.yaml
259
+ plugins:
184
260
  - './local-plugin.js'
185
- styleguide:
186
261
  plugins:
187
- - './local-plugin.js'
262
+ - './local-plugin.js'
188
263
  `,
189
264
  ''
190
265
  );
@@ -193,22 +268,10 @@ describe('lint', () => {
193
268
  expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
194
269
  Array [
195
270
  Object {
271
+ "from": undefined,
196
272
  "location": Array [
197
273
  Object {
198
- "pointer": "#/apis/styleguide",
199
- "reportOnKey": true,
200
- "source": "",
201
- },
202
- ],
203
- "message": "The field \`root\` must be present on this level.",
204
- "ruleId": "configuration spec",
205
- "severity": "error",
206
- "suggest": Array [],
207
- },
208
- Object {
209
- "location": Array [
210
- Object {
211
- "pointer": "#/apis/styleguide/plugins",
274
+ "pointer": "#/apis/main/plugins",
212
275
  "reportOnKey": true,
213
276
  "source": "",
214
277
  },
@@ -225,31 +288,31 @@ describe('lint', () => {
225
288
  it("'const' can have any type", async () => {
226
289
  const document = parseYamlToDocument(
227
290
  outdent`
228
- openapi: "3.1.0"
229
- info:
230
- version: 1.0.0
231
- title: Swagger Petstore
232
- description: Information about Petstore
233
- license:
234
- name: MIT
235
- url: https://opensource.org/licenses/MIT
236
- servers:
237
- - url: http://petstore.swagger.io/v1
238
- paths:
239
- /pets:
240
- get:
241
- summary: List all pets
242
- operationId: listPets
243
- tags:
244
- - pets
245
- responses:
246
- 200:
247
- description: An paged array of pets
248
- content:
249
- application/json:
250
- schema:
251
- type: string
252
- const: ABC
291
+ openapi: "3.1.0"
292
+ info:
293
+ version: 1.0.0
294
+ title: Swagger Petstore
295
+ description: Information about Petstore
296
+ license:
297
+ name: MIT
298
+ url: https://opensource.org/licenses/MIT
299
+ servers:
300
+ - url: http://petstore.swagger.io/v1
301
+ paths:
302
+ /pets:
303
+ get:
304
+ summary: List all pets
305
+ operationId: listPets
306
+ tags:
307
+ - pets
308
+ responses:
309
+ 200:
310
+ description: An paged array of pets
311
+ content:
312
+ application/json:
313
+ schema:
314
+ type: string
315
+ const: ABC
253
316
  `,
254
317
  'foobar.yaml'
255
318
  );
@@ -266,8 +329,8 @@ describe('lint', () => {
266
329
  it('detect OpenAPI should throw an error when version is not string', () => {
267
330
  const testDocument = parseYamlToDocument(
268
331
  outdent`
269
- openapi: 3.0
270
- `,
332
+ openapi: 3.0
333
+ `,
271
334
  ''
272
335
  );
273
336
  expect(() => detectOpenAPI(testDocument.parsed)).toThrow(
@@ -278,28 +341,28 @@ describe('lint', () => {
278
341
  it("spec rule shouldn't throw an error for named callback", async () => {
279
342
  const document = parseYamlToDocument(
280
343
  outdent`
281
- openapi: 3.1.0
282
- info:
283
- title: Callback test
284
- version: 'alpha'
285
- components:
286
- callbacks:
287
- resultCallback:
288
- '{$url}':
289
- post:
290
- requestBody:
291
- description: Callback payload
292
- content:
293
- 'application/json':
294
- schema:
295
- type: object
296
- properties:
297
- test:
298
- type: string
299
- responses:
300
- '200':
301
- description: callback successfully processed
302
- `,
344
+ openapi: 3.1.0
345
+ info:
346
+ title: Callback test
347
+ version: 'alpha'
348
+ components:
349
+ callbacks:
350
+ resultCallback:
351
+ '{$url}':
352
+ post:
353
+ requestBody:
354
+ description: Callback payload
355
+ content:
356
+ 'application/json':
357
+ schema:
358
+ type: object
359
+ properties:
360
+ test:
361
+ type: string
362
+ responses:
363
+ '200':
364
+ description: callback successfully processed
365
+ `,
303
366
  'foobar.yaml'
304
367
  );
305
368
 
@@ -316,23 +379,23 @@ describe('lint', () => {
316
379
  const absoluteRef = path.join(__dirname, 'fixtures/openapi.yaml');
317
380
  const document = parseYamlToDocument(
318
381
  outdent`
319
- openapi: 3.0.0
320
- info:
321
- version: 1.0.0
322
- title: Example OpenAPI 3 definition.
323
- description: Information about API
324
- license:
325
- name: MIT
326
- url: 'https://opensource.org/licenses/MIT'
327
- servers:
328
- - url: 'https://redocly.com/v1'
329
- paths:
330
- '/pets/{petId}':
331
- post:
332
- responses:
333
- '201':
334
- summary: Exist
335
- description: example description
382
+ openapi: 3.0.0
383
+ info:
384
+ version: 1.0.0
385
+ title: Example OpenAPI 3 definition.
386
+ description: Information about API
387
+ license:
388
+ name: MIT
389
+ url: 'https://opensource.org/licenses/MIT'
390
+ servers:
391
+ - url: 'https://redocly.com/v1'
392
+ paths:
393
+ '/pets/{petId}':
394
+ post:
395
+ responses:
396
+ '201':
397
+ summary: Exist
398
+ description: example description
336
399
  `,
337
400
  absoluteRef
338
401
  );
@@ -43,7 +43,7 @@ describe('Resolve http-headers', () => {
43
43
  ],
44
44
  },
45
45
  }),
46
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
46
+ rootType: normalizeTypes(Oas3Types).Root,
47
47
  });
48
48
 
49
49
  expect(fetchMock).toBeCalledTimes(3);
@@ -24,7 +24,7 @@ describe('collect refs', () => {
24
24
  const resolvedRefs = await resolveDocument({
25
25
  rootDocument,
26
26
  externalRefResolver: new BaseResolver(),
27
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
27
+ rootType: normalizeTypes(Oas3Types).Root,
28
28
  });
29
29
 
30
30
  expect(resolvedRefs).toBeDefined();
@@ -63,7 +63,7 @@ describe('collect refs', () => {
63
63
  await resolveDocument({
64
64
  rootDocument,
65
65
  externalRefResolver: new BaseResolver(),
66
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
66
+ rootType: normalizeTypes(Oas3Types).Root,
67
67
  });
68
68
  } catch (e) {
69
69
  expect(e.message).toEqual('Self-referencing circular pointer');
@@ -95,7 +95,7 @@ describe('collect refs', () => {
95
95
  const resolvedRefs = await resolveDocument({
96
96
  rootDocument,
97
97
  externalRefResolver: new BaseResolver(),
98
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
98
+ rootType: normalizeTypes(Oas3Types).Root,
99
99
  });
100
100
 
101
101
  expect(resolvedRefs).toBeDefined();
@@ -132,7 +132,7 @@ describe('collect refs', () => {
132
132
  await resolveDocument({
133
133
  rootDocument,
134
134
  externalRefResolver: new BaseResolver(),
135
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
135
+ rootType: normalizeTypes(Oas3Types).Root,
136
136
  });
137
137
  } catch (e) {
138
138
  expect(e.message).toEqual('Self-referencing circular pointer');
@@ -153,7 +153,7 @@ describe('collect refs', () => {
153
153
  const resolvedRefs = await resolveDocument({
154
154
  rootDocument,
155
155
  externalRefResolver: new BaseResolver(),
156
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
156
+ rootType: normalizeTypes(Oas3Types).Root,
157
157
  });
158
158
 
159
159
  expect(resolvedRefs).toBeDefined();
@@ -187,7 +187,7 @@ describe('collect refs', () => {
187
187
  const resolvedRefs = await resolveDocument({
188
188
  rootDocument: rootDocument as Document,
189
189
  externalRefResolver: externalRefResolver,
190
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
190
+ rootType: normalizeTypes(Oas3Types).Root,
191
191
  });
192
192
 
193
193
  expect(resolvedRefs).toBeDefined();
@@ -263,7 +263,7 @@ describe('collect refs', () => {
263
263
  const resolvedRefs = await resolveDocument({
264
264
  rootDocument: rootDocument as Document,
265
265
  externalRefResolver: externalRefResolver,
266
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
266
+ rootType: normalizeTypes(Oas3Types).Root,
267
267
  });
268
268
 
269
269
  expect(resolvedRefs).toBeDefined();
@@ -358,7 +358,7 @@ describe('collect refs', () => {
358
358
  const resolvedRefs = await resolveDocument({
359
359
  rootDocument: rootDocument as Document,
360
360
  externalRefResolver: externalRefResolver,
361
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
361
+ rootType: normalizeTypes(Oas3Types).Root,
362
362
  });
363
363
 
364
364
  expect(resolvedRefs).toBeDefined();
@@ -392,7 +392,7 @@ describe('collect refs', () => {
392
392
  const resolvedRefs = await resolveDocument({
393
393
  rootDocument,
394
394
  externalRefResolver: new BaseResolver(),
395
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
395
+ rootType: normalizeTypes(Oas3Types).Root,
396
396
  });
397
397
 
398
398
  expect(resolvedRefs).toBeDefined();
@@ -16,7 +16,7 @@ import { Oas3RuleSet } from '../oas-types';
16
16
  describe('walk order', () => {
17
17
  it('should run visitors', async () => {
18
18
  const visitors = {
19
- DefinitionRoot: {
19
+ Root: {
20
20
  enter: jest.fn(),
21
21
  leave: jest.fn(),
22
22
  },
@@ -63,6 +63,74 @@ describe('walk order', () => {
63
63
  }
64
64
  });
65
65
 
66
+ it('should run legacy visitors', async () => {
67
+ const visitors = {
68
+ DefinitionRoot: {
69
+ enter: jest.fn(),
70
+ leave: jest.fn(),
71
+ },
72
+ PathMap: {
73
+ enter: jest.fn(),
74
+ leave: jest.fn(),
75
+ },
76
+ ServerVariableMap: {
77
+ enter: jest.fn(),
78
+ leave: jest.fn(),
79
+ },
80
+ MediaTypeMap: {
81
+ enter: jest.fn(),
82
+ leave: jest.fn(),
83
+ },
84
+ ExampleMap: {
85
+ enter: jest.fn(),
86
+ leave: jest.fn(),
87
+ },
88
+ HeaderMap: {
89
+ enter: jest.fn(),
90
+ leave: jest.fn(),
91
+ },
92
+ };
93
+
94
+ const testRuleSet: Oas3RuleSet = {
95
+ test: jest.fn(() => {
96
+ return visitors;
97
+ }),
98
+ };
99
+
100
+ const document = parseYamlToDocument(
101
+ outdent`
102
+ openapi: 3.0.0
103
+ servers:
104
+ - url: http://{test}.url
105
+ variables:
106
+ test: test
107
+ paths:
108
+ /test-path:
109
+ get:
110
+ responses:
111
+ 200:
112
+ headers: {}
113
+ content:
114
+ application/json:
115
+ schema: {}
116
+ examples: {}
117
+ `,
118
+ ''
119
+ );
120
+
121
+ await lintDocument({
122
+ externalRefResolver: new BaseResolver(),
123
+ document,
124
+ config: makeConfigForRuleset(testRuleSet),
125
+ });
126
+
127
+ expect(testRuleSet.test).toBeCalledTimes(1);
128
+ for (const fns of Object.values(visitors)) {
129
+ expect(fns.enter).toBeCalled();
130
+ expect(fns.leave).toBeCalled();
131
+ }
132
+ });
133
+
66
134
  it('should run nested visitors correctly', async () => {
67
135
  const calls: string[] = [];
68
136
 
@@ -1046,8 +1114,8 @@ describe('walk order', () => {
1046
1114
 
1047
1115
  expect(calls).toMatchInlineSnapshot(`
1048
1116
  Array [
1049
- "enter DefinitionRoot",
1050
- "enter PathMap",
1117
+ "enter Root",
1118
+ "enter PathsMap",
1051
1119
  "enter PathItem",
1052
1120
  "enter ParameterList",
1053
1121
  "enter Parameter",
@@ -1066,7 +1134,7 @@ describe('walk order', () => {
1066
1134
  "leave ParameterList",
1067
1135
  "leave Operation",
1068
1136
  "leave PathItem",
1069
- "leave PathMap",
1137
+ "leave PathsMap",
1070
1138
  "enter Components",
1071
1139
  "enter NamedParameters",
1072
1140
  "leave NamedParameters",
@@ -1075,7 +1143,7 @@ describe('walk order', () => {
1075
1143
  "leave Schema",
1076
1144
  "leave NamedSchemas",
1077
1145
  "leave Components",
1078
- "leave DefinitionRoot",
1146
+ "leave Root",
1079
1147
  ]
1080
1148
  `);
1081
1149
  });
@@ -1378,10 +1446,10 @@ describe('type extensions', () => {
1378
1446
  parameters: listOf('Parameter'),
1379
1447
  },
1380
1448
  },
1381
- DefinitionRoot: {
1382
- ...types.DefinitionRoot,
1449
+ Root: {
1450
+ ...types.Root,
1383
1451
  properties: {
1384
- ...types.DefinitionRoot.properties,
1452
+ ...types.Root.properties,
1385
1453
  'x-webhooks': 'XWebHooks',
1386
1454
  },
1387
1455
  },
@@ -1393,7 +1461,7 @@ describe('type extensions', () => {
1393
1461
 
1394
1462
  expect(calls).toMatchInlineSnapshot(`
1395
1463
  Array [
1396
- "enter DefinitionRoot",
1464
+ "enter Root",
1397
1465
  "enter XWebHooks",
1398
1466
  "enter hook test",
1399
1467
  "enter ParameterList",
@@ -1402,7 +1470,7 @@ describe('type extensions', () => {
1402
1470
  "leave ParameterList",
1403
1471
  "leave hook test",
1404
1472
  "leave XWebHooks",
1405
- "leave DefinitionRoot",
1473
+ "leave Root",
1406
1474
  ]
1407
1475
  `);
1408
1476
  });
@@ -18,6 +18,6 @@ export function measureAsync() {
18
18
  return resolveDocument({
19
19
  rootDocument: rebillyDocument,
20
20
  externalRefResolver,
21
- rootType: normalizeTypes(Oas3Types).DefinitionRoot,
21
+ rootType: normalizeTypes(Oas3Types).Root,
22
22
  });
23
23
  }