@scalar/openapi-parser 0.23.12 → 0.24.1
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 +29 -0
- package/dist/configuration/index.d.ts +23 -8
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/lib/Validator/Validator.d.ts +1 -1
- package/dist/lib/Validator/Validator.d.ts.map +1 -1
- package/dist/lib/Validator/Validator.js +11 -5
- package/dist/lib/Validator/Validator.js.map +2 -2
- package/dist/schemas/v2.0/schema.d.ts +3 -1
- package/dist/schemas/v2.0/schema.d.ts.map +1 -1
- package/dist/schemas/v2.0/schema.js +8 -1
- package/dist/schemas/v2.0/schema.js.map +2 -2
- package/dist/schemas/v3.0/schema.d.ts +8 -3
- package/dist/schemas/v3.0/schema.d.ts.map +1 -1
- package/dist/schemas/v3.0/schema.js +15 -5
- package/dist/schemas/v3.0/schema.js.map +2 -2
- package/dist/schemas/v3.1/schema.js +1 -1
- package/dist/schemas/v3.1/schema.js.map +1 -1
- package/dist/schemas/v3.2/schema.d.ts +12 -4
- package/dist/schemas/v3.2/schema.d.ts.map +1 -1
- package/dist/schemas/v3.2/schema.js +15 -7
- package/dist/schemas/v3.2/schema.js.map +2 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/betterAjvErrors/helpers.d.ts.map +1 -1
- package/dist/utils/betterAjvErrors/helpers.js +34 -6
- package/dist/utils/betterAjvErrors/helpers.js.map +2 -2
- package/dist/utils/betterAjvErrors/utils.d.ts +4 -0
- package/dist/utils/betterAjvErrors/utils.d.ts.map +1 -1
- package/dist/utils/betterAjvErrors/utils.js +8 -0
- package/dist/utils/betterAjvErrors/utils.js.map +2 -2
- package/dist/utils/transform-errors.d.ts +1 -1
- package/dist/utils/transform-errors.d.ts.map +1 -1
- package/dist/utils/transform-errors.js +43 -5
- package/dist/utils/transform-errors.js.map +2 -2
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @scalar/openapi-parser
|
|
2
2
|
|
|
3
|
+
## 0.24.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
#### Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- **@scalar/json-magic@0.9.1**
|
|
10
|
+
|
|
11
|
+
- **@scalar/openapi-upgrader@0.1.7**
|
|
12
|
+
|
|
13
|
+
## 0.24.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [#7171](https://github.com/scalar/scalar/pull/7171): refactor: new validator class
|
|
18
|
+
|
|
19
|
+
## 0.23.13
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
#### Updated Dependencies
|
|
24
|
+
|
|
25
|
+
- **@scalar/openapi-upgrader@0.1.7**
|
|
26
|
+
- [#7739](https://github.com/scalar/scalar/pull/7739): fix: upgrade form to multipart/form
|
|
27
|
+
- [#7694](https://github.com/scalar/scalar/pull/7694): feat: migrate x-example and x-examples
|
|
28
|
+
|
|
29
|
+
- **@scalar/json-magic@0.9.0**
|
|
30
|
+
- [#7701](https://github.com/scalar/scalar/pull/7701): Made bundle external document extensions configurable
|
|
31
|
+
|
|
3
32
|
## 0.23.12
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -168,7 +168,9 @@ export declare const OpenApiSpecifications: {
|
|
|
168
168
|
$ref: string;
|
|
169
169
|
};
|
|
170
170
|
"^/": {
|
|
171
|
-
|
|
171
|
+
oneOf: {
|
|
172
|
+
$ref: string;
|
|
173
|
+
}[];
|
|
172
174
|
};
|
|
173
175
|
};
|
|
174
176
|
additionalProperties: boolean;
|
|
@@ -2044,9 +2046,6 @@ export declare const OpenApiSpecifications: {
|
|
|
2044
2046
|
PathItem: {
|
|
2045
2047
|
type: string;
|
|
2046
2048
|
properties: {
|
|
2047
|
-
$ref: {
|
|
2048
|
-
type: string;
|
|
2049
|
-
};
|
|
2050
2049
|
summary: {
|
|
2051
2050
|
type: string;
|
|
2052
2051
|
};
|
|
@@ -2077,6 +2076,11 @@ export declare const OpenApiSpecifications: {
|
|
|
2077
2076
|
};
|
|
2078
2077
|
additionalProperties: boolean;
|
|
2079
2078
|
};
|
|
2079
|
+
PathItemOrReference: {
|
|
2080
|
+
oneOf: {
|
|
2081
|
+
$ref: string;
|
|
2082
|
+
}[];
|
|
2083
|
+
};
|
|
2080
2084
|
Operation: {
|
|
2081
2085
|
type: string;
|
|
2082
2086
|
required: string[];
|
|
@@ -2361,6 +2365,9 @@ export declare const OpenApiSpecifications: {
|
|
|
2361
2365
|
oneOf: {
|
|
2362
2366
|
$ref: string;
|
|
2363
2367
|
}[];
|
|
2368
|
+
discriminator: {
|
|
2369
|
+
propertyName: string;
|
|
2370
|
+
};
|
|
2364
2371
|
};
|
|
2365
2372
|
APIKeySecurityScheme: {
|
|
2366
2373
|
type: string;
|
|
@@ -4177,10 +4184,6 @@ export declare const OpenApiSpecifications: {
|
|
|
4177
4184
|
$comment: string;
|
|
4178
4185
|
type: string;
|
|
4179
4186
|
properties: {
|
|
4180
|
-
$ref: {
|
|
4181
|
-
type: string;
|
|
4182
|
-
format: string;
|
|
4183
|
-
};
|
|
4184
4187
|
summary: {
|
|
4185
4188
|
type: string;
|
|
4186
4189
|
};
|
|
@@ -4240,6 +4243,18 @@ export declare const OpenApiSpecifications: {
|
|
|
4240
4243
|
$ref: string;
|
|
4241
4244
|
unevaluatedProperties: boolean;
|
|
4242
4245
|
};
|
|
4246
|
+
"path-item-or-reference": {
|
|
4247
|
+
if: {
|
|
4248
|
+
type: string;
|
|
4249
|
+
required: string[];
|
|
4250
|
+
};
|
|
4251
|
+
then: {
|
|
4252
|
+
$ref: string;
|
|
4253
|
+
};
|
|
4254
|
+
else: {
|
|
4255
|
+
$ref: string;
|
|
4256
|
+
};
|
|
4257
|
+
};
|
|
4243
4258
|
operation: {
|
|
4244
4259
|
$comment: string;
|
|
4245
4260
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKjC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,qBAAqB,CAAA;AAE/D,eAAO,MAAM,eAAe,EAAyC,cAAc,EAAE,CAAA;AAErF;;GAEG;AACH,eAAO,MAAM,MAAM;;;;;;;;CAST,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ValidateFunction } from 'ajv';
|
|
2
2
|
import { type OpenApiVersion } from '../../configuration/index.js';
|
|
3
3
|
import type { AnyObject, Filesystem, ThrowOnErrorOption, ValidateResult } from '../../types/index.js';
|
|
4
4
|
export declare class Validator {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/Validator.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Validator.d.ts","sourceRoot":"","sources":["../../../src/lib/Validator/Validator.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,KAAK,CAAA;AAKhD,OAAO,EAAiC,KAAK,cAAc,EAAmB,MAAM,iBAAiB,CAAA;AACrG,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAc9F,qBAAa,SAAS;IACb,OAAO,EAAE,cAAc,CAAA;IAE9B,OAAc,iBAAiB,oCAAkB;IAGjD,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAK;IAE9D,SAAS,CAAC,MAAM,EAAE,MAAM,CAAA;IAExB,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAA;IAEtC,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAE5B,aAAa,EAAE,SAAS,CAAA;IAE/B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc;IAoF9E;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB;CAkC3D"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Ajv, {} from "ajv";
|
|
1
2
|
import Ajv2020 from "ajv/dist/2020.js";
|
|
2
3
|
import Ajv04 from "ajv-draft-04";
|
|
3
4
|
import addFormats from "ajv-formats";
|
|
@@ -7,6 +8,7 @@ import { resolveReferences } from "../../utils/resolve-references.js";
|
|
|
7
8
|
import { transformErrors } from "../../utils/transform-errors.js";
|
|
8
9
|
const jsonSchemaVersions = {
|
|
9
10
|
"http://json-schema.org/draft-04/schema#": Ajv04,
|
|
11
|
+
"http://json-schema.org/draft-07/schema#": Ajv,
|
|
10
12
|
"https://json-schema.org/draft/2020-12/schema": Ajv2020
|
|
11
13
|
};
|
|
12
14
|
class Validator {
|
|
@@ -35,7 +37,7 @@ class Validator {
|
|
|
35
37
|
}
|
|
36
38
|
return {
|
|
37
39
|
valid: false,
|
|
38
|
-
errors: transformErrors(
|
|
40
|
+
errors: transformErrors(specification, ERRORS.EMPTY_OR_INVALID)
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
const { version, specificationType, specificationVersion } = getOpenApiVersion(specification);
|
|
@@ -48,7 +50,7 @@ class Validator {
|
|
|
48
50
|
}
|
|
49
51
|
return {
|
|
50
52
|
valid: false,
|
|
51
|
-
errors: transformErrors(
|
|
53
|
+
errors: transformErrors(specification, ERRORS.OPENAPI_VERSION_NOT_SUPPORTED)
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
const validateSchema = this.getAjvValidator(version);
|
|
@@ -60,7 +62,7 @@ class Validator {
|
|
|
60
62
|
}
|
|
61
63
|
return {
|
|
62
64
|
valid: false,
|
|
63
|
-
errors: transformErrors(
|
|
65
|
+
errors: transformErrors(specification, validateSchema.errors)
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
68
|
}
|
|
@@ -76,7 +78,7 @@ class Validator {
|
|
|
76
78
|
}
|
|
77
79
|
return {
|
|
78
80
|
valid: false,
|
|
79
|
-
errors: transformErrors(
|
|
81
|
+
errors: transformErrors(specification, error.message ?? error)
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
84
|
}
|
|
@@ -92,7 +94,11 @@ class Validator {
|
|
|
92
94
|
const ajv = new AjvClass({
|
|
93
95
|
// Ajv is a bit too strict in its strict validation of OpenAPI schemas.
|
|
94
96
|
// Switch strict mode off.
|
|
95
|
-
strict: false
|
|
97
|
+
strict: false,
|
|
98
|
+
// Enable discriminator support for better oneOf error messages
|
|
99
|
+
discriminator: true,
|
|
100
|
+
// Show all errors, not just the first one
|
|
101
|
+
allErrors: true
|
|
96
102
|
});
|
|
97
103
|
addFormats(ajv);
|
|
98
104
|
if (version === "3.1" || version === "3.2") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/Validator/Validator.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import Ajv, { type ValidateFunction } from 'ajv'\nimport Ajv2020 from 'ajv/dist/2020.js'\nimport Ajv04 from 'ajv-draft-04'\nimport addFormats from 'ajv-formats'\n\nimport { ERRORS, OpenApiSpecifications, type OpenApiVersion, OpenApiVersions } from '@/configuration'\nimport type { AnyObject, Filesystem, ThrowOnErrorOption, ValidateResult } from '@/types/index'\nimport { details as getOpenApiVersion } from '@/utils/details'\nimport { resolveReferences } from '@/utils/resolve-references'\nimport { transformErrors } from '@/utils/transform-errors'\n\n/**\n * Configure available JSON Schema versions\n */\nconst jsonSchemaVersions = {\n 'http://json-schema.org/draft-04/schema#': Ajv04,\n 'http://json-schema.org/draft-07/schema#': Ajv,\n 'https://json-schema.org/draft/2020-12/schema': Ajv2020,\n}\n\nexport class Validator {\n public version: OpenApiVersion\n\n public static supportedVersions = OpenApiVersions\n\n // Object with function *or* object { errors: string }\n protected ajvValidators: Record<string, ValidateFunction> = {}\n\n protected errors: string\n\n protected specificationVersion: string\n\n protected specificationType: string\n\n public specification: AnyObject\n\n /**\n * Checks whether a specification is valid and all references can be resolved.\n */\n validate(filesystem: Filesystem, options?: ThrowOnErrorOption): ValidateResult {\n const entrypoint = filesystem.find((file) => file.isEntrypoint)\n const specification = entrypoint?.specification\n\n // TODO: How does this work with a filesystem?\n this.specification = specification\n\n // TODO: defaulting info.version to keep parser compatible with the previous one\n // we should bubble this error up and not throw on it\n if (this.specification?.info && !this.specification.info.version) {\n this.specification.info.version = '0.0.1'\n }\n\n try {\n // AnyObject is empty or invalid\n if (specification === undefined || specification === null) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.EMPTY_OR_INVALID)\n }\n\n return {\n valid: false,\n errors: transformErrors(specification, ERRORS.EMPTY_OR_INVALID),\n }\n }\n\n // Meta data about the specification\n const { version, specificationType, specificationVersion } = getOpenApiVersion(specification)\n\n this.version = version\n this.specificationVersion = specificationVersion\n this.specificationType = specificationType\n\n // AnyObject is not supported\n if (!version) {\n if (options?.throwOnError) {\n throw new Error(ERRORS.OPENAPI_VERSION_NOT_SUPPORTED)\n }\n\n return {\n valid: false,\n errors: transformErrors(specification, ERRORS.OPENAPI_VERSION_NOT_SUPPORTED),\n }\n }\n\n // Get the correct OpenAPI validator\n const validateSchema = this.getAjvValidator(version)\n const schemaResult = validateSchema(specification)\n\n // Error handling\n if (validateSchema.errors) {\n if (validateSchema.errors.length > 0) {\n if (options?.throwOnError) {\n throw new Error(validateSchema.errors[0].message)\n }\n\n return {\n valid: false,\n errors: transformErrors(specification, validateSchema.errors),\n }\n }\n }\n\n // Check if the references are valid\n const resolvedReferences = resolveReferences(filesystem, options)\n\n return {\n valid: schemaResult && resolvedReferences.valid,\n errors: [...resolvedReferences.errors],\n schema: resolvedReferences.schema,\n }\n } catch (error) {\n // Something went horribly wrong!\n if (options?.throwOnError) {\n throw error\n }\n\n return {\n valid: false,\n errors: transformErrors(specification, error.message ?? error),\n }\n }\n }\n\n /**\n * Ajv JSON schema validator\n */\n getAjvValidator(version: OpenApiVersion): ValidateFunction {\n // Schema loaded already\n if (this.ajvValidators[version]) {\n return this.ajvValidators[version]\n }\n\n // Load OpenAPI Schema\n const schema = OpenApiSpecifications[version]\n\n // Load JSON Schema\n const AjvClass = jsonSchemaVersions[schema.$schema as keyof typeof jsonSchemaVersions]\n\n // Get the correct Ajv validator\n const ajv = new AjvClass({\n // Ajv is a bit too strict in its strict validation of OpenAPI schemas.\n // Switch strict mode off.\n strict: false,\n // Enable discriminator support for better oneOf error messages\n discriminator: true,\n // Show all errors, not just the first one\n allErrors: true,\n })\n\n // Register formats\n // https://ajv.js.org/packages/ajv-formats.html#formats\n addFormats(ajv)\n\n // OpenAPI 3.1 and 3.2 uses media-range format\n if (version === '3.1' || version === '3.2') {\n ajv.addFormat('media-range', true)\n }\n\n return (this.ajvValidators[version] = ajv.compile(schema))\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,aAAoC;AAC3C,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,OAAO,gBAAgB;AAEvB,SAAS,QAAQ,uBAA4C,uBAAuB;AAEpF,SAAS,WAAW,yBAAyB;AAC7C,SAAS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,kBAAM,IAAI,MAAM,eAAe,OAAO,CAAC,EAAE,OAAO;AAAA,UAClD;AAEA,iBAAO;AAAA,YACL,OAAO;AAAA,YACP,QAAQ,gBAAgB,eAAe,eAAe,MAAM;AAAA,UAC9D;AAAA,QACF;AAAA,MACF;AAGA,YAAM,qBAAqB,kBAAkB,YAAY,OAAO;AAEhE,aAAO;AAAA,QACL,OAAO,gBAAgB,mBAAmB;AAAA,QAC1C,QAAQ,CAAC,GAAG,mBAAmB,MAAM;AAAA,QACrC,QAAQ,mBAAmB;AAAA,MAC7B;AAAA,IACF,SAAS,OAAO;AAEd,UAAI,SAAS,cAAc;AACzB,cAAM;AAAA,MACR;AAEA,aAAO;AAAA,QACL,OAAO;AAAA,QACP,QAAQ,gBAAgB,eAAe,MAAM,WAAW,KAAK;AAAA,MAC/D;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAgB,SAA2C;AAEzD,QAAI,KAAK,cAAc,OAAO,GAAG;AAC/B,aAAO,KAAK,cAAc,OAAO;AAAA,IACnC;AAGA,UAAM,SAAS,sBAAsB,OAAO;AAG5C,UAAM,WAAW,mBAAmB,OAAO,OAA0C;AAGrF,UAAM,MAAM,IAAI,SAAS;AAAA;AAAA;AAAA,MAGvB,QAAQ;AAAA;AAAA,MAER,eAAe;AAAA;AAAA,MAEf,WAAW;AAAA,IACb,CAAC;AAID,eAAW,GAAG;AAGd,QAAI,YAAY,SAAS,YAAY,OAAO;AAC1C,UAAI,UAAU,eAAe,IAAI;AAAA,IACnC;AAEA,WAAQ,KAAK,cAAc,OAAO,IAAI,IAAI,QAAQ,MAAM;AAAA,EAC1D;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/v2.0/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/sch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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAy7CC"}
|
|
@@ -168,7 +168,14 @@ var schema_default = {
|
|
|
168
168
|
"$ref": "#/definitions/vendorExtension"
|
|
169
169
|
},
|
|
170
170
|
"^/": {
|
|
171
|
-
"
|
|
171
|
+
"oneOf": [
|
|
172
|
+
{
|
|
173
|
+
"$ref": "#/definitions/pathItem"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"$ref": "#/definitions/jsonReference"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
172
179
|
}
|
|
173
180
|
},
|
|
174
181
|
"additionalProperties": false
|