@redocly/openapi-core 1.0.0-beta.96 → 1.0.0-beta.99
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/lib/bundle.d.ts +2 -0
- package/lib/bundle.js +6 -3
- package/lib/config/all.js +1 -0
- package/lib/config/config-resolvers.d.ts +1 -1
- package/lib/config/config-resolvers.js +31 -2
- package/lib/config/config.d.ts +4 -1
- package/lib/config/config.js +18 -12
- package/lib/format/format.js +2 -1
- package/lib/redocly/index.js +10 -26
- package/lib/redocly/registry-api-types.d.ts +1 -0
- package/lib/redocly/registry-api.d.ts +1 -1
- package/lib/redocly/registry-api.js +2 -1
- package/lib/ref-utils.js +1 -0
- package/lib/rules/common/response-contains-header.d.ts +2 -0
- package/lib/rules/common/response-contains-header.js +29 -0
- package/lib/rules/common/scalar-property-missing-example.d.ts +2 -0
- package/lib/rules/common/scalar-property-missing-example.js +41 -0
- package/lib/rules/oas2/index.d.ts +3 -0
- package/lib/rules/oas2/index.js +6 -0
- package/lib/rules/oas2/response-contains-property.d.ts +2 -0
- package/lib/rules/oas2/response-contains-property.js +38 -0
- package/lib/rules/oas3/index.js +6 -0
- package/lib/rules/oas3/response-contains-property.d.ts +2 -0
- package/lib/rules/oas3/response-contains-property.js +40 -0
- package/lib/types/oas2.js +3 -1
- package/lib/types/oas3.js +21 -8
- package/lib/types/oas3_1.js +12 -8
- package/lib/types/redocly-yaml.js +12 -0
- package/lib/typings/openapi.d.ts +5 -2
- package/lib/typings/swagger.d.ts +2 -0
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +5 -3
- package/package.json +3 -3
- package/{__tests__ → src/__tests__}/__snapshots__/bundle.test.ts.snap +26 -0
- package/{__tests__ → src/__tests__}/bundle.test.ts +30 -6
- package/{__tests__ → src/__tests__}/codeframes.test.ts +3 -3
- package/{__tests__ → src/__tests__}/fixtures/extension.js +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/definitions.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/examples.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/external-request-body.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/externalref.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/hosted.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/openapi-with-external-refs-conflicting-names.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/openapi-with-external-refs.yaml +0 -0
- package/src/__tests__/fixtures/refs/openapi-with-url-refs.yaml +18 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/param-b.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/param-c.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/rename.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/requestBody.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/schema-a.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/simple.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/refs/vendor.schema.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/External.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/External2.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/description.md +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/externalInfo.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/externalLicense.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/openapi-with-back.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/openapi-with-md-description.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/openapi.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/schemas/type-a.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/schemas/type-b.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/transitive/a.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/transitive/components.yaml +0 -0
- package/{__tests__ → src/__tests__}/fixtures/resolve/transitive/schemas.yaml +0 -0
- package/src/__tests__/lint.test.ts +13 -0
- package/{__tests__ → src/__tests__}/login.test.ts +1 -1
- package/{__tests__ → src/__tests__}/normalizeVisitors.test.ts +4 -4
- package/{__tests__ → src/__tests__}/ref-utils.test.ts +5 -5
- package/{__tests__ → src/__tests__}/resolve-http.test.ts +4 -4
- package/{__tests__ → src/__tests__}/resolve.test.ts +4 -4
- package/src/__tests__/utils.test.ts +12 -1
- package/{__tests__ → src/__tests__}/walk.test.ts +5 -5
- package/src/bundle.ts +18 -3
- package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +18 -1
- package/src/config/__tests__/config-resolvers.test.ts +32 -1
- package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +5 -0
- package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +7 -0
- package/src/config/all.ts +1 -0
- package/src/config/config-resolvers.ts +58 -3
- package/src/config/config.ts +21 -12
- package/src/format/format.ts +2 -1
- package/src/redocly/index.ts +12 -41
- package/src/redocly/registry-api-types.ts +1 -0
- package/src/redocly/registry-api.ts +2 -0
- package/src/ref-utils.ts +1 -0
- package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +207 -0
- package/src/rules/common/response-contains-header.ts +30 -0
- package/src/rules/common/scalar-property-missing-example.ts +55 -0
- package/src/rules/oas2/__tests__/response-contains-header.test.ts +174 -0
- package/src/rules/oas2/__tests__/response-contains-property.test.ts +155 -0
- package/src/rules/oas2/index.ts +6 -0
- package/src/rules/oas2/response-contains-property.ts +36 -0
- package/src/rules/oas3/__tests__/response-contains-header.test.ts +273 -0
- package/src/rules/oas3/__tests__/response-contains-property.test.ts +403 -0
- package/src/rules/oas3/index.ts +6 -0
- package/src/rules/oas3/response-contains-property.ts +38 -0
- package/src/types/oas2.ts +2 -0
- package/src/types/oas3.ts +18 -7
- package/src/types/oas3_1.ts +11 -7
- package/src/types/redocly-yaml.ts +12 -0
- package/src/typings/openapi.ts +4 -1
- package/src/typings/swagger.ts +2 -0
- package/src/utils.ts +6 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/__tests__/lint.test.ts +0 -17
package/lib/types/oas3.js
CHANGED
|
@@ -149,7 +149,8 @@ const Operation = {
|
|
|
149
149
|
deprecated: { type: 'boolean' },
|
|
150
150
|
callbacks: _1.mapOf('Callback'),
|
|
151
151
|
'x-codeSamples': _1.listOf('XCodeSample'),
|
|
152
|
-
'x-code-samples': _1.listOf('XCodeSample'),
|
|
152
|
+
'x-code-samples': _1.listOf('XCodeSample'),
|
|
153
|
+
'x-hideTryItPanel': { type: 'boolean' },
|
|
153
154
|
},
|
|
154
155
|
required: ['responses'],
|
|
155
156
|
};
|
|
@@ -249,14 +250,14 @@ const Schema = {
|
|
|
249
250
|
minimum: { type: 'number' },
|
|
250
251
|
exclusiveMaximum: { type: 'boolean' },
|
|
251
252
|
exclusiveMinimum: { type: 'boolean' },
|
|
252
|
-
maxLength: { type: '
|
|
253
|
-
minLength: { type: '
|
|
253
|
+
maxLength: { type: 'integer', minimum: 0 },
|
|
254
|
+
minLength: { type: 'integer', minimum: 0 },
|
|
254
255
|
pattern: { type: 'string' },
|
|
255
|
-
maxItems: { type: '
|
|
256
|
-
minItems: { type: '
|
|
256
|
+
maxItems: { type: 'integer', minimum: 0 },
|
|
257
|
+
minItems: { type: 'integer', minimum: 0 },
|
|
257
258
|
uniqueItems: { type: 'boolean' },
|
|
258
|
-
maxProperties: { type: '
|
|
259
|
-
minProperties: { type: '
|
|
259
|
+
maxProperties: { type: 'integer', minimum: 0 },
|
|
260
|
+
minProperties: { type: 'integer', minimum: 0 },
|
|
260
261
|
required: { type: 'array', items: { type: 'string' } },
|
|
261
262
|
enum: { type: 'array' },
|
|
262
263
|
type: {
|
|
@@ -275,6 +276,17 @@ const Schema = {
|
|
|
275
276
|
return 'Schema';
|
|
276
277
|
}
|
|
277
278
|
},
|
|
279
|
+
additionalItems: (value) => {
|
|
280
|
+
if (typeof value === 'boolean') {
|
|
281
|
+
return { type: 'boolean' };
|
|
282
|
+
}
|
|
283
|
+
else if (Array.isArray(value)) {
|
|
284
|
+
return _1.listOf('Schema');
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
return 'Schema';
|
|
288
|
+
}
|
|
289
|
+
},
|
|
278
290
|
additionalProperties: (value) => {
|
|
279
291
|
if (typeof value === 'boolean') {
|
|
280
292
|
return { type: 'boolean' };
|
|
@@ -292,6 +304,7 @@ const Schema = {
|
|
|
292
304
|
xml: 'Xml',
|
|
293
305
|
example: { isExample: true },
|
|
294
306
|
deprecated: { type: 'boolean' },
|
|
307
|
+
'x-tags': { type: 'array', items: { type: 'string' } },
|
|
295
308
|
},
|
|
296
309
|
};
|
|
297
310
|
const Xml = {
|
|
@@ -344,7 +357,7 @@ const ImplicitFlow = {
|
|
|
344
357
|
scopes: { type: 'object', additionalProperties: { type: 'string' } },
|
|
345
358
|
authorizationUrl: { type: 'string' },
|
|
346
359
|
},
|
|
347
|
-
required: ['authorizationUrl', 'scopes']
|
|
360
|
+
required: ['authorizationUrl', 'scopes'],
|
|
348
361
|
};
|
|
349
362
|
const PasswordFlow = {
|
|
350
363
|
properties: {
|
package/lib/types/oas3_1.js
CHANGED
|
@@ -71,7 +71,8 @@ const Operation = {
|
|
|
71
71
|
deprecated: { type: 'boolean' },
|
|
72
72
|
callbacks: _1.mapOf('Callback'),
|
|
73
73
|
'x-codeSamples': _1.listOf('XCodeSample'),
|
|
74
|
-
'x-code-samples': _1.listOf('XCodeSample'),
|
|
74
|
+
'x-code-samples': _1.listOf('XCodeSample'),
|
|
75
|
+
'x-hideTryItPanel': { type: 'boolean' },
|
|
75
76
|
},
|
|
76
77
|
};
|
|
77
78
|
const Schema = {
|
|
@@ -86,19 +87,19 @@ const Schema = {
|
|
|
86
87
|
discriminator: 'Discriminator',
|
|
87
88
|
myArbitraryKeyword: { type: 'boolean' },
|
|
88
89
|
title: { type: 'string' },
|
|
89
|
-
multipleOf: { type: 'number' },
|
|
90
|
+
multipleOf: { type: 'number', minimum: 0 },
|
|
90
91
|
maximum: { type: 'number' },
|
|
91
92
|
minimum: { type: 'number' },
|
|
92
93
|
exclusiveMaximum: { type: 'number' },
|
|
93
94
|
exclusiveMinimum: { type: 'number' },
|
|
94
|
-
maxLength: { type: '
|
|
95
|
-
minLength: { type: '
|
|
95
|
+
maxLength: { type: 'integer', minimum: 0 },
|
|
96
|
+
minLength: { type: 'integer', minimum: 0 },
|
|
96
97
|
pattern: { type: 'string' },
|
|
97
|
-
maxItems: { type: '
|
|
98
|
-
minItems: { type: '
|
|
98
|
+
maxItems: { type: 'integer', minimum: 0 },
|
|
99
|
+
minItems: { type: 'integer', minimum: 0 },
|
|
99
100
|
uniqueItems: { type: 'boolean' },
|
|
100
|
-
maxProperties: { type: '
|
|
101
|
-
minProperties: { type: '
|
|
101
|
+
maxProperties: { type: 'integer', minimum: 0 },
|
|
102
|
+
minProperties: { type: 'integer', minimum: 0 },
|
|
102
103
|
required: { type: 'array', items: { type: 'string' } },
|
|
103
104
|
enum: { type: 'array' },
|
|
104
105
|
type: (value) => {
|
|
@@ -124,6 +125,8 @@ const Schema = {
|
|
|
124
125
|
dependentSchemas: _1.listOf('Schema'),
|
|
125
126
|
prefixItems: _1.listOf('Schema'),
|
|
126
127
|
contains: 'Schema',
|
|
128
|
+
minContains: { type: 'integer', minimum: 0 },
|
|
129
|
+
maxContains: { type: 'integer', minimum: 0 },
|
|
127
130
|
patternProperties: { type: 'object' },
|
|
128
131
|
propertyNames: 'Schema',
|
|
129
132
|
unevaluatedItems: 'Schema',
|
|
@@ -164,6 +167,7 @@ const Schema = {
|
|
|
164
167
|
deprecated: { type: 'boolean' },
|
|
165
168
|
const: null,
|
|
166
169
|
$comment: { type: 'string' },
|
|
170
|
+
'x-tags': { type: 'array', items: { type: 'string' } },
|
|
167
171
|
},
|
|
168
172
|
};
|
|
169
173
|
const SecurityScheme = {
|
|
@@ -311,6 +311,7 @@ const LinksConfig = {
|
|
|
311
311
|
color: { type: 'string' },
|
|
312
312
|
hover: { type: 'string' },
|
|
313
313
|
textDecoration: { type: 'string' },
|
|
314
|
+
hoverTextDecoration: { type: 'string' },
|
|
314
315
|
visited: { type: 'string' },
|
|
315
316
|
},
|
|
316
317
|
};
|
|
@@ -401,6 +402,9 @@ const ConfigReferenceDocs = {
|
|
|
401
402
|
disableSidebar: { type: 'boolean' },
|
|
402
403
|
downloadDefinitionUrl: { type: 'string' },
|
|
403
404
|
expandDefaultServerVariables: { type: 'boolean' },
|
|
405
|
+
enumSkipQuotes: { type: 'boolean' },
|
|
406
|
+
expandDefaultRequest: { type: 'boolean' },
|
|
407
|
+
expandDefaultResponse: { type: 'boolean' },
|
|
404
408
|
expandResponses: { type: 'string' },
|
|
405
409
|
expandSingleSchemaField: { type: 'boolean' },
|
|
406
410
|
generateCodeSamples: 'GenerateCodeSamples',
|
|
@@ -414,6 +418,9 @@ const ConfigReferenceDocs = {
|
|
|
414
418
|
hideSchemaPattern: { type: 'boolean' },
|
|
415
419
|
hideSchemaTitles: { type: 'boolean' },
|
|
416
420
|
hideSingleRequestSampleTab: { type: 'boolean' },
|
|
421
|
+
hideTryItPanel: { type: 'boolean' },
|
|
422
|
+
hideFab: { type: 'boolean' },
|
|
423
|
+
hideOneOfDescription: { type: 'boolean' },
|
|
417
424
|
htmlTemplate: { type: 'string' },
|
|
418
425
|
jsonSampleExpandLevel: { type: 'string' },
|
|
419
426
|
labels: 'ConfigLabels',
|
|
@@ -433,6 +440,9 @@ const ConfigReferenceDocs = {
|
|
|
433
440
|
routingBasePath: { type: 'string' },
|
|
434
441
|
samplesTabsMaxCount: { type: 'number' },
|
|
435
442
|
schemaExpansionLevel: { type: 'string' },
|
|
443
|
+
schemaDefinitionsTagName: { type: 'string' },
|
|
444
|
+
minCharacterLengthToInitSearch: { type: 'number' },
|
|
445
|
+
maxResponseHeadersToShowInTryIt: { type: 'number' },
|
|
436
446
|
scrollYOffset: { type: 'string' },
|
|
437
447
|
searchAutoExpand: { type: 'boolean' },
|
|
438
448
|
searchFieldLevelBoost: { type: 'number' },
|
|
@@ -444,6 +454,8 @@ const ConfigReferenceDocs = {
|
|
|
444
454
|
showExtensions: { type: 'boolean' },
|
|
445
455
|
showNextButton: { type: 'boolean' },
|
|
446
456
|
showRightPanelToggle: { type: 'boolean' },
|
|
457
|
+
showWebhookVerb: { type: 'boolean' },
|
|
458
|
+
showObjectSchemaExamples: { type: 'boolean' },
|
|
447
459
|
sidebarLinks: 'ConfigSidebarLinks',
|
|
448
460
|
sideNavStyle: { type: 'string' },
|
|
449
461
|
simpleOneOfTypeLabel: { type: 'boolean' },
|
package/lib/typings/openapi.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ export interface Oas3Operation {
|
|
|
72
72
|
servers?: Oas3Server[];
|
|
73
73
|
'x-codeSamples'?: Oas3XCodeSample[];
|
|
74
74
|
'x-code-samples'?: Oas3XCodeSample[];
|
|
75
|
+
'x-hideTryItPanel'?: boolean;
|
|
75
76
|
}
|
|
76
77
|
export interface Oas3Parameter {
|
|
77
78
|
name: string;
|
|
@@ -144,10 +145,12 @@ export interface Oas3Schema {
|
|
|
144
145
|
enum?: any[];
|
|
145
146
|
example?: any;
|
|
146
147
|
xml?: Oas3Xml;
|
|
148
|
+
'x-tags'?: string[];
|
|
147
149
|
}
|
|
148
|
-
export
|
|
150
|
+
export declare type Oas3_1Schema = Oas3Schema & {
|
|
151
|
+
type?: string | string[];
|
|
149
152
|
examples?: any[];
|
|
150
|
-
}
|
|
153
|
+
};
|
|
151
154
|
export interface Oas3_1Definition extends Oas3Definition {
|
|
152
155
|
webhooks?: Oas3_1Webhooks;
|
|
153
156
|
}
|
package/lib/typings/swagger.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export interface Oas2Operation {
|
|
|
71
71
|
security?: Oas2SecurityRequirement[];
|
|
72
72
|
'x-codeSamples'?: Oas2XCodeSample[];
|
|
73
73
|
'x-code-samples'?: Oas2XCodeSample[];
|
|
74
|
+
'x-hideTryItPanel'?: boolean;
|
|
74
75
|
}
|
|
75
76
|
export declare type Oas2Parameter = Oas2BodyParameter | Oas2SimpleParameter;
|
|
76
77
|
export interface Oas2BodyParameter {
|
|
@@ -166,6 +167,7 @@ export interface Oas2Schema {
|
|
|
166
167
|
enum?: any[];
|
|
167
168
|
example?: any;
|
|
168
169
|
xml?: Oas2Xml;
|
|
170
|
+
'x-tags'?: string[];
|
|
169
171
|
}
|
|
170
172
|
export declare type Oas2ParameterLocation = 'query' | 'header' | 'path' | 'formData';
|
|
171
173
|
export interface Oas2Responses {
|
package/lib/utils.d.ts
CHANGED
|
@@ -22,7 +22,6 @@ export declare function readFileFromUrl(url: string, config: HttpResolveConfig):
|
|
|
22
22
|
body: any;
|
|
23
23
|
mimeType: any;
|
|
24
24
|
}>;
|
|
25
|
-
export declare function match(url: string, pattern: string): boolean;
|
|
26
25
|
export declare function pickObjectProps<T extends Record<string, unknown>>(object: T, keys: Array<string>): T;
|
|
27
26
|
export declare function omitObjectProps<T extends Record<string, unknown>>(object: T, keys: Array<string>): T;
|
|
28
27
|
export declare function splitCamelCaseIntoWords(str: string): Set<string>;
|
|
@@ -39,3 +38,4 @@ export declare function isNotEmptyObject(obj: any): boolean;
|
|
|
39
38
|
export declare function isString(value: unknown): value is string;
|
|
40
39
|
export declare function isNotString<T>(value: string | T): value is T;
|
|
41
40
|
export declare function assignExisting<T>(target: Record<string, T>, obj: Record<string, T>): void;
|
|
41
|
+
export declare const getMatchingStatusCodeRange: (code: number | string) => string;
|
package/lib/utils.js
CHANGED
|
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.assignExisting = exports.isNotString = exports.isString = exports.isNotEmptyObject = exports.slash = exports.isPathParameter = exports.readFileAsStringSync = exports.isSingular = exports.validateMimeTypeOAS3 = exports.validateMimeType = exports.splitCamelCaseIntoWords = exports.omitObjectProps = exports.pickObjectProps = exports.
|
|
12
|
+
exports.getMatchingStatusCodeRange = exports.assignExisting = exports.isNotString = exports.isString = exports.isNotEmptyObject = exports.slash = exports.isPathParameter = exports.readFileAsStringSync = exports.isSingular = exports.validateMimeTypeOAS3 = exports.validateMimeType = exports.splitCamelCaseIntoWords = exports.omitObjectProps = exports.pickObjectProps = exports.readFileFromUrl = exports.isEmptyArray = exports.isEmptyObject = exports.isPlainObject = exports.notUndefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0;
|
|
13
13
|
const fs = require("fs");
|
|
14
14
|
const minimatch = require("minimatch");
|
|
15
15
|
const node_fetch_1 = require("node-fetch");
|
|
16
16
|
const pluralize = require("pluralize");
|
|
17
17
|
const js_yaml_1 = require("./js-yaml");
|
|
18
|
+
const config_1 = require("./config");
|
|
18
19
|
var js_yaml_2 = require("./js-yaml");
|
|
19
20
|
Object.defineProperty(exports, "parseYaml", { enumerable: true, get: function () { return js_yaml_2.parseYaml; } });
|
|
20
21
|
Object.defineProperty(exports, "stringifyYaml", { enumerable: true, get: function () { return js_yaml_2.stringifyYaml; } });
|
|
@@ -56,7 +57,7 @@ function readFileFromUrl(url, config) {
|
|
|
56
57
|
for (const header of config.headers) {
|
|
57
58
|
if (match(url, header.matches)) {
|
|
58
59
|
headers[header.name] =
|
|
59
|
-
header.envVariable !== undefined ?
|
|
60
|
+
header.envVariable !== undefined ? config_1.env[header.envVariable] || '' : header.value;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
const req = yield (config.customFetch || node_fetch_1.default)(url, {
|
|
@@ -76,7 +77,6 @@ function match(url, pattern) {
|
|
|
76
77
|
}
|
|
77
78
|
return minimatch(url, pattern);
|
|
78
79
|
}
|
|
79
|
-
exports.match = match;
|
|
80
80
|
function pickObjectProps(object, keys) {
|
|
81
81
|
return Object.fromEntries(keys.filter((key) => key in object).map((key) => [key, object[key]]));
|
|
82
82
|
}
|
|
@@ -173,3 +173,5 @@ function assignExisting(target, obj) {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
exports.assignExisting = assignExisting;
|
|
176
|
+
const getMatchingStatusCodeRange = (code) => `${code}`.replace(/^(\d)\d\d$/, (_, firstDigit) => `${firstDigit}XX`);
|
|
177
|
+
exports.getMatchingStatusCodeRange = getMatchingStatusCodeRange;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/openapi-core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.99",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"js-levenshtein": "^1.1.6",
|
|
40
40
|
"js-yaml": "^4.1.0",
|
|
41
41
|
"lodash.isequal": "^4.5.0",
|
|
42
|
-
"minimatch": "^
|
|
42
|
+
"minimatch": "^5.0.1",
|
|
43
43
|
"node-fetch": "^2.6.1",
|
|
44
44
|
"pluralize": "^8.0.0",
|
|
45
45
|
"yaml-ast-parser": "0.0.43"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/js-levenshtein": "^1.1.0",
|
|
49
49
|
"@types/js-yaml": "^4.0.3",
|
|
50
50
|
"@types/lodash.isequal": "^4.5.5",
|
|
51
|
-
"@types/minimatch": "^3.0.
|
|
51
|
+
"@types/minimatch": "^3.0.5",
|
|
52
52
|
"@types/node-fetch": "^2.5.7",
|
|
53
53
|
"@types/pluralize": "^0.0.29",
|
|
54
54
|
"typescript": "^4.0.5"
|
|
@@ -100,6 +100,32 @@ components:
|
|
|
100
100
|
|
|
101
101
|
`;
|
|
102
102
|
|
|
103
|
+
exports[`bundle should not bundle url refs if used with keepUrlRefs 1`] = `
|
|
104
|
+
openapi: 3.0.0
|
|
105
|
+
paths:
|
|
106
|
+
/pet:
|
|
107
|
+
parameters:
|
|
108
|
+
- $ref: '#/components/parameters/path-param'
|
|
109
|
+
put:
|
|
110
|
+
parameters:
|
|
111
|
+
- $ref: https://someexternal.schema
|
|
112
|
+
- $ref: '#/components/parameters/param-b'
|
|
113
|
+
- name: test
|
|
114
|
+
get:
|
|
115
|
+
parameters:
|
|
116
|
+
- $ref: http://someexternal.schema
|
|
117
|
+
- $ref: '#/components/parameters/param-c'
|
|
118
|
+
components:
|
|
119
|
+
parameters:
|
|
120
|
+
path-param:
|
|
121
|
+
name: path_param
|
|
122
|
+
param-c:
|
|
123
|
+
name: param_c
|
|
124
|
+
param-b:
|
|
125
|
+
name: param_b
|
|
126
|
+
|
|
127
|
+
`;
|
|
128
|
+
|
|
103
129
|
exports[`bundle should not place referened schema inline when component in question is not of type "schemas" 1`] = `
|
|
104
130
|
openapi: 3.0.0
|
|
105
131
|
paths:
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import outdent from 'outdent';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
|
|
4
|
-
import { bundleDocument, bundle } from '../
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { BaseResolver } from '../src/resolve';
|
|
4
|
+
import { bundleDocument, bundle } from '../bundle';
|
|
5
|
+
import { parseYamlToDocument, yamlSerializer } from '../../__tests__/utils';
|
|
6
|
+
import { LintConfig, Config, ResolvedConfig } from '../config';
|
|
7
|
+
import { BaseResolver } from '../resolve';
|
|
9
8
|
|
|
10
9
|
describe('bundle', () => {
|
|
11
10
|
expect.addSnapshotSerializer(yamlSerializer);
|
|
@@ -128,5 +127,30 @@ describe('bundle', () => {
|
|
|
128
127
|
}
|
|
129
128
|
);
|
|
130
129
|
expect(res.parsed).toMatchSnapshot();
|
|
131
|
-
})
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should not bundle url refs if used with keepUrlRefs', async () => {
|
|
133
|
+
const fetchMock = jest.fn(() =>
|
|
134
|
+
Promise.resolve({
|
|
135
|
+
ok: true,
|
|
136
|
+
text: () => 'External schema content',
|
|
137
|
+
headers: {
|
|
138
|
+
get: () => '',
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
);
|
|
142
|
+
const { bundle: res, problems } = await bundle({
|
|
143
|
+
config: new Config({} as ResolvedConfig),
|
|
144
|
+
externalRefResolver: new BaseResolver({
|
|
145
|
+
http: {
|
|
146
|
+
customFetch: fetchMock,
|
|
147
|
+
headers: [],
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
ref: path.join(__dirname, 'fixtures/refs/openapi-with-url-refs.yaml'),
|
|
151
|
+
keepUrlRefs: true,
|
|
152
|
+
});
|
|
153
|
+
expect(problems).toHaveLength(0);
|
|
154
|
+
expect(res.parsed).toMatchSnapshot();
|
|
155
|
+
});
|
|
132
156
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
|
|
3
|
-
import { getLineColLocation, getCodeframe } from '../
|
|
4
|
-
import { LocationObject } from '../
|
|
5
|
-
import { Source } from '../
|
|
3
|
+
import { getLineColLocation, getCodeframe } from '../format/codeframes';
|
|
4
|
+
import { LocationObject } from '../walk';
|
|
5
|
+
import { Source } from '../resolve';
|
|
6
6
|
|
|
7
7
|
describe('Location', () => {
|
|
8
8
|
it('should correctly calculate location for key', () => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/{__tests__ → src/__tests__}/fixtures/refs/openapi-with-external-refs-conflicting-names.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
openapi: 3.0.0
|
|
2
|
+
paths:
|
|
3
|
+
/pet:
|
|
4
|
+
parameters:
|
|
5
|
+
- $ref: '#/components/parameters/path-param'
|
|
6
|
+
put:
|
|
7
|
+
parameters:
|
|
8
|
+
- $ref: 'https://someexternal.schema'
|
|
9
|
+
- $ref: ./param-b.yaml
|
|
10
|
+
- name: test
|
|
11
|
+
get:
|
|
12
|
+
parameters:
|
|
13
|
+
- $ref: 'http://someexternal.schema'
|
|
14
|
+
- $ref: ./param-c.yaml
|
|
15
|
+
components:
|
|
16
|
+
parameters:
|
|
17
|
+
path-param:
|
|
18
|
+
name: path_param
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -4,6 +4,7 @@ import { lintFromString, lintConfig, lintDocument } from '../lint';
|
|
|
4
4
|
import { BaseResolver } from '../resolve';
|
|
5
5
|
import { loadConfig } from '../config/load';
|
|
6
6
|
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../__tests__/utils';
|
|
7
|
+
import { detectOpenAPI } from '../oas-types';
|
|
7
8
|
|
|
8
9
|
describe('lint', () => {
|
|
9
10
|
it('lintFromString should work', async () => {
|
|
@@ -179,4 +180,16 @@ describe('lint', () => {
|
|
|
179
180
|
|
|
180
181
|
expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`Array []`);
|
|
181
182
|
});
|
|
183
|
+
|
|
184
|
+
it('detect OpenAPI should throw an error when version is not string', () => {
|
|
185
|
+
const testDocument = parseYamlToDocument(
|
|
186
|
+
outdent`
|
|
187
|
+
openapi: 3.0
|
|
188
|
+
`,
|
|
189
|
+
'',
|
|
190
|
+
);
|
|
191
|
+
expect(() => detectOpenAPI(testDocument.parsed)).toThrow(
|
|
192
|
+
`Invalid OpenAPI version: should be a string but got "number"`,
|
|
193
|
+
);
|
|
194
|
+
});
|
|
182
195
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { normalizeVisitors, VisitorLevelContext } from '../
|
|
2
|
-
import { Oas3RuleSet } from '../
|
|
3
|
-
import { Oas3Types } from '../
|
|
4
|
-
import { normalizeTypes } from '../
|
|
1
|
+
import { normalizeVisitors, VisitorLevelContext } from '../visitors';
|
|
2
|
+
import { Oas3RuleSet } from '../oas-types';
|
|
3
|
+
import { Oas3Types } from '../types/oas3';
|
|
4
|
+
import { normalizeTypes } from '../types';
|
|
5
5
|
|
|
6
6
|
describe('Normalize visitors', () => {
|
|
7
7
|
it('should work correctly for single rule', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import outdent from 'outdent';
|
|
2
|
-
import { parseYamlToDocument } from '
|
|
3
|
-
import { parseRef, refBaseName } from '../
|
|
4
|
-
import { lintDocument } from '../
|
|
5
|
-
import { LintConfig } from '../
|
|
6
|
-
import { BaseResolver } from '../
|
|
2
|
+
import { parseYamlToDocument } from '../../__tests__/utils';
|
|
3
|
+
import { parseRef, refBaseName } from '../ref-utils';
|
|
4
|
+
import { lintDocument } from '../lint';
|
|
5
|
+
import { LintConfig } from '../config';
|
|
6
|
+
import { BaseResolver } from '../resolve';
|
|
7
7
|
|
|
8
8
|
describe('ref-utils', () => {
|
|
9
9
|
it(`should unescape refs with '/'`, () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
|
|
3
|
-
import { resolveDocument, BaseResolver } from '../
|
|
4
|
-
import { parseYamlToDocument } from '
|
|
5
|
-
import { Oas3Types } from '../
|
|
6
|
-
import { normalizeTypes } from '../
|
|
3
|
+
import { resolveDocument, BaseResolver } from '../resolve';
|
|
4
|
+
import { parseYamlToDocument } from '../../__tests__/utils';
|
|
5
|
+
import { Oas3Types } from '../types/oas3';
|
|
6
|
+
import { normalizeTypes } from '../types';
|
|
7
7
|
|
|
8
8
|
describe('Resolve http-headers', () => {
|
|
9
9
|
it('should use matching http-headers', async () => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { outdent } from 'outdent';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
|
|
4
|
-
import { resolveDocument, BaseResolver, Document } from '../
|
|
5
|
-
import { parseYamlToDocument } from '
|
|
6
|
-
import { Oas3Types } from '../
|
|
7
|
-
import { normalizeTypes } from '../
|
|
4
|
+
import { resolveDocument, BaseResolver, Document } from '../resolve';
|
|
5
|
+
import { parseYamlToDocument } from '../../__tests__/utils';
|
|
6
|
+
import { Oas3Types } from '../types/oas3';
|
|
7
|
+
import { normalizeTypes } from '../types';
|
|
8
8
|
|
|
9
9
|
describe('collect refs', () => {
|
|
10
10
|
it('should resolve local refs', async () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pickObjectProps, omitObjectProps, slash } from '../utils';
|
|
1
|
+
import { pickObjectProps, omitObjectProps, slash, getMatchingStatusCodeRange } from '../utils';
|
|
2
2
|
|
|
3
3
|
describe('utils', () => {
|
|
4
4
|
const testObject = {
|
|
@@ -71,4 +71,15 @@ describe('utils', () => {
|
|
|
71
71
|
expect(slash(extended)).toBe(extended);
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
|
+
|
|
75
|
+
describe('getMatchingStatusCodeRange', () => {
|
|
76
|
+
it('should get the generalized form of status codes', () => {
|
|
77
|
+
expect(getMatchingStatusCodeRange('202')).toEqual('2XX');
|
|
78
|
+
expect(getMatchingStatusCodeRange(400)).toEqual('4XX');
|
|
79
|
+
});
|
|
80
|
+
it('should fail on a wrong input', () => {
|
|
81
|
+
expect(getMatchingStatusCodeRange('2002')).toEqual('2002');
|
|
82
|
+
expect(getMatchingStatusCodeRange(4000)).toEqual('4000');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
74
85
|
});
|
|
@@ -2,12 +2,12 @@ import outdent from 'outdent';
|
|
|
2
2
|
import each from 'jest-each';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
|
|
5
|
-
import { lintDocument } from '../
|
|
5
|
+
import { lintDocument } from '../lint';
|
|
6
6
|
|
|
7
|
-
import { parseYamlToDocument, replaceSourceWithRef, makeConfigForRuleset } from '
|
|
8
|
-
import { BaseResolver, Document } from '../
|
|
9
|
-
import { listOf } from '../
|
|
10
|
-
import { Oas3RuleSet } from '../
|
|
7
|
+
import { parseYamlToDocument, replaceSourceWithRef, makeConfigForRuleset } from '../../__tests__/utils';
|
|
8
|
+
import { BaseResolver, Document } from '../resolve';
|
|
9
|
+
import { listOf } from '../types';
|
|
10
|
+
import { Oas3RuleSet } from '../oas-types';
|
|
11
11
|
|
|
12
12
|
describe('walk order', () => {
|
|
13
13
|
it('should run visitors', async () => {
|