@skmtc/core 0.0.796 → 0.0.798
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/app/validate.d.ts +32 -0
- package/esm/app/validate.d.ts.map +1 -1
- package/esm/app/validate.js +32 -0
- package/esm/context/CoreContext.d.ts +147 -2
- package/esm/context/CoreContext.d.ts.map +1 -1
- package/esm/context/CoreContext.js +87 -0
- package/esm/context/GenerateContext.d.ts +180 -0
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +25 -0
- package/esm/context/ParseContext.d.ts +6 -0
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +6 -0
- package/esm/dsl/constants.d.ts +28 -0
- package/esm/dsl/constants.d.ts.map +1 -1
- package/esm/dsl/constants.js +28 -0
- package/esm/oas/_helpers/parseDefault.d.ts +148 -0
- package/esm/oas/_helpers/parseDefault.d.ts.map +1 -1
- package/esm/oas/_helpers/parseDefault.js +128 -0
- package/esm/oas/_helpers/parseEnum.d.ts +124 -0
- package/esm/oas/_helpers/parseEnum.d.ts.map +1 -1
- package/esm/oas/_helpers/parseEnum.js +104 -0
- package/esm/oas/_helpers/parseExample.d.ts +107 -0
- package/esm/oas/_helpers/parseExample.d.ts.map +1 -1
- package/esm/oas/_helpers/parseExample.js +87 -0
- package/esm/oas/_helpers/parseFormat.d.ts +154 -0
- package/esm/oas/_helpers/parseFormat.d.ts.map +1 -1
- package/esm/oas/_helpers/parseFormat.js +138 -0
- package/esm/oas/_helpers/parseNullable.d.ts +127 -0
- package/esm/oas/_helpers/parseNullable.d.ts.map +1 -1
- package/esm/oas/_helpers/parseNullable.js +113 -0
- package/esm/oas/example/toExamplesV3.d.ts +39 -0
- package/esm/oas/example/toExamplesV3.d.ts.map +1 -1
- package/esm/oas/example/toExamplesV3.js +29 -0
- package/esm/oas/object/Object.d.ts +6 -0
- package/esm/oas/object/Object.d.ts.map +1 -1
- package/esm/oas/object/Object.js +6 -0
- package/esm/oas/operation/Operation.d.ts +34 -0
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +14 -0
- package/esm/oas/parameter/Parameter.d.ts +3 -0
- package/esm/oas/parameter/Parameter.d.ts.map +1 -1
- package/esm/oas/parameter/Parameter.js +3 -0
- package/esm/oas/ref/ref-types.d.ts +42 -0
- package/esm/oas/ref/ref-types.d.ts.map +1 -1
- package/esm/oas/ref/ref-types.js +9 -0
- package/esm/oas/securitySchemes/security-scheme-types.d.ts +63 -0
- package/esm/oas/securitySchemes/security-scheme-types.d.ts.map +1 -1
- package/esm/oas/securitySchemes/security-scheme-types.js +15 -0
- package/esm/run/toV3JsonDocument.d.ts +90 -0
- package/esm/run/toV3JsonDocument.d.ts.map +1 -1
- package/esm/run/toV3JsonDocument.js +84 -0
- package/esm/types/Results.d.ts +32 -0
- package/esm/types/Results.d.ts.map +1 -1
- package/esm/types/Results.js +12 -0
- package/package.json +1 -1
- package/script/app/validate.d.ts +32 -0
- package/script/app/validate.d.ts.map +1 -1
- package/script/app/validate.js +32 -0
- package/script/context/CoreContext.d.ts +147 -2
- package/script/context/CoreContext.d.ts.map +1 -1
- package/script/context/CoreContext.js +87 -0
- package/script/context/GenerateContext.d.ts +180 -0
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +25 -0
- package/script/context/ParseContext.d.ts +6 -0
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +6 -0
- package/script/dsl/constants.d.ts +28 -0
- package/script/dsl/constants.d.ts.map +1 -1
- package/script/dsl/constants.js +28 -0
- package/script/oas/_helpers/parseDefault.d.ts +148 -0
- package/script/oas/_helpers/parseDefault.d.ts.map +1 -1
- package/script/oas/_helpers/parseDefault.js +128 -0
- package/script/oas/_helpers/parseEnum.d.ts +124 -0
- package/script/oas/_helpers/parseEnum.d.ts.map +1 -1
- package/script/oas/_helpers/parseEnum.js +104 -0
- package/script/oas/_helpers/parseExample.d.ts +107 -0
- package/script/oas/_helpers/parseExample.d.ts.map +1 -1
- package/script/oas/_helpers/parseExample.js +87 -0
- package/script/oas/_helpers/parseFormat.d.ts +154 -0
- package/script/oas/_helpers/parseFormat.d.ts.map +1 -1
- package/script/oas/_helpers/parseFormat.js +138 -0
- package/script/oas/_helpers/parseNullable.d.ts +127 -0
- package/script/oas/_helpers/parseNullable.d.ts.map +1 -1
- package/script/oas/_helpers/parseNullable.js +113 -0
- package/script/oas/example/toExamplesV3.d.ts +39 -0
- package/script/oas/example/toExamplesV3.d.ts.map +1 -1
- package/script/oas/example/toExamplesV3.js +29 -0
- package/script/oas/object/Object.d.ts +6 -0
- package/script/oas/object/Object.d.ts.map +1 -1
- package/script/oas/object/Object.js +6 -0
- package/script/oas/operation/Operation.d.ts +34 -0
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +14 -0
- package/script/oas/parameter/Parameter.d.ts +3 -0
- package/script/oas/parameter/Parameter.d.ts.map +1 -1
- package/script/oas/parameter/Parameter.js +3 -0
- package/script/oas/ref/ref-types.d.ts +42 -0
- package/script/oas/ref/ref-types.d.ts.map +1 -1
- package/script/oas/ref/ref-types.js +9 -0
- package/script/oas/securitySchemes/security-scheme-types.d.ts +63 -0
- package/script/oas/securitySchemes/security-scheme-types.d.ts.map +1 -1
- package/script/oas/securitySchemes/security-scheme-types.js +15 -0
- package/script/run/toV3JsonDocument.d.ts +90 -0
- package/script/run/toV3JsonDocument.d.ts.map +1 -1
- package/script/run/toV3JsonDocument.js +84 -0
- package/script/types/Results.d.ts +32 -0
- package/script/types/Results.d.ts.map +1 -1
- package/script/types/Results.js +12 -0
|
@@ -1,4 +1,142 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
/**
|
|
3
|
+
* Parses and validates OpenAPI schema format values with type safety.
|
|
4
|
+
*
|
|
5
|
+
* This function extracts and validates format specifiers from OpenAPI schema objects,
|
|
6
|
+
* ensuring they conform to expected format types for the given schema. Invalid format
|
|
7
|
+
* values are removed and logged as warnings through the parse context.
|
|
8
|
+
*
|
|
9
|
+
* The format property provides additional semantic information about the expected
|
|
10
|
+
* structure of string values (like 'email', 'date-time', 'uuid', etc.) and numeric
|
|
11
|
+
* precision (like 'float', 'double' for numbers, 'int32', 'int64' for integers).
|
|
12
|
+
*
|
|
13
|
+
* @template T - The expected type of the format value (usually string)
|
|
14
|
+
* @template Value - The OpenAPI schema object type
|
|
15
|
+
*
|
|
16
|
+
* @param args - Parsing configuration
|
|
17
|
+
* @returns Parsed format data with the validated format and cleaned schema
|
|
18
|
+
*
|
|
19
|
+
* @example String format parsing
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { parseFormat } from '@skmtc/core/oas/_helpers';
|
|
22
|
+
* import * as v from 'valibot';
|
|
23
|
+
*
|
|
24
|
+
* const result = parseFormat({
|
|
25
|
+
* value: {
|
|
26
|
+
* type: 'string',
|
|
27
|
+
* format: 'email',
|
|
28
|
+
* maxLength: 100
|
|
29
|
+
* },
|
|
30
|
+
* valibotSchema: v.string(),
|
|
31
|
+
* context: parseContext
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* console.log(result.format); // 'email'
|
|
35
|
+
* console.log(result.value); // { type: 'string', maxLength: 100 }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example Date-time format
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const result = parseFormat({
|
|
41
|
+
* value: {
|
|
42
|
+
* type: 'string',
|
|
43
|
+
* format: 'date-time',
|
|
44
|
+
* description: 'ISO 8601 timestamp'
|
|
45
|
+
* },
|
|
46
|
+
* valibotSchema: v.string(),
|
|
47
|
+
* context: parseContext
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* console.log(result.format); // 'date-time'
|
|
51
|
+
* // Can be used to generate Date objects in TypeScript
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @example Number precision formats
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const result = parseFormat({
|
|
57
|
+
* value: {
|
|
58
|
+
* type: 'number',
|
|
59
|
+
* format: 'float',
|
|
60
|
+
* minimum: 0
|
|
61
|
+
* },
|
|
62
|
+
* valibotSchema: v.string(), // Format is always a string
|
|
63
|
+
* context: parseContext
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* console.log(result.format); // 'float'
|
|
67
|
+
* // Indicates single-precision floating-point
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example Integer format specifiers
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const result = parseFormat({
|
|
73
|
+
* value: {
|
|
74
|
+
* type: 'integer',
|
|
75
|
+
* format: 'int64',
|
|
76
|
+
* description: 'Large integer ID'
|
|
77
|
+
* },
|
|
78
|
+
* valibotSchema: v.string(),
|
|
79
|
+
* context: parseContext
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* console.log(result.format); // 'int64'
|
|
83
|
+
* // Indicates 64-bit signed integer
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example Invalid format handling
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const result = parseFormat({
|
|
89
|
+
* value: {
|
|
90
|
+
* type: 'string',
|
|
91
|
+
* format: 123, // Invalid - should be string
|
|
92
|
+
* pattern: '^[a-z]+$'
|
|
93
|
+
* } as any,
|
|
94
|
+
* valibotSchema: v.string(),
|
|
95
|
+
* context: parseContext
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* console.log(result.format); // undefined (invalid format removed)
|
|
99
|
+
* console.log(result.value); // { type: 'string', pattern: '^[a-z]+$' }
|
|
100
|
+
* // Context will log a warning about the invalid format
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example Missing format (undefined)
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const result = parseFormat({
|
|
106
|
+
* value: {
|
|
107
|
+
* type: 'string',
|
|
108
|
+
* minLength: 1,
|
|
109
|
+
* maxLength: 50
|
|
110
|
+
* },
|
|
111
|
+
* valibotSchema: v.string(),
|
|
112
|
+
* context: parseContext
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* console.log(result.format); // undefined (no format specified)
|
|
116
|
+
* console.log(result.value); // { type: 'string', minLength: 1, maxLength: 50 }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example Common string formats
|
|
120
|
+
* ```typescript
|
|
121
|
+
* // Standard OpenAPI string formats:
|
|
122
|
+
* // - 'date': full-date as defined by RFC3339
|
|
123
|
+
* // - 'date-time': date-time as defined by RFC3339
|
|
124
|
+
* // - 'time': time as defined by RFC3339
|
|
125
|
+
* // - 'email': email address as defined by RFC5322
|
|
126
|
+
* // - 'uri': URI as defined by RFC3986
|
|
127
|
+
* // - 'uuid': UUID as defined by RFC4122
|
|
128
|
+
* // - 'binary': binary data (base64 encoded)
|
|
129
|
+
* // - 'byte': base64 encoded characters
|
|
130
|
+
* // - 'password': hint for UI to obscure input
|
|
131
|
+
*
|
|
132
|
+
* const emailFormat = parseFormat({
|
|
133
|
+
* value: { type: 'string', format: 'email' },
|
|
134
|
+
* valibotSchema: v.string(),
|
|
135
|
+
* context
|
|
136
|
+
* });
|
|
137
|
+
* // Can generate validation: v.pipe(v.string(), v.email())
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
2
140
|
export const parseFormat = ({ value, valibotSchema, context }) => {
|
|
3
141
|
const { format, ...rest } = value;
|
|
4
142
|
const parsedFormat = context.provisionalParse({
|
|
@@ -1,12 +1,139 @@
|
|
|
1
1
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
2
2
|
import type { ParseContext } from '../../context/ParseContext.js';
|
|
3
|
+
/**
|
|
4
|
+
* Arguments for parsing the nullable property from OpenAPI schemas.
|
|
5
|
+
*
|
|
6
|
+
* @template Value - The OpenAPI schema object type
|
|
7
|
+
*/
|
|
3
8
|
export type ParseNullableArgs<Value extends OpenAPIV3.SchemaObject> = {
|
|
9
|
+
/** The OpenAPI schema object containing the nullable property */
|
|
4
10
|
value: Value;
|
|
11
|
+
/** Parse context for error handling */
|
|
5
12
|
context: ParseContext;
|
|
6
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Return type for parsed nullable data.
|
|
16
|
+
*
|
|
17
|
+
* @template Value - The OpenAPI schema object type
|
|
18
|
+
*/
|
|
7
19
|
export type ParseNullableReturn<Value extends OpenAPIV3.SchemaObject> = {
|
|
20
|
+
/** The validated nullable flag (true, false, or undefined) */
|
|
8
21
|
nullable: boolean | undefined;
|
|
22
|
+
/** The schema object without the nullable property */
|
|
9
23
|
value: Omit<Value, 'nullable'>;
|
|
10
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Parses and validates the nullable property from OpenAPI schema objects.
|
|
27
|
+
*
|
|
28
|
+
* This function extracts and validates the `nullable` property from OpenAPI
|
|
29
|
+
* schema objects, ensuring it's a valid boolean value. Invalid nullable values
|
|
30
|
+
* are removed and logged as warnings through the parse context.
|
|
31
|
+
*
|
|
32
|
+
* The nullable property determines whether a schema value can be null in addition
|
|
33
|
+
* to its primary type, which affects type generation and validation logic.
|
|
34
|
+
*
|
|
35
|
+
* @template Value - The OpenAPI schema object type
|
|
36
|
+
*
|
|
37
|
+
* @param args - Parsing configuration
|
|
38
|
+
* @returns Parsed nullable data with the validated flag and cleaned schema
|
|
39
|
+
*
|
|
40
|
+
* @example Valid nullable property
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { parseNullable } from '@skmtc/core/oas/_helpers';
|
|
43
|
+
*
|
|
44
|
+
* const result = parseNullable({
|
|
45
|
+
* value: {
|
|
46
|
+
* type: 'string',
|
|
47
|
+
* nullable: true,
|
|
48
|
+
* description: 'An optional string that can be null'
|
|
49
|
+
* },
|
|
50
|
+
* context: parseContext
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* console.log(result.nullable); // true
|
|
54
|
+
* console.log(result.value); // { type: 'string', description: 'An optional string that can be null' }
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @example Explicitly non-nullable
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const result = parseNullable({
|
|
60
|
+
* value: {
|
|
61
|
+
* type: 'number',
|
|
62
|
+
* nullable: false,
|
|
63
|
+
* minimum: 0
|
|
64
|
+
* },
|
|
65
|
+
* context: parseContext
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* console.log(result.nullable); // false
|
|
69
|
+
* console.log(result.value); // { type: 'number', minimum: 0 }
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example Missing nullable property (undefined)
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const result = parseNullable({
|
|
75
|
+
* value: {
|
|
76
|
+
* type: 'string',
|
|
77
|
+
* format: 'email'
|
|
78
|
+
* },
|
|
79
|
+
* context: parseContext
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* console.log(result.nullable); // undefined (property not present)
|
|
83
|
+
* console.log(result.value); // { type: 'string', format: 'email' }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example Invalid nullable value
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const result = parseNullable({
|
|
89
|
+
* value: {
|
|
90
|
+
* type: 'boolean',
|
|
91
|
+
* nullable: 'yes', // Invalid - should be boolean
|
|
92
|
+
* description: 'A flag'
|
|
93
|
+
* } as any,
|
|
94
|
+
* context: parseContext
|
|
95
|
+
* });
|
|
96
|
+
*
|
|
97
|
+
* console.log(result.nullable); // undefined (invalid value removed)
|
|
98
|
+
* console.log(result.value); // { type: 'boolean', description: 'A flag' }
|
|
99
|
+
* // Context will log a warning about the invalid nullable value
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example Usage in type generation
|
|
103
|
+
* ```typescript
|
|
104
|
+
* function generateTypeScript(schema: OpenAPIV3.SchemaObject) {
|
|
105
|
+
* const { nullable, value } = parseNullable({ value: schema, context });
|
|
106
|
+
*
|
|
107
|
+
* const baseType = generateBaseType(value);
|
|
108
|
+
* const nullableType = nullable ? ` | null` : '';
|
|
109
|
+
*
|
|
110
|
+
* return `${baseType}${nullableType}`;
|
|
111
|
+
* }
|
|
112
|
+
*
|
|
113
|
+
* // Examples:
|
|
114
|
+
* // nullable: true -> 'string | null'
|
|
115
|
+
* // nullable: false -> 'string'
|
|
116
|
+
* // nullable: undefined -> 'string' (default behavior)
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example Complex schema with nullable
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const result = parseNullable({
|
|
122
|
+
* value: {
|
|
123
|
+
* type: 'object',
|
|
124
|
+
* properties: {
|
|
125
|
+
* name: { type: 'string' },
|
|
126
|
+
* age: { type: 'number' }
|
|
127
|
+
* },
|
|
128
|
+
* required: ['name'],
|
|
129
|
+
* nullable: true // The entire object can be null
|
|
130
|
+
* },
|
|
131
|
+
* context: parseContext
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* console.log(result.nullable); // true
|
|
135
|
+
* // Generated type might be: { name: string; age?: number } | null
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
11
138
|
export declare const parseNullable: <Value extends OpenAPIV3.SchemaObject>({ value, context }: ParseNullableArgs<Value>) => ParseNullableReturn<Value>;
|
|
12
139
|
//# sourceMappingURL=parseNullable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseNullable.d.ts","sourceRoot":"","sources":["../../../src/oas/_helpers/parseNullable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,SAAS,CAAC,YAAY,IAAI;IACpE,KAAK,EAAE,KAAK,CAAA;IACZ,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,mBAAmB,CAAC,KA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
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
/**
|
|
3
|
+
* Parses and validates the nullable property from OpenAPI schema objects.
|
|
4
|
+
*
|
|
5
|
+
* This function extracts and validates the `nullable` property from OpenAPI
|
|
6
|
+
* schema objects, ensuring it's a valid boolean value. Invalid nullable values
|
|
7
|
+
* are removed and logged as warnings through the parse context.
|
|
8
|
+
*
|
|
9
|
+
* The nullable property determines whether a schema value can be null in addition
|
|
10
|
+
* to its primary type, which affects type generation and validation logic.
|
|
11
|
+
*
|
|
12
|
+
* @template Value - The OpenAPI schema object type
|
|
13
|
+
*
|
|
14
|
+
* @param args - Parsing configuration
|
|
15
|
+
* @returns Parsed nullable data with the validated flag and cleaned schema
|
|
16
|
+
*
|
|
17
|
+
* @example Valid nullable property
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { parseNullable } from '@skmtc/core/oas/_helpers';
|
|
20
|
+
*
|
|
21
|
+
* const result = parseNullable({
|
|
22
|
+
* value: {
|
|
23
|
+
* type: 'string',
|
|
24
|
+
* nullable: true,
|
|
25
|
+
* description: 'An optional string that can be null'
|
|
26
|
+
* },
|
|
27
|
+
* context: parseContext
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* console.log(result.nullable); // true
|
|
31
|
+
* console.log(result.value); // { type: 'string', description: 'An optional string that can be null' }
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example Explicitly non-nullable
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const result = parseNullable({
|
|
37
|
+
* value: {
|
|
38
|
+
* type: 'number',
|
|
39
|
+
* nullable: false,
|
|
40
|
+
* minimum: 0
|
|
41
|
+
* },
|
|
42
|
+
* context: parseContext
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* console.log(result.nullable); // false
|
|
46
|
+
* console.log(result.value); // { type: 'number', minimum: 0 }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example Missing nullable property (undefined)
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const result = parseNullable({
|
|
52
|
+
* value: {
|
|
53
|
+
* type: 'string',
|
|
54
|
+
* format: 'email'
|
|
55
|
+
* },
|
|
56
|
+
* context: parseContext
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* console.log(result.nullable); // undefined (property not present)
|
|
60
|
+
* console.log(result.value); // { type: 'string', format: 'email' }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Invalid nullable value
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const result = parseNullable({
|
|
66
|
+
* value: {
|
|
67
|
+
* type: 'boolean',
|
|
68
|
+
* nullable: 'yes', // Invalid - should be boolean
|
|
69
|
+
* description: 'A flag'
|
|
70
|
+
* } as any,
|
|
71
|
+
* context: parseContext
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* console.log(result.nullable); // undefined (invalid value removed)
|
|
75
|
+
* console.log(result.value); // { type: 'boolean', description: 'A flag' }
|
|
76
|
+
* // Context will log a warning about the invalid nullable value
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example Usage in type generation
|
|
80
|
+
* ```typescript
|
|
81
|
+
* function generateTypeScript(schema: OpenAPIV3.SchemaObject) {
|
|
82
|
+
* const { nullable, value } = parseNullable({ value: schema, context });
|
|
83
|
+
*
|
|
84
|
+
* const baseType = generateBaseType(value);
|
|
85
|
+
* const nullableType = nullable ? ` | null` : '';
|
|
86
|
+
*
|
|
87
|
+
* return `${baseType}${nullableType}`;
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* // Examples:
|
|
91
|
+
* // nullable: true -> 'string | null'
|
|
92
|
+
* // nullable: false -> 'string'
|
|
93
|
+
* // nullable: undefined -> 'string' (default behavior)
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @example Complex schema with nullable
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const result = parseNullable({
|
|
99
|
+
* value: {
|
|
100
|
+
* type: 'object',
|
|
101
|
+
* properties: {
|
|
102
|
+
* name: { type: 'string' },
|
|
103
|
+
* age: { type: 'number' }
|
|
104
|
+
* },
|
|
105
|
+
* required: ['name'],
|
|
106
|
+
* nullable: true // The entire object can be null
|
|
107
|
+
* },
|
|
108
|
+
* context: parseContext
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* console.log(result.nullable); // true
|
|
112
|
+
* // Generated type might be: { name: string; age?: number } | null
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
2
115
|
export const parseNullable = ({ value, context }) => {
|
|
3
116
|
const { nullable, ...rest } = value;
|
|
4
117
|
const parsedNullable = context.provisionalParse({
|
|
@@ -5,18 +5,57 @@ import type { OasRef } from '../ref/Ref.js';
|
|
|
5
5
|
type ToExampleSimpleV3Args = {
|
|
6
6
|
example: unknown;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Creates a simple OAS example from a value.
|
|
10
|
+
*
|
|
11
|
+
* Converts a raw example value into an OasExample object with basic
|
|
12
|
+
* fields. Used for simple example scenarios where only the value matters.
|
|
13
|
+
*
|
|
14
|
+
* @param args - Arguments containing the example value
|
|
15
|
+
* @returns OasExample object with the provided value
|
|
16
|
+
*/
|
|
8
17
|
export declare const toExampleSimpleV3: ({ example }: ToExampleSimpleV3Args) => OasExample | OasRef<"example">;
|
|
18
|
+
/**
|
|
19
|
+
* Arguments for processing OpenAPI v3 examples into OAS example objects.
|
|
20
|
+
*
|
|
21
|
+
* Handles both single example and examples collection scenarios,
|
|
22
|
+
* with context for tracing and error handling.
|
|
23
|
+
*/
|
|
9
24
|
export type ToExamplesV3Args = {
|
|
25
|
+
/** Single example object (OpenAPI v3 format) */
|
|
10
26
|
example: OpenAPIV3.ExampleObject | undefined;
|
|
27
|
+
/** Collection of named examples (OpenAPI v3 format) */
|
|
11
28
|
examples: Record<string, OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject> | undefined;
|
|
29
|
+
/** Key name for the example context */
|
|
12
30
|
exampleKey: string;
|
|
31
|
+
/** Parse context for tracing and error handling */
|
|
13
32
|
context: ParseContext;
|
|
14
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Processes OpenAPI v3 examples into OAS example objects.
|
|
36
|
+
*
|
|
37
|
+
* Handles both single example and examples collection scenarios,
|
|
38
|
+
* converting them to the internal OAS representation. Provides
|
|
39
|
+
* warnings when both formats are specified simultaneously.
|
|
40
|
+
*
|
|
41
|
+
* @param args - Arguments containing example data and context
|
|
42
|
+
* @returns Record of processed examples, or undefined if no examples
|
|
43
|
+
*/
|
|
15
44
|
export declare const toExamplesV3: ({ example, examples, exampleKey, context }: ToExamplesV3Args) => Record<string, OasExample | OasRef<"example">> | undefined;
|
|
16
45
|
type ToExampleV3Args = {
|
|
17
46
|
example: OpenAPIV3.ExampleObject | OpenAPIV3.ReferenceObject;
|
|
18
47
|
context: ParseContext;
|
|
19
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Processes a single OpenAPI v3 example into an OAS example object.
|
|
51
|
+
*
|
|
52
|
+
* Converts OpenAPI v3 example objects or references into the internal
|
|
53
|
+
* OAS representation, handling both direct examples and $ref references.
|
|
54
|
+
* Processes specification extensions and maintains all example metadata.
|
|
55
|
+
*
|
|
56
|
+
* @param args - Arguments containing the example and parsing context
|
|
57
|
+
* @returns OasExample object or reference to an example
|
|
58
|
+
*/
|
|
20
59
|
export declare const toExampleV3: ({ example, context }: ToExampleV3Args) => OasExample | OasRef<"example">;
|
|
21
60
|
export {};
|
|
22
61
|
//# sourceMappingURL=toExamplesV3.d.ts.map
|
|
@@ -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,c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,CAAA;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAE/B,qBAAqB,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAQvD,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gDAAgD;IAChD,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,SAAS,CAAA;IACzF,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,mDAAmD;IACnD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAAI,4CAK1B,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,SAsBtE,CAAA;AAED,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,SAAS,CAAC,aAAa,GAAG,SAAS,CAAC,eAAe,CAAA;IAC5D,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GAAI,sBAGzB,eAAe,KAAG,UAAU,GAAG,MAAM,CAAC,SAAS,CAoBjD,CAAA"}
|
|
@@ -2,6 +2,15 @@ import { isRef } from '../../helpers/refFns.js';
|
|
|
2
2
|
import { toRefV31 } from '../ref/toRefV31.js';
|
|
3
3
|
import { OasExample } from './Example.js';
|
|
4
4
|
import { toSpecificationExtensionsV3 } from '../specificationExtensions/toSpecificationExtensionsV3.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a simple OAS example from a value.
|
|
7
|
+
*
|
|
8
|
+
* Converts a raw example value into an OasExample object with basic
|
|
9
|
+
* fields. Used for simple example scenarios where only the value matters.
|
|
10
|
+
*
|
|
11
|
+
* @param args - Arguments containing the example value
|
|
12
|
+
* @returns OasExample object with the provided value
|
|
13
|
+
*/
|
|
5
14
|
export const toExampleSimpleV3 = ({ example }) => {
|
|
6
15
|
const fields = {
|
|
7
16
|
value: example,
|
|
@@ -10,6 +19,16 @@ export const toExampleSimpleV3 = ({ example }) => {
|
|
|
10
19
|
};
|
|
11
20
|
return new OasExample(fields);
|
|
12
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Processes OpenAPI v3 examples into OAS example objects.
|
|
24
|
+
*
|
|
25
|
+
* Handles both single example and examples collection scenarios,
|
|
26
|
+
* converting them to the internal OAS representation. Provides
|
|
27
|
+
* warnings when both formats are specified simultaneously.
|
|
28
|
+
*
|
|
29
|
+
* @param args - Arguments containing example data and context
|
|
30
|
+
* @returns Record of processed examples, or undefined if no examples
|
|
31
|
+
*/
|
|
13
32
|
export const toExamplesV3 = ({ example, examples, exampleKey, context }) => {
|
|
14
33
|
if (example && examples) {
|
|
15
34
|
context.logger.warn(`Both example and examples are defined for ${exampleKey}`);
|
|
@@ -28,6 +47,16 @@ export const toExamplesV3 = ({ example, examples, exampleKey, context }) => {
|
|
|
28
47
|
}
|
|
29
48
|
return undefined;
|
|
30
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Processes a single OpenAPI v3 example into an OAS example object.
|
|
52
|
+
*
|
|
53
|
+
* Converts OpenAPI v3 example objects or references into the internal
|
|
54
|
+
* OAS representation, handling both direct examples and $ref references.
|
|
55
|
+
* Processes specification extensions and maintains all example metadata.
|
|
56
|
+
*
|
|
57
|
+
* @param args - Arguments containing the example and parsing context
|
|
58
|
+
* @returns OasExample object or reference to an example
|
|
59
|
+
*/
|
|
31
60
|
export const toExampleV3 = ({ example, context }) => {
|
|
32
61
|
if (isRef(example)) {
|
|
33
62
|
return toRefV31({ ref: example, refType: 'example', context });
|
|
@@ -182,11 +182,17 @@ export declare class OasObject<Nullable extends boolean | undefined = boolean |
|
|
|
182
182
|
* The default value of the object.
|
|
183
183
|
*/
|
|
184
184
|
default: Nullable extends true ? Record<string, unknown> | null | undefined : Record<string, unknown> | undefined;
|
|
185
|
+
/** Maximum number of properties allowed in the object */
|
|
185
186
|
maxProperties?: number;
|
|
187
|
+
/** Minimum number of properties required in the object */
|
|
186
188
|
minProperties?: number;
|
|
189
|
+
/** Whether the object is read-only */
|
|
187
190
|
readOnly?: boolean;
|
|
191
|
+
/** Whether the object is write-only */
|
|
188
192
|
writeOnly?: boolean;
|
|
193
|
+
/** Whether the object schema is deprecated */
|
|
189
194
|
deprecated?: boolean;
|
|
195
|
+
/** Array of valid enum values for the object */
|
|
190
196
|
enums?: Nullable extends true ? (Record<string, unknown> | null)[] | undefined : Record<string, unknown>[] | undefined;
|
|
191
197
|
/**
|
|
192
198
|
* Creates a new OasObject instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Object.d.ts","sourceRoot":"","sources":["../../../src/oas/object/Object.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,QAAQ,SAAS,OAAO,GAAG,SAAS,IAAI;IAClE,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC,GAAG,SAAS,CAAA;IACnF,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,EAAE,GA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,gDAAgD;IAChD,KAAK,CAAC,EAAE,QAAQ,SAAS,IAAI,GACzB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,SAAS,GAC9C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,SAAS,CAAA;IACzC;;;;;;;;;;;;;;;;;OAiBG;gBACS,MAAM,GAAE,eAAe,CAAC,QAAQ,CAAM;IAiBlD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC;IAQhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,SAAS;IAmBnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAkBvC,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,SAAS;IAIpB,WAAW,IAAI,SAAS;IAIxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC,oBAAoB;CA8B3E"}
|
package/esm/oas/object/Object.js
CHANGED
|
@@ -205,36 +205,42 @@ export class OasObject {
|
|
|
205
205
|
writable: true,
|
|
206
206
|
value: void 0
|
|
207
207
|
});
|
|
208
|
+
/** Maximum number of properties allowed in the object */
|
|
208
209
|
Object.defineProperty(this, "maxProperties", {
|
|
209
210
|
enumerable: true,
|
|
210
211
|
configurable: true,
|
|
211
212
|
writable: true,
|
|
212
213
|
value: void 0
|
|
213
214
|
});
|
|
215
|
+
/** Minimum number of properties required in the object */
|
|
214
216
|
Object.defineProperty(this, "minProperties", {
|
|
215
217
|
enumerable: true,
|
|
216
218
|
configurable: true,
|
|
217
219
|
writable: true,
|
|
218
220
|
value: void 0
|
|
219
221
|
});
|
|
222
|
+
/** Whether the object is read-only */
|
|
220
223
|
Object.defineProperty(this, "readOnly", {
|
|
221
224
|
enumerable: true,
|
|
222
225
|
configurable: true,
|
|
223
226
|
writable: true,
|
|
224
227
|
value: void 0
|
|
225
228
|
});
|
|
229
|
+
/** Whether the object is write-only */
|
|
226
230
|
Object.defineProperty(this, "writeOnly", {
|
|
227
231
|
enumerable: true,
|
|
228
232
|
configurable: true,
|
|
229
233
|
writable: true,
|
|
230
234
|
value: void 0
|
|
231
235
|
});
|
|
236
|
+
/** Whether the object schema is deprecated */
|
|
232
237
|
Object.defineProperty(this, "deprecated", {
|
|
233
238
|
enumerable: true,
|
|
234
239
|
configurable: true,
|
|
235
240
|
writable: true,
|
|
236
241
|
value: void 0
|
|
237
242
|
});
|
|
243
|
+
/** Array of valid enum values for the object */
|
|
238
244
|
Object.defineProperty(this, "enums", {
|
|
239
245
|
enumerable: true,
|
|
240
246
|
configurable: true,
|
|
@@ -11,19 +11,39 @@ import { OasObject } from '../object/Object.js';
|
|
|
11
11
|
import type { ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
12
12
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
13
13
|
import type { OasSecurityRequirement } from '../securityRequirement/SecurityRequirement.js';
|
|
14
|
+
/**
|
|
15
|
+
* Fields for configuring an OpenAPI operation object.
|
|
16
|
+
*
|
|
17
|
+
* Contains all the properties needed to define a complete OpenAPI operation,
|
|
18
|
+
* including path information, parameters, request/response specifications,
|
|
19
|
+
* security requirements, and metadata.
|
|
20
|
+
*/
|
|
14
21
|
export type OperationFields = {
|
|
22
|
+
/** The API path for this operation */
|
|
15
23
|
path: string;
|
|
24
|
+
/** The HTTP method for this operation */
|
|
16
25
|
method: Method;
|
|
26
|
+
/** The parent path item containing this operation */
|
|
17
27
|
pathItem: OasPathItem | undefined;
|
|
28
|
+
/** Unique identifier for the operation */
|
|
18
29
|
operationId?: string | undefined;
|
|
30
|
+
/** Brief summary of the operation */
|
|
19
31
|
summary?: string | undefined;
|
|
32
|
+
/** Tags for organizing operations in documentation */
|
|
20
33
|
tags?: string[] | undefined;
|
|
34
|
+
/** Detailed description of the operation */
|
|
21
35
|
description?: string | undefined;
|
|
36
|
+
/** Parameters accepted by this operation */
|
|
22
37
|
parameters?: (OasParameter | OasRef<'parameter'>)[] | undefined;
|
|
38
|
+
/** Request body specification for this operation */
|
|
23
39
|
requestBody?: OasRequestBody | OasRef<'requestBody'> | undefined;
|
|
40
|
+
/** Response specifications mapped by status code */
|
|
24
41
|
responses: Record<string, OasResponse | OasRef<'response'>>;
|
|
42
|
+
/** Security requirements for this operation */
|
|
25
43
|
security?: OasSecurityRequirement[] | undefined;
|
|
44
|
+
/** Whether this operation is deprecated */
|
|
26
45
|
deprecated?: boolean | undefined;
|
|
46
|
+
/** OpenAPI specification extensions */
|
|
27
47
|
extensionFields?: Record<string, unknown>;
|
|
28
48
|
};
|
|
29
49
|
type ToRequestBodyMapArgs = {
|
|
@@ -138,19 +158,33 @@ type ToRequestBodyMapArgs = {
|
|
|
138
158
|
* ```
|
|
139
159
|
*/
|
|
140
160
|
export declare class OasOperation {
|
|
161
|
+
/** Type identifier for OAS operation objects */
|
|
141
162
|
oasType: 'operation';
|
|
163
|
+
/** The API path for this operation */
|
|
142
164
|
path: string;
|
|
165
|
+
/** The HTTP method for this operation */
|
|
143
166
|
method: Method;
|
|
167
|
+
/** The parent path item containing this operation */
|
|
144
168
|
pathItem: OasPathItem | undefined;
|
|
169
|
+
/** Unique identifier for the operation */
|
|
145
170
|
operationId: string | undefined;
|
|
171
|
+
/** Brief summary of the operation */
|
|
146
172
|
summary: string | undefined;
|
|
173
|
+
/** Tags for organizing operations in documentation */
|
|
147
174
|
tags: string[] | undefined;
|
|
175
|
+
/** Detailed description of the operation */
|
|
148
176
|
description: string | undefined;
|
|
177
|
+
/** Parameters accepted by this operation */
|
|
149
178
|
parameters: (OasParameter | OasRef<'parameter'>)[] | undefined;
|
|
179
|
+
/** Request body specification for this operation */
|
|
150
180
|
requestBody: OasRequestBody | OasRef<'requestBody'> | undefined;
|
|
181
|
+
/** Response specifications mapped by status code */
|
|
151
182
|
responses: Record<string, OasResponse | OasRef<'response'>>;
|
|
183
|
+
/** Security requirements for this operation */
|
|
152
184
|
security: OasSecurityRequirement[] | undefined;
|
|
185
|
+
/** Whether this operation is deprecated */
|
|
153
186
|
deprecated: boolean | undefined;
|
|
187
|
+
/** OpenAPI specification extensions */
|
|
154
188
|
extensionFields: Record<string, unknown> | undefined;
|
|
155
189
|
constructor(fields: OperationFields);
|
|
156
190
|
toSuccessResponse(): OasResponse | OasRef<'response'> | undefined;
|