@skmtc/core 0.0.594 → 0.0.596
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/esm/context/ParseContext.d.ts +2 -2
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +2 -2
- package/esm/context/StackTrail.d.ts +6 -1
- package/esm/context/StackTrail.d.ts.map +1 -1
- package/esm/context/StackTrail.js +23 -1
- package/esm/helpers/tracer.d.ts +2 -2
- package/esm/helpers/tracer.d.ts.map +1 -1
- package/esm/helpers/tracer.js +2 -2
- package/esm/oas/components/toComponentsV3.d.ts.map +1 -1
- package/esm/oas/components/toComponentsV3.js +19 -6
- package/esm/oas/example/toExamplesV3.d.ts +3 -1
- package/esm/oas/example/toExamplesV3.d.ts.map +1 -1
- package/esm/oas/example/toExamplesV3.js +3 -3
- package/esm/oas/string/String.d.ts +2 -2
- package/esm/oas/string/String.d.ts.map +1 -1
- package/esm/oas/string/string-types.d.ts +13 -1
- package/esm/oas/string/string-types.d.ts.map +1 -1
- package/esm/oas/string/string-types.js +32 -15
- package/package.json +1 -1
- package/script/context/ParseContext.d.ts +2 -2
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +2 -2
- package/script/context/StackTrail.d.ts +6 -1
- package/script/context/StackTrail.d.ts.map +1 -1
- package/script/context/StackTrail.js +23 -1
- package/script/helpers/tracer.d.ts +2 -2
- package/script/helpers/tracer.d.ts.map +1 -1
- package/script/helpers/tracer.js +2 -2
- package/script/oas/components/toComponentsV3.d.ts.map +1 -1
- package/script/oas/components/toComponentsV3.js +19 -6
- package/script/oas/example/toExamplesV3.d.ts +3 -1
- package/script/oas/example/toExamplesV3.d.ts.map +1 -1
- package/script/oas/example/toExamplesV3.js +3 -3
- package/script/oas/string/String.d.ts +2 -2
- package/script/oas/string/String.d.ts.map +1 -1
- package/script/oas/string/string-types.d.ts +13 -1
- package/script/oas/string/string-types.d.ts.map +1 -1
- package/script/oas/string/string-types.js +32 -15
|
@@ -2,7 +2,7 @@ import "../_dnt.polyfills.js";
|
|
|
2
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
3
3
|
import { OasDocument } from '../oas/document/Document.js';
|
|
4
4
|
import type * as log from '../deps/jsr.io/@std/log/0.224.8/mod.js';
|
|
5
|
-
import type { StackTrail } from './StackTrail.js';
|
|
5
|
+
import type { StackTrail, TraceOptions } from './StackTrail.js';
|
|
6
6
|
type ConstructorArgs = {
|
|
7
7
|
documentObject: OpenAPIV3.Document;
|
|
8
8
|
logger: log.Logger;
|
|
@@ -18,7 +18,7 @@ export declare class ParseContext {
|
|
|
18
18
|
stackTrail: StackTrail;
|
|
19
19
|
constructor({ documentObject, logger, stackTrail }: ConstructorArgs);
|
|
20
20
|
parse(): OasDocument;
|
|
21
|
-
trace<T>(token: string | string[], fn: () => T): T;
|
|
21
|
+
trace<T>(token: string | string[], fn: () => T, options?: TraceOptions): T;
|
|
22
22
|
logSkippedFields(skipped: Record<string, unknown>): void;
|
|
23
23
|
}
|
|
24
24
|
export declare const parseSchema: (schema: string) => OpenAPIV3.Document<{}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG/D,KAAK,eAAe,GAAG;IACrB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,qBAAa,YAAY;IACvB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;gBAEV,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,eAAe;IAOnE,KAAK;IASL,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,CAAC;IAI1E,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUlD;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,2BAMzC,CAAA"}
|
|
@@ -41,8 +41,8 @@ export class ParseContext {
|
|
|
41
41
|
});
|
|
42
42
|
return this.oasDocument;
|
|
43
43
|
}
|
|
44
|
-
trace(token, fn) {
|
|
45
|
-
return tracer(this.stackTrail, token, fn);
|
|
44
|
+
trace(token, fn, options) {
|
|
45
|
+
return tracer(this.stackTrail, token, fn, options);
|
|
46
46
|
}
|
|
47
47
|
logSkippedFields(skipped) {
|
|
48
48
|
Object.entries(skipped).forEach(([key, value]) => {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
|
+
export type TraceOptions = {
|
|
3
|
+
checkCycles?: boolean;
|
|
4
|
+
};
|
|
2
5
|
export declare class StackTrail {
|
|
3
6
|
#private;
|
|
4
7
|
constructor(stack?: (string | number)[]);
|
|
5
8
|
clone(): StackTrail;
|
|
6
9
|
slice(start: number, end?: number): StackTrail;
|
|
7
10
|
get stackTrail(): (string | number)[];
|
|
8
|
-
append(frame: string | string[]): StackTrail;
|
|
11
|
+
append(frame: string | string[], options?: TraceOptions): StackTrail;
|
|
12
|
+
checkCycles(frame: string | string[]): boolean;
|
|
13
|
+
checkCyclesArray(frames: string[]): boolean;
|
|
9
14
|
getParentOf(frame: string): string | undefined;
|
|
10
15
|
remove(frame: string | string[]): StackTrail;
|
|
11
16
|
static join(...stacks: (StackTrail | string)[]): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackTrail.d.ts","sourceRoot":"","sources":["../../src/context/StackTrail.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,qBAAa,UAAU;;gBAGT,KAAK,GAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO;IAI3C,KAAK;IAIL,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAIjC,IAAI,UAAU,wBAEb;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU;
|
|
1
|
+
{"version":3,"file":"StackTrail.d.ts","sourceRoot":"","sources":["../../src/context/StackTrail.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,qBAAa,UAAU;;gBAGT,KAAK,GAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO;IAI3C,KAAK;IAIL,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAIjC,IAAI,UAAU,wBAEb;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,UAAU;IAoBpE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO;IAQ9C,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO;IAkB3C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAW9C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU;IAsB5C,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,UAAU,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM;IAIvD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAYvC,QAAQ;CAOT"}
|
|
@@ -25,7 +25,10 @@ export class StackTrail {
|
|
|
25
25
|
get stackTrail() {
|
|
26
26
|
return __classPrivateFieldGet(this, _StackTrail_stack, "f");
|
|
27
27
|
}
|
|
28
|
-
append(frame) {
|
|
28
|
+
append(frame, options) {
|
|
29
|
+
if (options?.checkCycles && this.checkCycles(frame)) {
|
|
30
|
+
throw new Error(`Cycle detected in stack trail: ${this}`);
|
|
31
|
+
}
|
|
29
32
|
if (typeof frame === 'string') {
|
|
30
33
|
__classPrivateFieldGet(this, _StackTrail_stack, "f").push(frame);
|
|
31
34
|
return this;
|
|
@@ -36,6 +39,25 @@ export class StackTrail {
|
|
|
36
39
|
}
|
|
37
40
|
throw new Error(`Unexpected stack frame: ${frame}`);
|
|
38
41
|
}
|
|
42
|
+
checkCycles(frame) {
|
|
43
|
+
if (typeof frame === 'string') {
|
|
44
|
+
return __classPrivateFieldGet(this, _StackTrail_stack, "f").includes(frame);
|
|
45
|
+
}
|
|
46
|
+
return this.checkCyclesArray(frame);
|
|
47
|
+
}
|
|
48
|
+
checkCyclesArray(frames) {
|
|
49
|
+
if (frames.length === 0) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const lastFrame = frames[frames.length - 1];
|
|
53
|
+
const indexOfLastFrame = __classPrivateFieldGet(this, _StackTrail_stack, "f").indexOf(lastFrame);
|
|
54
|
+
if (indexOfLastFrame === -1) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return frames.toReversed().every((frame, index) => {
|
|
58
|
+
return frame === __classPrivateFieldGet(this, _StackTrail_stack, "f")[indexOfLastFrame - index];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
39
61
|
getParentOf(frame) {
|
|
40
62
|
const lastItemIndex = this.stackTrail.length - 1;
|
|
41
63
|
if (this.stackTrail?.[lastItemIndex] === frame &&
|
package/esm/helpers/tracer.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { StackTrail } from '../context/StackTrail.js';
|
|
2
|
-
export declare const tracer: <T>(stackTrail: StackTrail, token: string | string[], fn: () => T) => T;
|
|
1
|
+
import type { StackTrail, TraceOptions } from '../context/StackTrail.js';
|
|
2
|
+
export declare const tracer: <T>(stackTrail: StackTrail, token: string | string[], fn: () => T, options?: TraceOptions) => T;
|
|
3
3
|
//# sourceMappingURL=tracer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/helpers/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/helpers/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAExE,eAAO,MAAM,MAAM,GAAI,CAAC,cACV,UAAU,SACf,MAAM,GAAG,MAAM,EAAE,MACpB,MAAM,CAAC,YACD,YAAY,MASvB,CAAA"}
|
package/esm/helpers/tracer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toComponentsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/components/toComponentsV3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"toComponentsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/components/toComponentsV3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,aAAa,GAAG,SAsDvC,CAAA"}
|
|
@@ -13,20 +13,33 @@ export const toComponentsV3 = ({ components, context }) => {
|
|
|
13
13
|
const { schemas, responses, parameters, examples, requestBodies, headers, ...skipped } = components;
|
|
14
14
|
const extensionFields = toSpecificationExtensionsV3({ skipped, context });
|
|
15
15
|
const fields = {
|
|
16
|
-
schemas: context.trace('schemas', () => toOptionalSchemasV3({ schemas, context })
|
|
17
|
-
|
|
16
|
+
schemas: context.trace('schemas', () => toOptionalSchemasV3({ schemas, context }), {
|
|
17
|
+
checkCycles: true
|
|
18
|
+
}),
|
|
19
|
+
responses: context.trace('responses', () => toOptionalResponsesV3({ responses, context }), {
|
|
20
|
+
checkCycles: true
|
|
21
|
+
}),
|
|
18
22
|
parameters: context.trace('parameters', () => toOptionalParametersV3({
|
|
19
23
|
parameters,
|
|
20
24
|
context
|
|
21
|
-
})
|
|
25
|
+
}), {
|
|
26
|
+
checkCycles: true
|
|
27
|
+
}),
|
|
22
28
|
examples: toExamplesV3({
|
|
23
29
|
examples,
|
|
24
30
|
example: undefined,
|
|
25
31
|
exampleKey: 'TEMP',
|
|
26
|
-
context
|
|
32
|
+
context,
|
|
33
|
+
options: {
|
|
34
|
+
checkCycles: true
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
requestBodies: context.trace('requestBodies', () => toRequestBodiesV3({ requestBodies, context }), {
|
|
38
|
+
checkCycles: true
|
|
39
|
+
}),
|
|
40
|
+
headers: context.trace('headers', () => toHeadersV3({ headers, context }), {
|
|
41
|
+
checkCycles: true
|
|
27
42
|
}),
|
|
28
|
-
requestBodies: context.trace('requestBodies', () => toRequestBodiesV3({ requestBodies, context })),
|
|
29
|
-
headers: context.trace('headers', () => toHeadersV3({ headers, context })),
|
|
30
43
|
extensionFields
|
|
31
44
|
};
|
|
32
45
|
return new OasComponents(fields);
|
|
@@ -2,6 +2,7 @@ import type { ParseContext } from '../../context/ParseContext.js';
|
|
|
2
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
3
3
|
import { OasExample } from './Example.js';
|
|
4
4
|
import type { OasRef } from '../ref/Ref.js';
|
|
5
|
+
import type { TraceOptions } from '../../context/StackTrail.js';
|
|
5
6
|
type ToExampleSimpleV3Args = {
|
|
6
7
|
example: unknown;
|
|
7
8
|
};
|
|
@@ -11,8 +12,9 @@ export type ToExamplesV3Args = {
|
|
|
11
12
|
examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> | undefined;
|
|
12
13
|
exampleKey: string;
|
|
13
14
|
context: ParseContext;
|
|
15
|
+
options?: TraceOptions;
|
|
14
16
|
};
|
|
15
|
-
export declare const toExamplesV3: ({ example, examples, exampleKey, context }: ToExamplesV3Args) => Record<string, OasExample | OasRef<"example">> | undefined;
|
|
17
|
+
export declare const toExamplesV3: ({ example, examples, exampleKey, context, options }: ToExamplesV3Args) => Record<string, OasExample | OasRef<"example">> | undefined;
|
|
16
18
|
type ToExampleV3Args = {
|
|
17
19
|
example: OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject;
|
|
18
20
|
context: ParseContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toExamplesV3.d.ts","sourceRoot":"","sources":["../../../src/oas/example/toExamplesV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"toExamplesV3.d.ts","sourceRoot":"","sources":["../../../src/oas/example/toExamplesV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC/D,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,iBAAiB,gBAE3B,qBAAqB,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAQvD,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IACzF,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,YAAY,CAAA;IACrB,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,YAAY,wDAMtB,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,SA0BtE,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAA;IAC5D,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,WAAW,yBAGrB,eAAe,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAejD,CAAA"}
|
|
@@ -10,13 +10,13 @@ export const toExampleSimpleV3 = ({ example }) => {
|
|
|
10
10
|
};
|
|
11
11
|
return new OasExample(fields);
|
|
12
12
|
};
|
|
13
|
-
export const toExamplesV3 = ({ example, examples, exampleKey, context }) => {
|
|
13
|
+
export const toExamplesV3 = ({ example, examples, exampleKey, context, options }) => {
|
|
14
14
|
if (example && examples) {
|
|
15
15
|
context.logger.warn(`Both example and examples are defined for ${exampleKey}`);
|
|
16
16
|
}
|
|
17
17
|
if (example) {
|
|
18
18
|
return {
|
|
19
|
-
[exampleKey]: context.trace('example', () => toExampleSimpleV3({ example }))
|
|
19
|
+
[exampleKey]: context.trace('example', () => toExampleSimpleV3({ example }), options)
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
if (examples) {
|
|
@@ -24,7 +24,7 @@ export const toExamplesV3 = ({ example, examples, exampleKey, context }) => {
|
|
|
24
24
|
return Object.fromEntries(Object.entries(examples).map(([key, value]) => {
|
|
25
25
|
return [key, context.trace(key, () => toExampleV3({ example: value, context }))];
|
|
26
26
|
}));
|
|
27
|
-
});
|
|
27
|
+
}, options);
|
|
28
28
|
}
|
|
29
29
|
return undefined;
|
|
30
30
|
};
|
|
@@ -6,7 +6,7 @@ export type StringFields = {
|
|
|
6
6
|
title?: string;
|
|
7
7
|
description?: string;
|
|
8
8
|
format?: string;
|
|
9
|
-
enums?: string[];
|
|
9
|
+
enums?: (string | null)[];
|
|
10
10
|
maxLength?: number;
|
|
11
11
|
minLength?: number;
|
|
12
12
|
nullable?: boolean;
|
|
@@ -41,7 +41,7 @@ export declare class OasString {
|
|
|
41
41
|
/**
|
|
42
42
|
* An array of allowed values for the string.
|
|
43
43
|
*/
|
|
44
|
-
enums: string[] | undefined;
|
|
44
|
+
enums: (string | null)[] | undefined;
|
|
45
45
|
/**
|
|
46
46
|
* The maximum length of the string.
|
|
47
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../../../src/oas/string/String.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../../../src/oas/string/String.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAA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CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,SAAS;IAIpB,WAAW,IAAI,SAAS;IAKxB,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC,oBAAoB;CAa5E"}
|
|
@@ -3,6 +3,18 @@ export declare const stringFormat: z.ZodEnum<["date-time", "time", "date", "dura
|
|
|
3
3
|
export declare const oasStringData: z.ZodType<OasStringData>;
|
|
4
4
|
export type StringFormat = 'date-time' | 'time' | 'date' | 'duration' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'uuid' | 'uri' | 'regex' | 'password' | 'byte' | 'binary';
|
|
5
5
|
export type OasStringData = {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
default?: string;
|
|
9
|
+
type: 'string';
|
|
10
|
+
maxLength?: number;
|
|
11
|
+
minLength?: number;
|
|
12
|
+
pattern?: string;
|
|
13
|
+
enum?: (string | null)[];
|
|
14
|
+
format?: string;
|
|
15
|
+
nullable: true;
|
|
16
|
+
example?: string;
|
|
17
|
+
} | {
|
|
6
18
|
title?: string;
|
|
7
19
|
description?: string;
|
|
8
20
|
default?: string;
|
|
@@ -12,7 +24,7 @@ export type OasStringData = {
|
|
|
12
24
|
pattern?: string;
|
|
13
25
|
enum?: string[];
|
|
14
26
|
format?: string;
|
|
15
|
-
nullable?:
|
|
27
|
+
nullable?: false;
|
|
16
28
|
example?: string;
|
|
17
29
|
};
|
|
18
30
|
//# sourceMappingURL=string-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-types.d.ts","sourceRoot":"","sources":["../../../src/oas/string/string-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAErC,eAAO,MAAM,YAAY,iJAevB,CAAA;AAEF,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"string-types.d.ts","sourceRoot":"","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;CACjB,CAAA"}
|
|
@@ -15,18 +15,35 @@ export const stringFormat = z.enum([
|
|
|
15
15
|
'byte',
|
|
16
16
|
'binary'
|
|
17
17
|
]);
|
|
18
|
-
export const oasStringData = z
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
export const oasStringData = z.union([
|
|
19
|
+
z
|
|
20
|
+
.object({
|
|
21
|
+
type: z.literal('string'),
|
|
22
|
+
title: z.string().optional(),
|
|
23
|
+
description: z.string().optional(),
|
|
24
|
+
default: z.string().optional(),
|
|
25
|
+
maxLength: z.number().optional(),
|
|
26
|
+
minLength: z.number().optional(),
|
|
27
|
+
pattern: z.string().optional(),
|
|
28
|
+
enum: z.array(z.union([z.string(), z.null()])).optional(),
|
|
29
|
+
format: z.string().optional(),
|
|
30
|
+
nullable: z.literal(true),
|
|
31
|
+
example: z.string().optional().catch(undefined)
|
|
32
|
+
})
|
|
33
|
+
.passthrough(),
|
|
34
|
+
z
|
|
35
|
+
.object({
|
|
36
|
+
type: z.literal('string'),
|
|
37
|
+
title: z.string().optional(),
|
|
38
|
+
description: z.string().optional(),
|
|
39
|
+
default: z.string().optional(),
|
|
40
|
+
maxLength: z.number().optional(),
|
|
41
|
+
minLength: z.number().optional(),
|
|
42
|
+
pattern: z.string().optional(),
|
|
43
|
+
enum: z.array(z.string()).optional(),
|
|
44
|
+
format: z.string().optional(),
|
|
45
|
+
nullable: z.literal(false).optional(),
|
|
46
|
+
example: z.string().optional().catch(undefined)
|
|
47
|
+
})
|
|
48
|
+
.passthrough()
|
|
49
|
+
]);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import "../_dnt.polyfills.js";
|
|
|
2
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
3
3
|
import { OasDocument } from '../oas/document/Document.js';
|
|
4
4
|
import type * as log from '../deps/jsr.io/@std/log/0.224.8/mod.js';
|
|
5
|
-
import type { StackTrail } from './StackTrail.js';
|
|
5
|
+
import type { StackTrail, TraceOptions } from './StackTrail.js';
|
|
6
6
|
type ConstructorArgs = {
|
|
7
7
|
documentObject: OpenAPIV3.Document;
|
|
8
8
|
logger: log.Logger;
|
|
@@ -18,7 +18,7 @@ export declare class ParseContext {
|
|
|
18
18
|
stackTrail: StackTrail;
|
|
19
19
|
constructor({ documentObject, logger, stackTrail }: ConstructorArgs);
|
|
20
20
|
parse(): OasDocument;
|
|
21
|
-
trace<T>(token: string | string[], fn: () => T): T;
|
|
21
|
+
trace<T>(token: string | string[], fn: () => T, options?: TraceOptions): T;
|
|
22
22
|
logSkippedFields(skipped: Record<string, unknown>): void;
|
|
23
23
|
}
|
|
24
24
|
export declare const parseSchema: (schema: string) => OpenAPIV3.Document<{}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,wCAAwC,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG/D,KAAK,eAAe,GAAG;IACrB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,qBAAa,YAAY;IACvB,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAA;IAClB,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;gBAEV,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,eAAe;IAOnE,KAAK;IASL,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,CAAC;IAI1E,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAUlD;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,2BAMzC,CAAA"}
|
|
@@ -44,8 +44,8 @@ class ParseContext {
|
|
|
44
44
|
});
|
|
45
45
|
return this.oasDocument;
|
|
46
46
|
}
|
|
47
|
-
trace(token, fn) {
|
|
48
|
-
return (0, tracer_js_1.tracer)(this.stackTrail, token, fn);
|
|
47
|
+
trace(token, fn, options) {
|
|
48
|
+
return (0, tracer_js_1.tracer)(this.stackTrail, token, fn, options);
|
|
49
49
|
}
|
|
50
50
|
logSkippedFields(skipped) {
|
|
51
51
|
Object.entries(skipped).forEach(([key, value]) => {
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import "../_dnt.polyfills.js";
|
|
2
|
+
export type TraceOptions = {
|
|
3
|
+
checkCycles?: boolean;
|
|
4
|
+
};
|
|
2
5
|
export declare class StackTrail {
|
|
3
6
|
#private;
|
|
4
7
|
constructor(stack?: (string | number)[]);
|
|
5
8
|
clone(): StackTrail;
|
|
6
9
|
slice(start: number, end?: number): StackTrail;
|
|
7
10
|
get stackTrail(): (string | number)[];
|
|
8
|
-
append(frame: string | string[]): StackTrail;
|
|
11
|
+
append(frame: string | string[], options?: TraceOptions): StackTrail;
|
|
12
|
+
checkCycles(frame: string | string[]): boolean;
|
|
13
|
+
checkCyclesArray(frames: string[]): boolean;
|
|
9
14
|
getParentOf(frame: string): string | undefined;
|
|
10
15
|
remove(frame: string | string[]): StackTrail;
|
|
11
16
|
static join(...stacks: (StackTrail | string)[]): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StackTrail.d.ts","sourceRoot":"","sources":["../../src/context/StackTrail.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,qBAAa,UAAU;;gBAGT,KAAK,GAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO;IAI3C,KAAK;IAIL,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAIjC,IAAI,UAAU,wBAEb;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU;
|
|
1
|
+
{"version":3,"file":"StackTrail.d.ts","sourceRoot":"","sources":["../../src/context/StackTrail.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,qBAAa,UAAU;;gBAGT,KAAK,GAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAO;IAI3C,KAAK;IAIL,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM;IAIjC,IAAI,UAAU,wBAEb;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,UAAU;IAoBpE,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO;IAQ9C,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO;IAkB3C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAW9C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU;IAsB5C,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC,UAAU,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM;IAIvD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAYvC,QAAQ;CAOT"}
|
|
@@ -28,7 +28,10 @@ class StackTrail {
|
|
|
28
28
|
get stackTrail() {
|
|
29
29
|
return __classPrivateFieldGet(this, _StackTrail_stack, "f");
|
|
30
30
|
}
|
|
31
|
-
append(frame) {
|
|
31
|
+
append(frame, options) {
|
|
32
|
+
if (options?.checkCycles && this.checkCycles(frame)) {
|
|
33
|
+
throw new Error(`Cycle detected in stack trail: ${this}`);
|
|
34
|
+
}
|
|
32
35
|
if (typeof frame === 'string') {
|
|
33
36
|
__classPrivateFieldGet(this, _StackTrail_stack, "f").push(frame);
|
|
34
37
|
return this;
|
|
@@ -39,6 +42,25 @@ class StackTrail {
|
|
|
39
42
|
}
|
|
40
43
|
throw new Error(`Unexpected stack frame: ${frame}`);
|
|
41
44
|
}
|
|
45
|
+
checkCycles(frame) {
|
|
46
|
+
if (typeof frame === 'string') {
|
|
47
|
+
return __classPrivateFieldGet(this, _StackTrail_stack, "f").includes(frame);
|
|
48
|
+
}
|
|
49
|
+
return this.checkCyclesArray(frame);
|
|
50
|
+
}
|
|
51
|
+
checkCyclesArray(frames) {
|
|
52
|
+
if (frames.length === 0) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const lastFrame = frames[frames.length - 1];
|
|
56
|
+
const indexOfLastFrame = __classPrivateFieldGet(this, _StackTrail_stack, "f").indexOf(lastFrame);
|
|
57
|
+
if (indexOfLastFrame === -1) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return frames.toReversed().every((frame, index) => {
|
|
61
|
+
return frame === __classPrivateFieldGet(this, _StackTrail_stack, "f")[indexOfLastFrame - index];
|
|
62
|
+
});
|
|
63
|
+
}
|
|
42
64
|
getParentOf(frame) {
|
|
43
65
|
const lastItemIndex = this.stackTrail.length - 1;
|
|
44
66
|
if (this.stackTrail?.[lastItemIndex] === frame &&
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { StackTrail } from '../context/StackTrail.js';
|
|
2
|
-
export declare const tracer: <T>(stackTrail: StackTrail, token: string | string[], fn: () => T) => T;
|
|
1
|
+
import type { StackTrail, TraceOptions } from '../context/StackTrail.js';
|
|
2
|
+
export declare const tracer: <T>(stackTrail: StackTrail, token: string | string[], fn: () => T, options?: TraceOptions) => T;
|
|
3
3
|
//# sourceMappingURL=tracer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/helpers/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/helpers/tracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAExE,eAAO,MAAM,MAAM,GAAI,CAAC,cACV,UAAU,SACf,MAAM,GAAG,MAAM,EAAE,MACpB,MAAM,CAAC,YACD,YAAY,MASvB,CAAA"}
|
package/script/helpers/tracer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tracer = void 0;
|
|
4
|
-
const tracer = (stackTrail, token, fn) => {
|
|
5
|
-
stackTrail.append(token);
|
|
4
|
+
const tracer = (stackTrail, token, fn, options) => {
|
|
5
|
+
stackTrail.append(token, options);
|
|
6
6
|
const result = fn();
|
|
7
7
|
stackTrail.remove(token);
|
|
8
8
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toComponentsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/components/toComponentsV3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"toComponentsV3.d.ts","sourceRoot":"","sources":["../../../src/oas/components/toComponentsV3.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAI/C,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,SAAS,CAAC,gBAAgB,GAAG,SAAS,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,cAAc,4BAGxB,kBAAkB,KAAG,aAAa,GAAG,SAsDvC,CAAA"}
|
|
@@ -16,20 +16,33 @@ const toComponentsV3 = ({ components, context }) => {
|
|
|
16
16
|
const { schemas, responses, parameters, examples, requestBodies, headers, ...skipped } = components;
|
|
17
17
|
const extensionFields = (0, toSpecificationExtensionsV3_js_1.toSpecificationExtensionsV3)({ skipped, context });
|
|
18
18
|
const fields = {
|
|
19
|
-
schemas: context.trace('schemas', () => (0, toSchemasV3_js_1.toOptionalSchemasV3)({ schemas, context })
|
|
20
|
-
|
|
19
|
+
schemas: context.trace('schemas', () => (0, toSchemasV3_js_1.toOptionalSchemasV3)({ schemas, context }), {
|
|
20
|
+
checkCycles: true
|
|
21
|
+
}),
|
|
22
|
+
responses: context.trace('responses', () => (0, toResponseV3_js_1.toOptionalResponsesV3)({ responses, context }), {
|
|
23
|
+
checkCycles: true
|
|
24
|
+
}),
|
|
21
25
|
parameters: context.trace('parameters', () => (0, toParameterV3_js_1.toOptionalParametersV3)({
|
|
22
26
|
parameters,
|
|
23
27
|
context
|
|
24
|
-
})
|
|
28
|
+
}), {
|
|
29
|
+
checkCycles: true
|
|
30
|
+
}),
|
|
25
31
|
examples: (0, toExamplesV3_js_1.toExamplesV3)({
|
|
26
32
|
examples,
|
|
27
33
|
example: undefined,
|
|
28
34
|
exampleKey: 'TEMP',
|
|
29
|
-
context
|
|
35
|
+
context,
|
|
36
|
+
options: {
|
|
37
|
+
checkCycles: true
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
requestBodies: context.trace('requestBodies', () => (0, toRequestBodiesV3_js_1.toRequestBodiesV3)({ requestBodies, context }), {
|
|
41
|
+
checkCycles: true
|
|
42
|
+
}),
|
|
43
|
+
headers: context.trace('headers', () => (0, toHeadersV3_js_1.toHeadersV3)({ headers, context }), {
|
|
44
|
+
checkCycles: true
|
|
30
45
|
}),
|
|
31
|
-
requestBodies: context.trace('requestBodies', () => (0, toRequestBodiesV3_js_1.toRequestBodiesV3)({ requestBodies, context })),
|
|
32
|
-
headers: context.trace('headers', () => (0, toHeadersV3_js_1.toHeadersV3)({ headers, context })),
|
|
33
46
|
extensionFields
|
|
34
47
|
};
|
|
35
48
|
return new Components_js_1.OasComponents(fields);
|
|
@@ -2,6 +2,7 @@ import type { ParseContext } from '../../context/ParseContext.js';
|
|
|
2
2
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
3
3
|
import { OasExample } from './Example.js';
|
|
4
4
|
import type { OasRef } from '../ref/Ref.js';
|
|
5
|
+
import type { TraceOptions } from '../../context/StackTrail.js';
|
|
5
6
|
type ToExampleSimpleV3Args = {
|
|
6
7
|
example: unknown;
|
|
7
8
|
};
|
|
@@ -11,8 +12,9 @@ export type ToExamplesV3Args = {
|
|
|
11
12
|
examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> | undefined;
|
|
12
13
|
exampleKey: string;
|
|
13
14
|
context: ParseContext;
|
|
15
|
+
options?: TraceOptions;
|
|
14
16
|
};
|
|
15
|
-
export declare const toExamplesV3: ({ example, examples, exampleKey, context }: ToExamplesV3Args) => Record<string, OasExample | OasRef<"example">> | undefined;
|
|
17
|
+
export declare const toExamplesV3: ({ example, examples, exampleKey, context, options }: ToExamplesV3Args) => Record<string, OasExample | OasRef<"example">> | undefined;
|
|
16
18
|
type ToExampleV3Args = {
|
|
17
19
|
example: OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject;
|
|
18
20
|
context: ParseContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toExamplesV3.d.ts","sourceRoot":"","sources":["../../../src/oas/example/toExamplesV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"toExamplesV3.d.ts","sourceRoot":"","sources":["../../../src/oas/example/toExamplesV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC/D,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,iBAAiB,gBAE3B,qBAAqB,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAQvD,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IACzF,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,YAAY,CAAA;IACrB,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,YAAY,wDAMtB,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,SA0BtE,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAA;IAC5D,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,WAAW,yBAGrB,eAAe,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAejD,CAAA"}
|
|
@@ -14,13 +14,13 @@ const toExampleSimpleV3 = ({ example }) => {
|
|
|
14
14
|
return new Example_js_1.OasExample(fields);
|
|
15
15
|
};
|
|
16
16
|
exports.toExampleSimpleV3 = toExampleSimpleV3;
|
|
17
|
-
const toExamplesV3 = ({ example, examples, exampleKey, context }) => {
|
|
17
|
+
const toExamplesV3 = ({ example, examples, exampleKey, context, options }) => {
|
|
18
18
|
if (example && examples) {
|
|
19
19
|
context.logger.warn(`Both example and examples are defined for ${exampleKey}`);
|
|
20
20
|
}
|
|
21
21
|
if (example) {
|
|
22
22
|
return {
|
|
23
|
-
[exampleKey]: context.trace('example', () => (0, exports.toExampleSimpleV3)({ example }))
|
|
23
|
+
[exampleKey]: context.trace('example', () => (0, exports.toExampleSimpleV3)({ example }), options)
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
if (examples) {
|
|
@@ -28,7 +28,7 @@ const toExamplesV3 = ({ example, examples, exampleKey, context }) => {
|
|
|
28
28
|
return Object.fromEntries(Object.entries(examples).map(([key, value]) => {
|
|
29
29
|
return [key, context.trace(key, () => (0, exports.toExampleV3)({ example: value, context }))];
|
|
30
30
|
}));
|
|
31
|
-
});
|
|
31
|
+
}, options);
|
|
32
32
|
}
|
|
33
33
|
return undefined;
|
|
34
34
|
};
|
|
@@ -6,7 +6,7 @@ export type StringFields = {
|
|
|
6
6
|
title?: string;
|
|
7
7
|
description?: string;
|
|
8
8
|
format?: string;
|
|
9
|
-
enums?: string[];
|
|
9
|
+
enums?: (string | null)[];
|
|
10
10
|
maxLength?: number;
|
|
11
11
|
minLength?: number;
|
|
12
12
|
nullable?: boolean;
|
|
@@ -41,7 +41,7 @@ export declare class OasString {
|
|
|
41
41
|
/**
|
|
42
42
|
* An array of allowed values for the string.
|
|
43
43
|
*/
|
|
44
|
-
enums: string[] | undefined;
|
|
44
|
+
enums: (string | null)[] | undefined;
|
|
45
45
|
/**
|
|
46
46
|
* The maximum length of the string.
|
|
47
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"String.d.ts","sourceRoot":"","sources":["../../../src/oas/string/String.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAq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K,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,CAAA;IACpC;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B;;OAEG;IACH,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IACpD,gCAAgC;IAChC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;gBAEf,MAAM,EAAE,YAAY;IAgBhC,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,SAAS;IAIpB,WAAW,IAAI,SAAS;IAKxB,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC,oBAAoB;CAa5E"}
|
|
@@ -3,6 +3,18 @@ export declare const stringFormat: z.ZodEnum<["date-time", "time", "date", "dura
|
|
|
3
3
|
export declare const oasStringData: z.ZodType<OasStringData>;
|
|
4
4
|
export type StringFormat = 'date-time' | 'time' | 'date' | 'duration' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'uuid' | 'uri' | 'regex' | 'password' | 'byte' | 'binary';
|
|
5
5
|
export type OasStringData = {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
default?: string;
|
|
9
|
+
type: 'string';
|
|
10
|
+
maxLength?: number;
|
|
11
|
+
minLength?: number;
|
|
12
|
+
pattern?: string;
|
|
13
|
+
enum?: (string | null)[];
|
|
14
|
+
format?: string;
|
|
15
|
+
nullable: true;
|
|
16
|
+
example?: string;
|
|
17
|
+
} | {
|
|
6
18
|
title?: string;
|
|
7
19
|
description?: string;
|
|
8
20
|
default?: string;
|
|
@@ -12,7 +24,7 @@ export type OasStringData = {
|
|
|
12
24
|
pattern?: string;
|
|
13
25
|
enum?: string[];
|
|
14
26
|
format?: string;
|
|
15
|
-
nullable?:
|
|
27
|
+
nullable?: false;
|
|
16
28
|
example?: string;
|
|
17
29
|
};
|
|
18
30
|
//# sourceMappingURL=string-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-types.d.ts","sourceRoot":"","sources":["../../../src/oas/string/string-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAErC,eAAO,MAAM,YAAY,iJAevB,CAAA;AAEF,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"string-types.d.ts","sourceRoot":"","sources":["../../../src/oas/string/string-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAErC,eAAO,MAAM,YAAY,iJAevB,CAAA;AAEF,eAAO,MAAM,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CA+BjD,CAAA;AAEF,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,MAAM,GACN,MAAM,GACN,UAAU,GACV,OAAO,GACP,UAAU,GACV,MAAM,GACN,MAAM,GACN,MAAM,GACN,KAAK,GACL,OAAO,GACP,UAAU,GACV,MAAM,GACN,QAAQ,CAAA;AAEZ,MAAM,MAAM,aAAa,GACrB;IACE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,QAAQ,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,GACD;IACE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,QAAQ,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA"}
|
|
@@ -18,18 +18,35 @@ exports.stringFormat = zod_openapi_1.z.enum([
|
|
|
18
18
|
'byte',
|
|
19
19
|
'binary'
|
|
20
20
|
]);
|
|
21
|
-
exports.oasStringData = zod_openapi_1.z
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
exports.oasStringData = zod_openapi_1.z.union([
|
|
22
|
+
zod_openapi_1.z
|
|
23
|
+
.object({
|
|
24
|
+
type: zod_openapi_1.z.literal('string'),
|
|
25
|
+
title: zod_openapi_1.z.string().optional(),
|
|
26
|
+
description: zod_openapi_1.z.string().optional(),
|
|
27
|
+
default: zod_openapi_1.z.string().optional(),
|
|
28
|
+
maxLength: zod_openapi_1.z.number().optional(),
|
|
29
|
+
minLength: zod_openapi_1.z.number().optional(),
|
|
30
|
+
pattern: zod_openapi_1.z.string().optional(),
|
|
31
|
+
enum: zod_openapi_1.z.array(zod_openapi_1.z.union([zod_openapi_1.z.string(), zod_openapi_1.z.null()])).optional(),
|
|
32
|
+
format: zod_openapi_1.z.string().optional(),
|
|
33
|
+
nullable: zod_openapi_1.z.literal(true),
|
|
34
|
+
example: zod_openapi_1.z.string().optional().catch(undefined)
|
|
35
|
+
})
|
|
36
|
+
.passthrough(),
|
|
37
|
+
zod_openapi_1.z
|
|
38
|
+
.object({
|
|
39
|
+
type: zod_openapi_1.z.literal('string'),
|
|
40
|
+
title: zod_openapi_1.z.string().optional(),
|
|
41
|
+
description: zod_openapi_1.z.string().optional(),
|
|
42
|
+
default: zod_openapi_1.z.string().optional(),
|
|
43
|
+
maxLength: zod_openapi_1.z.number().optional(),
|
|
44
|
+
minLength: zod_openapi_1.z.number().optional(),
|
|
45
|
+
pattern: zod_openapi_1.z.string().optional(),
|
|
46
|
+
enum: zod_openapi_1.z.array(zod_openapi_1.z.string()).optional(),
|
|
47
|
+
format: zod_openapi_1.z.string().optional(),
|
|
48
|
+
nullable: zod_openapi_1.z.literal(false).optional(),
|
|
49
|
+
example: zod_openapi_1.z.string().optional().catch(undefined)
|
|
50
|
+
})
|
|
51
|
+
.passthrough()
|
|
52
|
+
]);
|