@scalar/openapi-parser 0.26.0 → 0.27.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 +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/Validator/Validator.d.ts +4 -3
- package/dist/lib/Validator/Validator.d.ts.map +1 -1
- package/dist/lib/Validator/Validator.js +15 -2
- package/dist/types/index.d.ts +33 -13
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/filter.d.ts +2 -2
- package/dist/utils/filter.d.ts.map +1 -1
- package/dist/utils/join/join.d.ts +2 -2
- package/dist/utils/join/join.d.ts.map +1 -1
- package/dist/utils/join/join.js +9 -6
- package/dist/utils/load/load.d.ts.map +1 -1
- package/dist/utils/load/load.js +1 -4
- package/dist/utils/make-filesystem.d.ts +2 -2
- package/dist/utils/make-filesystem.d.ts.map +1 -1
- package/dist/utils/make-filesystem.js +3 -0
- package/dist/utils/openapi/commands/loadCommand.d.ts +46 -46
- package/dist/utils/openapi/commands/loadCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/upgradeCommand.d.ts +23 -23
- package/dist/utils/openapi/commands/upgradeCommand.d.ts.map +1 -1
- package/dist/utils/openapi/commands/validateCommand.d.ts +23 -23
- package/dist/utils/openapi/commands/validateCommand.d.ts.map +1 -1
- package/dist/utils/openapi/openapi.d.ts +397 -397
- package/dist/utils/resolve-references.d.ts +2 -3
- package/dist/utils/resolve-references.d.ts.map +1 -1
- package/dist/utils/resolve-references.js +3 -0
- package/dist/utils/transform/sanitize.d.ts +2 -3
- package/dist/utils/transform/sanitize.d.ts.map +1 -1
- package/dist/utils/upgrade.d.ts +3 -3
- package/dist/utils/upgrade.d.ts.map +1 -1
- package/dist/utils/validate.d.ts +2 -2
- package/dist/utils/validate.d.ts.map +1 -1
- package/dist/utils/validate.js +36 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ upgradeFromTwoToThree, } from '@scalar/openapi-upgrader/2.0-to-3.0';
|
|
|
7
7
|
export {
|
|
8
8
|
/** @deprecated Please import from @scalar/openapi-upgrader/3.0-to-3.1 instead */
|
|
9
9
|
upgradeFromThreeToThreeOne, } from '@scalar/openapi-upgrader/3.0-to-3.1';
|
|
10
|
-
export type { AnyObject, ErrorObject, Filesystem, LoadResult } from './types/index.js';
|
|
10
|
+
export type { AnyObject, ErrorObject, Filesystem, LoadResult, UnknownObject } from './types/index.js';
|
|
11
11
|
export { type DereferenceOptions, dereference } from './utils/dereference.js';
|
|
12
12
|
export { filter } from './utils/filter.js';
|
|
13
13
|
export { isJson } from './utils/is-json.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACL,4FAA4F;AAC5F,iBAAiB,GAClB,MAAM,gDAAgD,CAAA;AACvD,OAAO;AACL,iFAAiF;AACjF,qBAAqB,GACtB,MAAM,qCAAqC,CAAA;AAC5C,OAAO;AACL,iFAAiF;AACjF,0BAA0B,GAC3B,MAAM,qCAAqC,CAAA;AAE5C,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACL,4FAA4F;AAC5F,iBAAiB,GAClB,MAAM,gDAAgD,CAAA;AACvD,OAAO;AACL,iFAAiF;AACjF,qBAAqB,GACtB,MAAM,qCAAqC,CAAA;AAC5C,OAAO;AACL,iFAAiF;AACjF,0BAA0B,GAC3B,MAAM,qCAAqC,CAAA;AAE5C,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5F,OAAO,EAAE,KAAK,kBAAkB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ValidateFunction } from 'ajv';
|
|
2
2
|
import { type OpenApiVersion } from '../../configuration/index.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Filesystem, ThrowOnErrorOption, UnknownObject, ValidationOutcome } from '../../types/index.js';
|
|
4
4
|
export declare class Validator {
|
|
5
5
|
version: OpenApiVersion;
|
|
6
6
|
static supportedVersions: ("2.0" | "3.0" | "3.1" | "3.2")[];
|
|
@@ -8,11 +8,12 @@ export declare class Validator {
|
|
|
8
8
|
protected errors: string;
|
|
9
9
|
protected specificationVersion: string;
|
|
10
10
|
protected specificationType: string;
|
|
11
|
-
specification:
|
|
11
|
+
specification: UnknownObject;
|
|
12
|
+
private isMutableRecord;
|
|
12
13
|
/**
|
|
13
14
|
* Checks whether a specification is valid and all references can be resolved.
|
|
14
15
|
*/
|
|
15
|
-
validate(filesystem: Filesystem, options?: ThrowOnErrorOption):
|
|
16
|
+
validate(filesystem: Filesystem, options?: ThrowOnErrorOption): ValidationOutcome;
|
|
16
17
|
/**
|
|
17
18
|
* Ajv JSON schema validator
|
|
18
19
|
*/
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,UAAU,EAAmB,kBAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAetH,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,aAAa,CAAA;IAEnC,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,iBAAiB;IAmGjF;;OAEG;IACH,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB;CAkC3D"}
|
|
@@ -24,6 +24,9 @@ export class Validator {
|
|
|
24
24
|
specificationVersion;
|
|
25
25
|
specificationType;
|
|
26
26
|
specification;
|
|
27
|
+
isMutableRecord(value) {
|
|
28
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
29
|
+
}
|
|
27
30
|
/**
|
|
28
31
|
* Checks whether a specification is valid and all references can be resolved.
|
|
29
32
|
*/
|
|
@@ -34,7 +37,9 @@ export class Validator {
|
|
|
34
37
|
this.specification = specification;
|
|
35
38
|
// TODO: defaulting info.version to keep parser compatible with the previous one
|
|
36
39
|
// we should bubble this error up and not throw on it
|
|
37
|
-
if (this.
|
|
40
|
+
if (this.isMutableRecord(this.specification) &&
|
|
41
|
+
this.isMutableRecord(this.specification.info) &&
|
|
42
|
+
typeof this.specification.info.version !== 'string') {
|
|
38
43
|
this.specification.info.version = '0.0.1';
|
|
39
44
|
}
|
|
40
45
|
try {
|
|
@@ -82,8 +87,16 @@ export class Validator {
|
|
|
82
87
|
const resolvedReferences = resolveReferences(filesystem, options);
|
|
83
88
|
const semanticErrors = validatePathParameters(resolvedReferences.schema);
|
|
84
89
|
const errors = [...resolvedReferences.errors, ...semanticErrors];
|
|
90
|
+
const valid = schemaResult && resolvedReferences.valid && semanticErrors.length === 0;
|
|
91
|
+
if (!valid) {
|
|
92
|
+
return {
|
|
93
|
+
valid: false,
|
|
94
|
+
errors,
|
|
95
|
+
schema: resolvedReferences.schema,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
85
98
|
return {
|
|
86
|
-
valid:
|
|
99
|
+
valid: true,
|
|
87
100
|
errors,
|
|
88
101
|
schema: resolvedReferences.schema,
|
|
89
102
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Document as OpenApiDocumentV2 } from '@scalar/openapi-types/2.0';
|
|
2
|
+
import type { Document as OpenApiDocumentV3 } from '@scalar/openapi-types/3.0';
|
|
3
|
+
import type { Document as OpenApiDocumentV3_1 } from '@scalar/openapi-types/3.1';
|
|
4
|
+
import type { Document as OpenApiDocumentV3_2 } from '@scalar/openapi-types/3.2';
|
|
2
5
|
import type { ERRORS, OpenApiVersion } from '../configuration/index.js';
|
|
3
6
|
/**
|
|
4
7
|
* Merge types with each other
|
|
@@ -9,25 +12,42 @@ export type UnknownObject = Record<string, unknown>;
|
|
|
9
12
|
/**
|
|
10
13
|
* JSON, YAML or object representation of an OpenAPI API definition
|
|
11
14
|
*/
|
|
12
|
-
export type AnyApiDefinitionFormat = string |
|
|
15
|
+
export type AnyApiDefinitionFormat = string | UnknownObject | Filesystem;
|
|
16
|
+
export type StrictOpenApiDocument = OpenApiDocumentV2 | OpenApiDocumentV3 | OpenApiDocumentV3_1 | OpenApiDocumentV3_2;
|
|
17
|
+
export type OpenApiDocument = StrictOpenApiDocument;
|
|
13
18
|
export type LoadResult = {
|
|
14
19
|
filesystem: Filesystem;
|
|
15
|
-
specification:
|
|
20
|
+
specification: UnknownObject | null;
|
|
16
21
|
errors?: ErrorObject[];
|
|
17
22
|
};
|
|
18
23
|
export type ValidateResult = {
|
|
19
|
-
valid:
|
|
20
|
-
specification
|
|
24
|
+
valid: true;
|
|
25
|
+
specification: StrictOpenApiDocument;
|
|
26
|
+
version: OpenApiVersion;
|
|
27
|
+
errors?: ErrorObject[];
|
|
28
|
+
schema: StrictOpenApiDocument;
|
|
29
|
+
} | {
|
|
30
|
+
valid: false;
|
|
31
|
+
specification?: UnknownObject;
|
|
21
32
|
version?: OpenApiVersion;
|
|
33
|
+
errors: ErrorObject[];
|
|
34
|
+
schema?: UnknownObject;
|
|
35
|
+
};
|
|
36
|
+
export type ValidationOutcome = {
|
|
37
|
+
valid: true;
|
|
22
38
|
errors?: ErrorObject[];
|
|
23
|
-
schema
|
|
39
|
+
schema: StrictOpenApiDocument;
|
|
40
|
+
} | {
|
|
41
|
+
valid: false;
|
|
42
|
+
errors: ErrorObject[];
|
|
43
|
+
schema?: UnknownObject;
|
|
24
44
|
};
|
|
25
|
-
export type UpgradeResult<T extends
|
|
45
|
+
export type UpgradeResult<T extends OpenApiDocument = OpenApiDocument> = {
|
|
26
46
|
specification: T;
|
|
27
47
|
version: '3.1';
|
|
28
48
|
};
|
|
29
49
|
export type FilterResult = {
|
|
30
|
-
specification:
|
|
50
|
+
specification: UnknownObject;
|
|
31
51
|
};
|
|
32
52
|
export type DetailsResult = {
|
|
33
53
|
version: OpenApiVersion;
|
|
@@ -36,8 +56,8 @@ export type DetailsResult = {
|
|
|
36
56
|
};
|
|
37
57
|
export type DereferenceResult = {
|
|
38
58
|
version?: OpenApiVersion;
|
|
39
|
-
specification?:
|
|
40
|
-
schema?:
|
|
59
|
+
specification?: UnknownObject;
|
|
60
|
+
schema?: UnknownObject;
|
|
41
61
|
errors?: ErrorObject[];
|
|
42
62
|
};
|
|
43
63
|
export type ErrorObject = {
|
|
@@ -58,7 +78,7 @@ export type FilesystemEntry = {
|
|
|
58
78
|
isEntrypoint: boolean;
|
|
59
79
|
references: string[];
|
|
60
80
|
filename: string;
|
|
61
|
-
specification:
|
|
81
|
+
specification: UnknownObject;
|
|
62
82
|
};
|
|
63
83
|
/**
|
|
64
84
|
* Options, that can apply to all commands
|
|
@@ -86,7 +106,7 @@ export type Queue<T extends readonly Task[] = readonly Task[]> = {
|
|
|
86
106
|
/** The original input, can be a JSON or YAML string or an object */
|
|
87
107
|
input: AnyApiDefinitionFormat;
|
|
88
108
|
/** The current OpenAPI document, but as an object */
|
|
89
|
-
specification:
|
|
109
|
+
specification: UnknownObject;
|
|
90
110
|
/** Global options */
|
|
91
111
|
options?: OpenApiOptions;
|
|
92
112
|
/** Queued tasks */
|
|
@@ -98,7 +118,7 @@ export type Queue<T extends readonly Task[] = readonly Task[]> = {
|
|
|
98
118
|
export type Task = Commands[keyof Commands]['task'];
|
|
99
119
|
type EmptyCommandChainResult = {
|
|
100
120
|
filesystem: Filesystem;
|
|
101
|
-
specification:
|
|
121
|
+
specification: UnknownObject;
|
|
102
122
|
};
|
|
103
123
|
/**
|
|
104
124
|
* Command chain magic
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC9E,OAAO,KAAK,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC9E,OAAO,KAAK,EAAE,QAAQ,IAAI,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,KAAK,EAAE,QAAQ,IAAI,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAG7D;;GAEG;AACH,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;AAEvC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE3C,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEnD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,aAAa,GAAG,UAAU,CAAA;AAExE,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,mBAAmB,CAAA;AAErH,MAAM,MAAM,eAAe,GAAG,qBAAqB,CAAA;AAEnD,MAAM,MAAM,UAA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aAAa,EAAE,aAAa,CAAA;CAC7B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,GAC/E,KAAK,SAAS,IAAI,GAChB,IAAI,SAAS,IAAI,EAAE,GACjB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC,GAC5D,KAAK,GACP,KAAK,GACP,uBAAuB,CAAA"}
|
package/dist/utils/filter.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AnyApiDefinitionFormat,
|
|
2
|
-
export type FilterCallback = (schema:
|
|
1
|
+
import type { AnyApiDefinitionFormat, UnknownObject, FilterResult } from '../types/index.js';
|
|
2
|
+
export type FilterCallback = (schema: UnknownObject) => boolean;
|
|
3
3
|
/**
|
|
4
4
|
* Filter the specification based on the callback
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/utils/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/utils/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAKxF,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,OAAO,CAAA;AAE/D;;GAEG;AACH,wBAAgB,MAAM,CAAC,aAAa,EAAE,sBAAsB,EAAE,QAAQ,EAAE,cAAc,GAAG,YAAY,CAQpG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Document as OpenApiDocumentV3_1 } from '@scalar/openapi-types/3.1';
|
|
2
2
|
import type { UnknownObject } from '../../types/index.js';
|
|
3
3
|
type Conflicts = {
|
|
4
4
|
type: 'path';
|
|
@@ -15,7 +15,7 @@ type Conflicts = {
|
|
|
15
15
|
};
|
|
16
16
|
type JoinResult = {
|
|
17
17
|
ok: true;
|
|
18
|
-
document:
|
|
18
|
+
document: OpenApiDocumentV3_1;
|
|
19
19
|
} | {
|
|
20
20
|
ok: false;
|
|
21
21
|
conflicts: Conflicts[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../src/utils/join/join.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../src/utils/join/join.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,QAAQ,IAAI,mBAAmB,EAKhC,MAAM,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAyO5C,KAAK,SAAS,GACV;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAC9D,KAAK,UAAU,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,SAAS,EAAE,CAAA;CAAE,CAAA;AAMrG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,IAAI,GAAU,QAAQ,aAAa,EAAE,EAAE,SAAS;IAAE,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAAE,KAAG,OAAO,CAAC,UAAU,CAkE/G,CAAA"}
|
package/dist/utils/join/join.js
CHANGED
|
@@ -43,7 +43,7 @@ const withDefault = (value, defaultValue) => {
|
|
|
43
43
|
* - If the same operation (e.g., "get") exists for the same path in multiple inputs,
|
|
44
44
|
* a conflict is recorded for that path and method.
|
|
45
45
|
*
|
|
46
|
-
* @param inputs - Array of
|
|
46
|
+
* @param inputs - Array of OpenAPI 3.1 PathsObjects to merge
|
|
47
47
|
* @returns An object containing the merged paths and a list of conflicts
|
|
48
48
|
*/
|
|
49
49
|
const mergePaths = (inputs) => {
|
|
@@ -73,7 +73,7 @@ const mergePaths = (inputs) => {
|
|
|
73
73
|
* Merges multiple arrays of OpenAPI TagObjects into a single array, ensuring uniqueness by tag name.
|
|
74
74
|
* - If a tag with the same name appears in multiple arrays, only the first occurrence is included in the result.
|
|
75
75
|
*
|
|
76
|
-
* @param inputs - Array of arrays of
|
|
76
|
+
* @param inputs - Array of arrays of OpenAPI 3.1 TagObjects to merge
|
|
77
77
|
* @returns An array of unique TagObjects (by name)
|
|
78
78
|
*/
|
|
79
79
|
const mergeTags = (inputs) => {
|
|
@@ -93,7 +93,7 @@ const mergeTags = (inputs) => {
|
|
|
93
93
|
* Merges multiple arrays of OpenAPI ServerObjects into a single array, ensuring uniqueness by server URL.
|
|
94
94
|
* - If a server with the same URL appears in multiple arrays, only the first occurrence is included in the result.
|
|
95
95
|
*
|
|
96
|
-
* @param inputs - Array of arrays of
|
|
96
|
+
* @param inputs - Array of arrays of OpenAPI 3.1 ServerObjects to merge
|
|
97
97
|
* @returns An array of unique ServerObjects (by url)
|
|
98
98
|
*/
|
|
99
99
|
const mergeServers = (inputs) => {
|
|
@@ -114,7 +114,7 @@ const mergeServers = (inputs) => {
|
|
|
114
114
|
* - If a component with the same type and name appears in multiple inputs, only the first occurrence is included.
|
|
115
115
|
* - Any conflicts (duplicate component names within the same type) are recorded in the `conflicts` array.
|
|
116
116
|
*
|
|
117
|
-
* @param inputs - Array of
|
|
117
|
+
* @param inputs - Array of OpenAPI 3.1 ComponentsObjects to merge
|
|
118
118
|
* @returns An object containing the merged components and an array of conflicts
|
|
119
119
|
*/
|
|
120
120
|
const mergeComponents = (inputs) => {
|
|
@@ -203,6 +203,9 @@ const prefixComponents = async (inputs, prefixes) => {
|
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
|
+
const asOpenApiDocumentV3_1 = (document) => {
|
|
207
|
+
return document;
|
|
208
|
+
};
|
|
206
209
|
/**
|
|
207
210
|
* Joins multiple OpenAPI documents into a single document.
|
|
208
211
|
*
|
|
@@ -279,7 +282,7 @@ export const join = async (inputs, config) => {
|
|
|
279
282
|
// Return the merged OpenAPI document
|
|
280
283
|
return {
|
|
281
284
|
ok: true,
|
|
282
|
-
document: {
|
|
285
|
+
document: asOpenApiDocumentV3_1({
|
|
283
286
|
...result,
|
|
284
287
|
info,
|
|
285
288
|
paths,
|
|
@@ -287,6 +290,6 @@ export const join = async (inputs, config) => {
|
|
|
287
290
|
tags: withDefault(tags, undefined),
|
|
288
291
|
servers: withDefault(servers, undefined),
|
|
289
292
|
components: withDefault(components, undefined),
|
|
290
|
-
},
|
|
293
|
+
}),
|
|
291
294
|
};
|
|
292
295
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/utils/load/load.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/utils/load/load.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAe,UAAU,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAMpH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,OAAO,CAAA;IAC/B,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAA;IACxB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IACvD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;IAC/B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,UAAU,CAAA;CACxB,GAAG,kBAAkB,CAAA;AAEtB;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,IAAI,CAAC,KAAK,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAuHpG"}
|
package/dist/utils/load/load.js
CHANGED
|
@@ -30,7 +30,7 @@ export async function load(value, options) {
|
|
|
30
30
|
}
|
|
31
31
|
// Check whether the value is an URL or file path
|
|
32
32
|
const plugin = options?.plugins?.find((thisPlugin) => thisPlugin.check(value));
|
|
33
|
-
let content;
|
|
33
|
+
let content = normalize(value);
|
|
34
34
|
if (plugin) {
|
|
35
35
|
try {
|
|
36
36
|
content = normalize(await plugin.get(value));
|
|
@@ -50,9 +50,6 @@ export async function load(value, options) {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
else {
|
|
54
|
-
content = normalize(value);
|
|
55
|
-
}
|
|
56
53
|
// No content
|
|
57
54
|
if (content === undefined) {
|
|
58
55
|
if (options?.throwOnError) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function makeFilesystem(value: string |
|
|
1
|
+
import type { Filesystem, FilesystemEntry, UnknownObject } from '../types/index.js';
|
|
2
|
+
export declare function makeFilesystem(value: string | UnknownObject | Filesystem, overwrites?: Partial<FilesystemEntry>): Filesystem;
|
|
3
3
|
//# sourceMappingURL=make-filesystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-filesystem.d.ts","sourceRoot":"","sources":["../../src/utils/make-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"make-filesystem.d.ts","sourceRoot":"","sources":["../../src/utils/make-filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAK/E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,EAC1C,UAAU,GAAE,OAAO,CAAC,eAAe,CAAM,GACxC,UAAU,CAwBZ"}
|