@redocly/openapi-core 1.0.0-beta.109 → 1.0.0-beta.111
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/README.md +2 -2
- package/lib/config/config-resolvers.js +44 -25
- package/lib/config/config.d.ts +1 -0
- package/lib/config/config.js +1 -0
- package/lib/config/load.d.ts +8 -2
- package/lib/config/load.js +4 -2
- package/lib/config/types.d.ts +10 -0
- package/lib/config/utils.js +2 -2
- package/lib/rules/ajv.d.ts +1 -1
- package/lib/rules/ajv.js +5 -5
- package/lib/rules/common/assertions/asserts.d.ts +3 -5
- package/lib/rules/common/assertions/asserts.js +137 -97
- package/lib/rules/common/assertions/index.js +2 -6
- package/lib/rules/common/assertions/utils.d.ts +12 -6
- package/lib/rules/common/assertions/utils.js +33 -20
- package/lib/rules/common/no-ambiguous-paths.js +1 -1
- package/lib/rules/common/no-identical-paths.js +4 -4
- package/lib/rules/common/operation-2xx-response.js +2 -2
- package/lib/rules/common/operation-4xx-response.js +2 -2
- package/lib/rules/common/path-not-include-query.js +1 -1
- package/lib/rules/common/path-params-defined.js +7 -2
- package/lib/rules/common/response-contains-header.js +2 -2
- package/lib/rules/common/security-defined.js +10 -5
- package/lib/rules/common/spec.js +14 -12
- package/lib/rules/oas3/request-mime-type.js +1 -1
- package/lib/rules/oas3/response-mime-type.js +1 -1
- package/lib/rules/other/stats.d.ts +1 -1
- package/lib/rules/other/stats.js +1 -1
- package/lib/rules/utils.d.ts +1 -0
- package/lib/rules/utils.js +18 -2
- package/lib/types/oas2.js +6 -6
- package/lib/types/oas3.js +11 -11
- package/lib/types/oas3_1.js +3 -3
- package/lib/types/redocly-yaml.js +30 -5
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +13 -1
- package/lib/visitors.d.ts +7 -6
- package/lib/visitors.js +11 -3
- package/package.json +3 -5
- package/src/__tests__/__snapshots__/bundle.test.ts.snap +1 -1
- package/src/__tests__/lint.test.ts +88 -0
- package/src/__tests__/utils.test.ts +11 -0
- package/src/__tests__/walk.test.ts +2 -2
- package/src/config/__tests__/config-resolvers.test.ts +62 -1
- package/src/config/__tests__/config.test.ts +5 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-custom-function.yaml +16 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-wrong-custom-function.yaml +16 -0
- package/src/config/__tests__/fixtures/resolve-config/plugin.js +11 -0
- package/src/config/__tests__/load.test.ts +1 -1
- package/src/config/__tests__/resolve-plugins.test.ts +3 -3
- package/src/config/config-resolvers.ts +30 -6
- package/src/config/config.ts +2 -0
- package/src/config/load.ts +10 -4
- package/src/config/types.ts +13 -0
- package/src/config/utils.ts +1 -0
- package/src/rules/ajv.ts +4 -4
- package/src/rules/common/__tests__/operation-2xx-response.test.ts +37 -0
- package/src/rules/common/__tests__/operation-4xx-response.test.ts +37 -0
- package/src/rules/common/__tests__/path-params-defined.test.ts +69 -0
- package/src/rules/common/__tests__/security-defined.test.ts +6 -6
- package/src/rules/common/__tests__/spec.test.ts +125 -0
- package/src/rules/common/assertions/__tests__/asserts.test.ts +491 -428
- package/src/rules/common/assertions/__tests__/utils.test.ts +2 -2
- package/src/rules/common/assertions/asserts.ts +155 -97
- package/src/rules/common/assertions/index.ts +2 -11
- package/src/rules/common/assertions/utils.ts +66 -36
- package/src/rules/common/no-ambiguous-paths.ts +1 -1
- package/src/rules/common/no-identical-paths.ts +4 -4
- package/src/rules/common/operation-2xx-response.ts +2 -2
- package/src/rules/common/operation-4xx-response.ts +2 -2
- package/src/rules/common/path-not-include-query.ts +1 -1
- package/src/rules/common/path-params-defined.ts +9 -2
- package/src/rules/common/response-contains-header.ts +6 -1
- package/src/rules/common/security-defined.ts +10 -5
- package/src/rules/common/spec.ts +15 -11
- package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +51 -2
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +116 -0
- package/src/rules/oas3/request-mime-type.ts +1 -1
- package/src/rules/oas3/response-mime-type.ts +1 -1
- package/src/rules/other/stats.ts +1 -1
- package/src/rules/utils.ts +24 -1
- package/src/types/oas2.ts +6 -6
- package/src/types/oas3.ts +11 -11
- package/src/types/oas3_1.ts +3 -3
- package/src/types/redocly-yaml.ts +30 -4
- package/src/utils.ts +13 -0
- package/src/visitors.ts +25 -10
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -139,3 +139,128 @@ describe('Oas3 spec', () => {
|
|
|
139
139
|
`);
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
|
+
|
|
143
|
+
describe('Oas3.1 spec', () => {
|
|
144
|
+
it('should report with "type can be one of the following only"', async () => {
|
|
145
|
+
const document = parseYamlToDocument(
|
|
146
|
+
outdent`
|
|
147
|
+
openapi: 3.1.0
|
|
148
|
+
info:
|
|
149
|
+
version: 1.0.0
|
|
150
|
+
title: Example.com
|
|
151
|
+
description: info,
|
|
152
|
+
license:
|
|
153
|
+
name: Apache 2.0
|
|
154
|
+
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
|
|
155
|
+
components:
|
|
156
|
+
schemas:
|
|
157
|
+
TestSchema:
|
|
158
|
+
title: TestSchema
|
|
159
|
+
description: Property name's description
|
|
160
|
+
type: test
|
|
161
|
+
`
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const results = await lintDocument({
|
|
165
|
+
externalRefResolver: new BaseResolver(),
|
|
166
|
+
document,
|
|
167
|
+
config: await makeConfig({ spec: 'error' }),
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
171
|
+
Array [
|
|
172
|
+
Object {
|
|
173
|
+
"from": undefined,
|
|
174
|
+
"location": Array [
|
|
175
|
+
Object {
|
|
176
|
+
"pointer": "#/components/schemas/TestSchema/type",
|
|
177
|
+
"reportOnKey": false,
|
|
178
|
+
"source": "",
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
"message": "\`type\` can be one of the following only: \\"object\\", \\"array\\", \\"string\\", \\"number\\", \\"integer\\", \\"boolean\\", \\"null\\".",
|
|
182
|
+
"ruleId": "spec",
|
|
183
|
+
"severity": "error",
|
|
184
|
+
"suggest": Array [],
|
|
185
|
+
},
|
|
186
|
+
]
|
|
187
|
+
`);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('should report with unknown type in type`s list', async () => {
|
|
191
|
+
const document = parseYamlToDocument(
|
|
192
|
+
outdent`
|
|
193
|
+
openapi: 3.1.0
|
|
194
|
+
info:
|
|
195
|
+
version: 1.0.0
|
|
196
|
+
title: Example.com
|
|
197
|
+
description: info,
|
|
198
|
+
license:
|
|
199
|
+
name: Apache 2.0
|
|
200
|
+
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
|
|
201
|
+
components:
|
|
202
|
+
schemas:
|
|
203
|
+
TestSchema:
|
|
204
|
+
title: TestSchema
|
|
205
|
+
description: Property name's description
|
|
206
|
+
type:
|
|
207
|
+
- string
|
|
208
|
+
- foo
|
|
209
|
+
`
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
const results = await lintDocument({
|
|
213
|
+
externalRefResolver: new BaseResolver(),
|
|
214
|
+
document,
|
|
215
|
+
config: await makeConfig({ spec: 'error' }),
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
|
|
219
|
+
Array [
|
|
220
|
+
Object {
|
|
221
|
+
"from": undefined,
|
|
222
|
+
"location": Array [
|
|
223
|
+
Object {
|
|
224
|
+
"pointer": "#/components/schemas/TestSchema/type/1",
|
|
225
|
+
"reportOnKey": false,
|
|
226
|
+
"source": "",
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
"message": "\`type\` can be one of the following only: \\"object\\", \\"array\\", \\"string\\", \\"number\\", \\"integer\\", \\"boolean\\", \\"null\\".",
|
|
230
|
+
"ruleId": "spec",
|
|
231
|
+
"severity": "error",
|
|
232
|
+
"suggest": Array [],
|
|
233
|
+
},
|
|
234
|
+
]
|
|
235
|
+
`);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should not report about unknown type', async () => {
|
|
239
|
+
const document = parseYamlToDocument(
|
|
240
|
+
outdent`
|
|
241
|
+
openapi: 3.1.0
|
|
242
|
+
info:
|
|
243
|
+
version: 1.0.0
|
|
244
|
+
title: Example.com
|
|
245
|
+
description: info,
|
|
246
|
+
license:
|
|
247
|
+
name: Apache 2.0
|
|
248
|
+
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
|
|
249
|
+
components:
|
|
250
|
+
schemas:
|
|
251
|
+
TestSchema:
|
|
252
|
+
title: TestSchema
|
|
253
|
+
description: Property name's description
|
|
254
|
+
type: null
|
|
255
|
+
`
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
const results = await lintDocument({
|
|
259
|
+
externalRefResolver: new BaseResolver(),
|
|
260
|
+
document,
|
|
261
|
+
config: await makeConfig({ spec: 'error' }),
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
265
|
+
});
|
|
266
|
+
});
|