@skmtc/core 0.0.788 → 0.0.790
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 +178 -0
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +108 -0
- package/esm/context/RenderContext.d.ts +190 -0
- package/esm/context/RenderContext.d.ts.map +1 -1
- package/esm/context/RenderContext.js +179 -0
- package/esm/dsl/Inserted.d.ts +240 -0
- package/esm/dsl/Inserted.d.ts.map +1 -1
- package/esm/dsl/Inserted.js +231 -0
- package/esm/helpers/refFns.d.ts +160 -0
- package/esm/helpers/refFns.d.ts.map +1 -1
- package/esm/helpers/refFns.js +156 -0
- package/esm/oas/boolean/Boolean.d.ts +142 -1
- package/esm/oas/boolean/Boolean.d.ts.map +1 -1
- package/esm/oas/boolean/Boolean.js +130 -1
- package/esm/oas/components/Components.d.ts +252 -2
- package/esm/oas/components/Components.d.ts.map +1 -1
- package/esm/oas/components/Components.js +241 -2
- package/esm/oas/parameter/Parameter.d.ts +160 -0
- package/esm/oas/parameter/Parameter.d.ts.map +1 -1
- package/esm/oas/parameter/Parameter.js +144 -0
- package/esm/oas/union/Union.d.ts +119 -5
- package/esm/oas/union/Union.d.ts.map +1 -1
- package/esm/oas/union/Union.js +108 -5
- package/package.json +1 -1
- package/script/context/ParseContext.d.ts +178 -0
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +108 -0
- package/script/context/RenderContext.d.ts +190 -0
- package/script/context/RenderContext.d.ts.map +1 -1
- package/script/context/RenderContext.js +179 -0
- package/script/dsl/Inserted.d.ts +240 -0
- package/script/dsl/Inserted.d.ts.map +1 -1
- package/script/dsl/Inserted.js +231 -0
- package/script/helpers/refFns.d.ts +160 -0
- package/script/helpers/refFns.d.ts.map +1 -1
- package/script/helpers/refFns.js +156 -0
- package/script/oas/boolean/Boolean.d.ts +142 -1
- package/script/oas/boolean/Boolean.d.ts.map +1 -1
- package/script/oas/boolean/Boolean.js +130 -1
- package/script/oas/components/Components.d.ts +252 -2
- package/script/oas/components/Components.d.ts.map +1 -1
- package/script/oas/components/Components.js +241 -2
- package/script/oas/parameter/Parameter.d.ts +160 -0
- package/script/oas/parameter/Parameter.d.ts.map +1 -1
- package/script/oas/parameter/Parameter.js +144 -0
- package/script/oas/union/Union.d.ts +119 -5
- package/script/oas/union/Union.d.ts.map +1 -1
- package/script/oas/union/Union.js +108 -5
|
@@ -15,6 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.OasComponents = exports.componentsKeys = void 0;
|
|
16
16
|
require("../../_dnt.polyfills.js");
|
|
17
17
|
require("../../_dnt.polyfills.js");
|
|
18
|
+
/**
|
|
19
|
+
* Available component types in an OpenAPI document.
|
|
20
|
+
*/
|
|
18
21
|
exports.componentsKeys = [
|
|
19
22
|
'schemas',
|
|
20
23
|
'responses',
|
|
@@ -24,11 +27,182 @@ exports.componentsKeys = [
|
|
|
24
27
|
'headers',
|
|
25
28
|
'securitySchemes'
|
|
26
29
|
];
|
|
27
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Represents the OpenAPI Components Object in the SKMTC OAS processing system.
|
|
32
|
+
*
|
|
33
|
+
* The `OasComponents` class manages the reusable components section of an OpenAPI
|
|
34
|
+
* document, providing centralized access to shared schemas, responses, parameters,
|
|
35
|
+
* and other reusable elements that can be referenced throughout the API specification.
|
|
36
|
+
*
|
|
37
|
+
* This class serves as the central registry for all reusable components, enabling
|
|
38
|
+
* efficient reference resolution and reducing duplication in OpenAPI documents.
|
|
39
|
+
*
|
|
40
|
+
* ## Key Features
|
|
41
|
+
*
|
|
42
|
+
* - **Schema Management**: Central repository for reusable data schemas
|
|
43
|
+
* - **Response Reuse**: Common response definitions for consistent API responses
|
|
44
|
+
* - **Parameter Standardization**: Shared parameter definitions across operations
|
|
45
|
+
* - **Reference Resolution**: Support for internal references ($ref) to components
|
|
46
|
+
* - **Type Safety**: Strongly typed access to different component categories
|
|
47
|
+
* - **Extension Support**: Custom OpenAPI extension field handling
|
|
48
|
+
*
|
|
49
|
+
* @example Basic component access
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { OasComponents } from '@skmtc/core';
|
|
52
|
+
*
|
|
53
|
+
* // Typically created during document parsing
|
|
54
|
+
* const components = new OasComponents({
|
|
55
|
+
* schemas: {
|
|
56
|
+
* User: new OasObject({
|
|
57
|
+
* properties: {
|
|
58
|
+
* id: new OasString(),
|
|
59
|
+
* name: new OasString()
|
|
60
|
+
* }
|
|
61
|
+
* }),
|
|
62
|
+
* Product: new OasObject({
|
|
63
|
+
* properties: {
|
|
64
|
+
* id: new OasString(),
|
|
65
|
+
* price: new OasNumber()
|
|
66
|
+
* }
|
|
67
|
+
* })
|
|
68
|
+
* },
|
|
69
|
+
* responses: {
|
|
70
|
+
* NotFound: new OasResponse({
|
|
71
|
+
* description: '404 - Resource not found'
|
|
72
|
+
* })
|
|
73
|
+
* }
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* // Access schemas
|
|
77
|
+
* const userSchema = components.schemas?.['User'];
|
|
78
|
+
* const productSchema = components.schemas?.['Product'];
|
|
79
|
+
*
|
|
80
|
+
* // Access responses
|
|
81
|
+
* const notFoundResponse = components.responses?.['NotFound'];
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example Schema management
|
|
85
|
+
* ```typescript
|
|
86
|
+
* // Get all schema reference names
|
|
87
|
+
* const schemaNames = components.toSchemasRefNames();
|
|
88
|
+
* console.log(schemaNames); // ['User', 'Product', 'Order']
|
|
89
|
+
*
|
|
90
|
+
* // Remove a schema (useful for processing)
|
|
91
|
+
* const removedSchema = components.removeSchema('ObsoleteSchema');
|
|
92
|
+
* console.log('Removed:', removedSchema);
|
|
93
|
+
*
|
|
94
|
+
* // Check remaining schemas
|
|
95
|
+
* const remainingSchemas = components.toSchemasRefNames();
|
|
96
|
+
* console.log('Remaining:', remainingSchemas);
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example Parameter reuse
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const components = new OasComponents({
|
|
102
|
+
* parameters: {
|
|
103
|
+
* PageSize: new OasParameter({
|
|
104
|
+
* name: 'pageSize',
|
|
105
|
+
* in: 'query',
|
|
106
|
+
* schema: new OasInteger({ minimum: 1, maximum: 100, default: 20 })
|
|
107
|
+
* }),
|
|
108
|
+
* PageNumber: new OasParameter({
|
|
109
|
+
* name: 'page',
|
|
110
|
+
* in: 'query',
|
|
111
|
+
* schema: new OasInteger({ minimum: 1, default: 1 })
|
|
112
|
+
* })
|
|
113
|
+
* }
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* // These parameters can be referenced in operations:
|
|
117
|
+
* // $ref: '#/components/parameters/PageSize'
|
|
118
|
+
* // $ref: '#/components/parameters/PageNumber'
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @example Response standardization
|
|
122
|
+
* ```typescript
|
|
123
|
+
* const components = new OasComponents({
|
|
124
|
+
* responses: {
|
|
125
|
+
* Success: new OasResponse({
|
|
126
|
+
* description: 'Successful operation',
|
|
127
|
+
* content: {
|
|
128
|
+
* 'application/json': {
|
|
129
|
+
* schema: new OasObject({
|
|
130
|
+
* properties: {
|
|
131
|
+
* success: new OasBoolean({ default: true }),
|
|
132
|
+
* data: new OasObject({ additionalProperties: true })
|
|
133
|
+
* }
|
|
134
|
+
* })
|
|
135
|
+
* }
|
|
136
|
+
* }
|
|
137
|
+
* }),
|
|
138
|
+
* ValidationError: new OasResponse({
|
|
139
|
+
* description: 'Validation failed',
|
|
140
|
+
* content: {
|
|
141
|
+
* 'application/json': {
|
|
142
|
+
* schema: new OasObject({
|
|
143
|
+
* properties: {
|
|
144
|
+
* error: new OasString(),
|
|
145
|
+
* details: new OasArray({
|
|
146
|
+
* items: new OasString()
|
|
147
|
+
* })
|
|
148
|
+
* }
|
|
149
|
+
* })
|
|
150
|
+
* }
|
|
151
|
+
* }
|
|
152
|
+
* })
|
|
153
|
+
* }
|
|
154
|
+
* });
|
|
155
|
+
*
|
|
156
|
+
* // Standardized responses across all operations
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* @example Processing components in generators
|
|
160
|
+
* ```typescript
|
|
161
|
+
* class ComponentProcessor {
|
|
162
|
+
* processDocument(document: OasDocument) {
|
|
163
|
+
* const components = document.components;
|
|
164
|
+
* if (!components) return;
|
|
165
|
+
*
|
|
166
|
+
* // Process all schemas
|
|
167
|
+
* if (components.schemas) {
|
|
168
|
+
* Object.entries(components.schemas).forEach(([name, schema]) => {
|
|
169
|
+
* if (schema.isRef()) {
|
|
170
|
+
* console.log(`Schema ${name} is a reference to ${schema.$ref}`);
|
|
171
|
+
* } else {
|
|
172
|
+
* console.log(`Schema ${name} is a direct definition`);
|
|
173
|
+
* }
|
|
174
|
+
* });
|
|
175
|
+
* }
|
|
28
176
|
*
|
|
29
|
-
*
|
|
177
|
+
* // Process parameters
|
|
178
|
+
* if (components.parameters) {
|
|
179
|
+
* Object.keys(components.parameters).forEach(paramName => {
|
|
180
|
+
* console.log(`Reusable parameter: ${paramName}`);
|
|
181
|
+
* });
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
* }
|
|
185
|
+
* ```
|
|
30
186
|
*/
|
|
31
187
|
class OasComponents {
|
|
188
|
+
/**
|
|
189
|
+
* Creates a new OasComponents instance.
|
|
190
|
+
*
|
|
191
|
+
* @param fields - Component definitions (defaults to empty object)
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const components = new OasComponents({
|
|
196
|
+
* schemas: {
|
|
197
|
+
* User: userSchema,
|
|
198
|
+
* Product: productSchema
|
|
199
|
+
* },
|
|
200
|
+
* responses: {
|
|
201
|
+
* NotFound: notFoundResponse
|
|
202
|
+
* }
|
|
203
|
+
* });
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
32
206
|
constructor(fields = {}) {
|
|
33
207
|
/** Static identifier property for OasComponents */
|
|
34
208
|
Object.defineProperty(this, "oasType", {
|
|
@@ -41,6 +215,35 @@ class OasComponents {
|
|
|
41
215
|
_OasComponents_fields.set(this, void 0);
|
|
42
216
|
__classPrivateFieldSet(this, _OasComponents_fields, fields, "f");
|
|
43
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Gets all schema reference names.
|
|
220
|
+
*
|
|
221
|
+
* This method extracts the keys from the schemas object and returns them
|
|
222
|
+
* as an array of RefName types. Useful for iterating over all available
|
|
223
|
+
* schemas or checking schema availability.
|
|
224
|
+
*
|
|
225
|
+
* @returns Array of reference names for all schemas
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const components = new OasComponents({
|
|
230
|
+
* schemas: {
|
|
231
|
+
* User: userSchema,
|
|
232
|
+
* Product: productSchema,
|
|
233
|
+
* Order: orderSchema
|
|
234
|
+
* }
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* const schemaNames = components.toSchemasRefNames();
|
|
238
|
+
* console.log(schemaNames); // ['User', 'Product', 'Order']
|
|
239
|
+
*
|
|
240
|
+
* // Use for processing
|
|
241
|
+
* schemaNames.forEach(name => {
|
|
242
|
+
* const schema = components.schemas?.[name];
|
|
243
|
+
* console.log(`Processing schema: ${name}`);
|
|
244
|
+
* });
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
44
247
|
toSchemasRefNames() {
|
|
45
248
|
return Object.keys(__classPrivateFieldGet(this, _OasComponents_fields, "f").schemas ?? {});
|
|
46
249
|
}
|
|
@@ -48,6 +251,42 @@ class OasComponents {
|
|
|
48
251
|
get schemas() {
|
|
49
252
|
return __classPrivateFieldGet(this, _OasComponents_fields, "f").schemas;
|
|
50
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Removes a schema from the components and returns it.
|
|
256
|
+
*
|
|
257
|
+
* This method permanently removes a schema from the components object
|
|
258
|
+
* and returns the removed schema. This is useful during processing when
|
|
259
|
+
* you need to extract and handle specific schemas separately.
|
|
260
|
+
*
|
|
261
|
+
* @param refName - The reference name of the schema to remove
|
|
262
|
+
* @returns The removed schema object or reference
|
|
263
|
+
*
|
|
264
|
+
* @throws {Error} When the schema doesn't exist or schemas object is undefined
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* const components = new OasComponents({
|
|
269
|
+
* schemas: {
|
|
270
|
+
* User: userSchema,
|
|
271
|
+
* Product: productSchema,
|
|
272
|
+
* Internal: internalSchema
|
|
273
|
+
* }
|
|
274
|
+
* });
|
|
275
|
+
*
|
|
276
|
+
* // Remove internal schema that shouldn't be exposed
|
|
277
|
+
* const internalSchema = components.removeSchema('Internal');
|
|
278
|
+
* console.log('Removed internal schema');
|
|
279
|
+
*
|
|
280
|
+
* // Check remaining schemas
|
|
281
|
+
* const remainingSchemas = components.toSchemasRefNames();
|
|
282
|
+
* console.log(remainingSchemas); // ['User', 'Product']
|
|
283
|
+
*
|
|
284
|
+
* // Process removed schema separately
|
|
285
|
+
* if (!internalSchema.isRef()) {
|
|
286
|
+
* console.log('Processing internal schema privately');
|
|
287
|
+
* }
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
51
290
|
removeSchema(refName) {
|
|
52
291
|
const { [refName]: removed, ...rest } = __classPrivateFieldGet(this, _OasComponents_fields, "f").schemas;
|
|
53
292
|
__classPrivateFieldGet(this, _OasComponents_fields, "f").schemas = rest;
|
|
@@ -6,21 +6,181 @@ import type { OasExample } from '../example/Example.js';
|
|
|
6
6
|
import type { OasSchema } from '../schema/Schema.js';
|
|
7
7
|
import type { ToJsonSchemaOptions } from '../schema/Schema.js';
|
|
8
8
|
import type { OpenAPIV3 } from 'openapi-types';
|
|
9
|
+
/**
|
|
10
|
+
* Constructor fields for {@link OasParameter}.
|
|
11
|
+
*/
|
|
9
12
|
export type ParameterFields = {
|
|
13
|
+
/** The name of the parameter */
|
|
10
14
|
name: string;
|
|
15
|
+
/** The location of the parameter (path, query, header, cookie) */
|
|
11
16
|
location: OasParameterLocation;
|
|
17
|
+
/** A brief description of the parameter */
|
|
12
18
|
description?: string | undefined;
|
|
19
|
+
/** Determines whether this parameter is mandatory */
|
|
13
20
|
required?: boolean | undefined;
|
|
21
|
+
/** Specifies that the parameter is deprecated */
|
|
14
22
|
deprecated?: boolean | undefined;
|
|
23
|
+
/** Whether to allow empty values for the parameter */
|
|
15
24
|
allowEmptyValue?: boolean | undefined;
|
|
25
|
+
/** Whether reserved characters are allowed in the parameter value */
|
|
16
26
|
allowReserved?: boolean | undefined;
|
|
27
|
+
/** The schema defining the parameter's data type */
|
|
17
28
|
schema?: OasSchema | OasRef<'schema'> | undefined;
|
|
29
|
+
/** Example values for the parameter */
|
|
18
30
|
examples?: Record<string, OasExample | OasRef<'example'>> | undefined;
|
|
31
|
+
/** Media type definitions for the parameter content */
|
|
19
32
|
content?: Record<string, OasMediaType> | undefined;
|
|
33
|
+
/** The serialization style for the parameter */
|
|
20
34
|
style: OasParameterStyle;
|
|
35
|
+
/** Whether to explode parameter values */
|
|
21
36
|
explode: boolean;
|
|
37
|
+
/** Custom extension fields (x-* properties) */
|
|
22
38
|
extensionFields?: Record<string, unknown>;
|
|
23
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Represents a Parameter Object in the OpenAPI Specification.
|
|
42
|
+
*
|
|
43
|
+
* The `OasParameter` class encapsulates the definition of a single operation parameter,
|
|
44
|
+
* including its location, data type, validation rules, and serialization behavior.
|
|
45
|
+
* Parameters can be located in the path, query string, headers, or cookies.
|
|
46
|
+
*
|
|
47
|
+
* This class provides comprehensive support for parameter validation, serialization
|
|
48
|
+
* styles, and complex data types through schema definitions or content specifications.
|
|
49
|
+
*
|
|
50
|
+
* ## Key Features
|
|
51
|
+
*
|
|
52
|
+
* - **Location Support**: Path, query, header, and cookie parameters
|
|
53
|
+
* - **Schema Validation**: Comprehensive data type validation through schemas
|
|
54
|
+
* - **Serialization Styles**: Various parameter serialization formats
|
|
55
|
+
* - **Content Types**: Support for complex parameter content with media types
|
|
56
|
+
* - **Examples & Documentation**: Parameter examples and descriptive documentation
|
|
57
|
+
* - **Advanced Options**: Empty values, reserved characters, and explode behavior
|
|
58
|
+
*
|
|
59
|
+
* @example Basic path parameter
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { OasParameter, OasString } from '@skmtc/core';
|
|
62
|
+
*
|
|
63
|
+
* const userIdParam = new OasParameter({
|
|
64
|
+
* name: 'userId',
|
|
65
|
+
* location: 'path',
|
|
66
|
+
* description: 'Unique identifier for the user',
|
|
67
|
+
* required: true,
|
|
68
|
+
* schema: new OasString({
|
|
69
|
+
* pattern: '^[0-9a-f]{24}$',
|
|
70
|
+
* example: '507f1f77bcf86cd799439011'
|
|
71
|
+
* }),
|
|
72
|
+
* style: 'simple',
|
|
73
|
+
* explode: false
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* // Used in path: /users/{userId}
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example Query parameter with validation
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const pageSizeParam = new OasParameter({
|
|
82
|
+
* name: 'pageSize',
|
|
83
|
+
* location: 'query',
|
|
84
|
+
* description: 'Number of items to return per page',
|
|
85
|
+
* required: false,
|
|
86
|
+
* schema: new OasInteger({
|
|
87
|
+
* minimum: 1,
|
|
88
|
+
* maximum: 100,
|
|
89
|
+
* default: 20
|
|
90
|
+
* }),
|
|
91
|
+
* style: 'form',
|
|
92
|
+
* explode: true,
|
|
93
|
+
* examples: {
|
|
94
|
+
* small: new OasExample({ value: 10 }),
|
|
95
|
+
* medium: new OasExample({ value: 25 }),
|
|
96
|
+
* large: new OasExample({ value: 50 })
|
|
97
|
+
* }
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* // Used in query: ?pageSize=20
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example Header parameter
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const authHeaderParam = new OasParameter({
|
|
106
|
+
* name: 'Authorization',
|
|
107
|
+
* location: 'header',
|
|
108
|
+
* description: 'Bearer token for authentication',
|
|
109
|
+
* required: true,
|
|
110
|
+
* schema: new OasString({
|
|
111
|
+
* pattern: '^Bearer [A-Za-z0-9+/=]+$',
|
|
112
|
+
* example: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
113
|
+
* }),
|
|
114
|
+
* style: 'simple',
|
|
115
|
+
* explode: false
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example Complex parameter with content
|
|
120
|
+
* ```typescript
|
|
121
|
+
* const filterParam = new OasParameter({
|
|
122
|
+
* name: 'filter',
|
|
123
|
+
* location: 'query',
|
|
124
|
+
* description: 'Complex filter object',
|
|
125
|
+
* required: false,
|
|
126
|
+
* content: {
|
|
127
|
+
* 'application/json': new OasMediaType({
|
|
128
|
+
* schema: new OasObject({
|
|
129
|
+
* properties: {
|
|
130
|
+
* category: new OasString(),
|
|
131
|
+
* priceRange: new OasObject({
|
|
132
|
+
* properties: {
|
|
133
|
+
* min: new OasNumber(),
|
|
134
|
+
* max: new OasNumber()
|
|
135
|
+
* }
|
|
136
|
+
* })
|
|
137
|
+
* }
|
|
138
|
+
* })
|
|
139
|
+
* })
|
|
140
|
+
* },
|
|
141
|
+
* style: 'deepObject',
|
|
142
|
+
* explode: true
|
|
143
|
+
* });
|
|
144
|
+
*
|
|
145
|
+
* // Used as: ?filter[category]=electronics&filter[priceRange][min]=100
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @example Array parameter with explode
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const tagsParam = new OasParameter({
|
|
151
|
+
* name: 'tags',
|
|
152
|
+
* location: 'query',
|
|
153
|
+
* description: 'Filter by multiple tags',
|
|
154
|
+
* required: false,
|
|
155
|
+
* schema: new OasArray({
|
|
156
|
+
* items: new OasString(),
|
|
157
|
+
* minItems: 1,
|
|
158
|
+
* maxItems: 10
|
|
159
|
+
* }),
|
|
160
|
+
* style: 'form',
|
|
161
|
+
* explode: true // Results in: ?tags=tech&tags=api&tags=rest
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* // Without explode: ?tags=tech,api,rest
|
|
165
|
+
* // With explode: ?tags=tech&tags=api&tags=rest
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @example Cookie parameter
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const sessionParam = new OasParameter({
|
|
171
|
+
* name: 'sessionId',
|
|
172
|
+
* location: 'cookie',
|
|
173
|
+
* description: 'Session identifier cookie',
|
|
174
|
+
* required: false,
|
|
175
|
+
* schema: new OasString({
|
|
176
|
+
* minLength: 32,
|
|
177
|
+
* maxLength: 128
|
|
178
|
+
* }),
|
|
179
|
+
* style: 'form',
|
|
180
|
+
* explode: false
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
24
184
|
export declare class OasParameter {
|
|
25
185
|
oasType: 'parameter';
|
|
26
186
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parameter.d.ts","sourceRoot":"","sources":["../../../src/oas/parameter/Parameter.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,M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B,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAChC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACrC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACnC,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAA;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,SAAS,CAAA;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,CAAA;IAClD,KAAK,EAAE,iBAAiB,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;gBACxC,MAAM,EAAE,eAAe;IAkBnC,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC;IAIpC,OAAO,IAAI,YAAY;IAIvB,WAAW,IAAI,YAAY;IAI3B,QAAQ,CAAC,SAAS,GAAE,MAA2B,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;IAc9E,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC,eAAe;CAuBtE"}
|
|
@@ -2,6 +2,150 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OasParameter = void 0;
|
|
4
4
|
require("../../_dnt.polyfills.js");
|
|
5
|
+
/**
|
|
6
|
+
* Represents a Parameter Object in the OpenAPI Specification.
|
|
7
|
+
*
|
|
8
|
+
* The `OasParameter` class encapsulates the definition of a single operation parameter,
|
|
9
|
+
* including its location, data type, validation rules, and serialization behavior.
|
|
10
|
+
* Parameters can be located in the path, query string, headers, or cookies.
|
|
11
|
+
*
|
|
12
|
+
* This class provides comprehensive support for parameter validation, serialization
|
|
13
|
+
* styles, and complex data types through schema definitions or content specifications.
|
|
14
|
+
*
|
|
15
|
+
* ## Key Features
|
|
16
|
+
*
|
|
17
|
+
* - **Location Support**: Path, query, header, and cookie parameters
|
|
18
|
+
* - **Schema Validation**: Comprehensive data type validation through schemas
|
|
19
|
+
* - **Serialization Styles**: Various parameter serialization formats
|
|
20
|
+
* - **Content Types**: Support for complex parameter content with media types
|
|
21
|
+
* - **Examples & Documentation**: Parameter examples and descriptive documentation
|
|
22
|
+
* - **Advanced Options**: Empty values, reserved characters, and explode behavior
|
|
23
|
+
*
|
|
24
|
+
* @example Basic path parameter
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { OasParameter, OasString } from '@skmtc/core';
|
|
27
|
+
*
|
|
28
|
+
* const userIdParam = new OasParameter({
|
|
29
|
+
* name: 'userId',
|
|
30
|
+
* location: 'path',
|
|
31
|
+
* description: 'Unique identifier for the user',
|
|
32
|
+
* required: true,
|
|
33
|
+
* schema: new OasString({
|
|
34
|
+
* pattern: '^[0-9a-f]{24}$',
|
|
35
|
+
* example: '507f1f77bcf86cd799439011'
|
|
36
|
+
* }),
|
|
37
|
+
* style: 'simple',
|
|
38
|
+
* explode: false
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Used in path: /users/{userId}
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Query parameter with validation
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const pageSizeParam = new OasParameter({
|
|
47
|
+
* name: 'pageSize',
|
|
48
|
+
* location: 'query',
|
|
49
|
+
* description: 'Number of items to return per page',
|
|
50
|
+
* required: false,
|
|
51
|
+
* schema: new OasInteger({
|
|
52
|
+
* minimum: 1,
|
|
53
|
+
* maximum: 100,
|
|
54
|
+
* default: 20
|
|
55
|
+
* }),
|
|
56
|
+
* style: 'form',
|
|
57
|
+
* explode: true,
|
|
58
|
+
* examples: {
|
|
59
|
+
* small: new OasExample({ value: 10 }),
|
|
60
|
+
* medium: new OasExample({ value: 25 }),
|
|
61
|
+
* large: new OasExample({ value: 50 })
|
|
62
|
+
* }
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* // Used in query: ?pageSize=20
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example Header parameter
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const authHeaderParam = new OasParameter({
|
|
71
|
+
* name: 'Authorization',
|
|
72
|
+
* location: 'header',
|
|
73
|
+
* description: 'Bearer token for authentication',
|
|
74
|
+
* required: true,
|
|
75
|
+
* schema: new OasString({
|
|
76
|
+
* pattern: '^Bearer [A-Za-z0-9+/=]+$',
|
|
77
|
+
* example: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
78
|
+
* }),
|
|
79
|
+
* style: 'simple',
|
|
80
|
+
* explode: false
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example Complex parameter with content
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const filterParam = new OasParameter({
|
|
87
|
+
* name: 'filter',
|
|
88
|
+
* location: 'query',
|
|
89
|
+
* description: 'Complex filter object',
|
|
90
|
+
* required: false,
|
|
91
|
+
* content: {
|
|
92
|
+
* 'application/json': new OasMediaType({
|
|
93
|
+
* schema: new OasObject({
|
|
94
|
+
* properties: {
|
|
95
|
+
* category: new OasString(),
|
|
96
|
+
* priceRange: new OasObject({
|
|
97
|
+
* properties: {
|
|
98
|
+
* min: new OasNumber(),
|
|
99
|
+
* max: new OasNumber()
|
|
100
|
+
* }
|
|
101
|
+
* })
|
|
102
|
+
* }
|
|
103
|
+
* })
|
|
104
|
+
* })
|
|
105
|
+
* },
|
|
106
|
+
* style: 'deepObject',
|
|
107
|
+
* explode: true
|
|
108
|
+
* });
|
|
109
|
+
*
|
|
110
|
+
* // Used as: ?filter[category]=electronics&filter[priceRange][min]=100
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @example Array parameter with explode
|
|
114
|
+
* ```typescript
|
|
115
|
+
* const tagsParam = new OasParameter({
|
|
116
|
+
* name: 'tags',
|
|
117
|
+
* location: 'query',
|
|
118
|
+
* description: 'Filter by multiple tags',
|
|
119
|
+
* required: false,
|
|
120
|
+
* schema: new OasArray({
|
|
121
|
+
* items: new OasString(),
|
|
122
|
+
* minItems: 1,
|
|
123
|
+
* maxItems: 10
|
|
124
|
+
* }),
|
|
125
|
+
* style: 'form',
|
|
126
|
+
* explode: true // Results in: ?tags=tech&tags=api&tags=rest
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* // Without explode: ?tags=tech,api,rest
|
|
130
|
+
* // With explode: ?tags=tech&tags=api&tags=rest
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @example Cookie parameter
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const sessionParam = new OasParameter({
|
|
136
|
+
* name: 'sessionId',
|
|
137
|
+
* location: 'cookie',
|
|
138
|
+
* description: 'Session identifier cookie',
|
|
139
|
+
* required: false,
|
|
140
|
+
* schema: new OasString({
|
|
141
|
+
* minLength: 32,
|
|
142
|
+
* maxLength: 128
|
|
143
|
+
* }),
|
|
144
|
+
* style: 'form',
|
|
145
|
+
* explode: false
|
|
146
|
+
* });
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
5
149
|
class OasParameter {
|
|
6
150
|
constructor(fields) {
|
|
7
151
|
Object.defineProperty(this, "oasType", {
|