@skmtc/core 0.0.789 → 0.0.791

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.
Files changed (37) hide show
  1. package/esm/context/RenderContext.d.ts +190 -0
  2. package/esm/context/RenderContext.d.ts.map +1 -1
  3. package/esm/context/RenderContext.js +179 -0
  4. package/esm/oas/boolean/Boolean.d.ts +142 -1
  5. package/esm/oas/boolean/Boolean.d.ts.map +1 -1
  6. package/esm/oas/boolean/Boolean.js +130 -1
  7. package/esm/oas/number/Number.d.ts +179 -1
  8. package/esm/oas/number/Number.d.ts.map +1 -1
  9. package/esm/oas/number/Number.js +161 -1
  10. package/esm/oas/parameter/Parameter.d.ts +160 -0
  11. package/esm/oas/parameter/Parameter.d.ts.map +1 -1
  12. package/esm/oas/parameter/Parameter.js +144 -0
  13. package/esm/oas/response/Response.d.ts +190 -0
  14. package/esm/oas/response/Response.d.ts.map +1 -1
  15. package/esm/oas/response/Response.js +183 -0
  16. package/esm/oas/void/Void.d.ts +130 -3
  17. package/esm/oas/void/Void.d.ts.map +1 -1
  18. package/esm/oas/void/Void.js +125 -3
  19. package/package.json +1 -1
  20. package/script/context/RenderContext.d.ts +190 -0
  21. package/script/context/RenderContext.d.ts.map +1 -1
  22. package/script/context/RenderContext.js +179 -0
  23. package/script/oas/boolean/Boolean.d.ts +142 -1
  24. package/script/oas/boolean/Boolean.d.ts.map +1 -1
  25. package/script/oas/boolean/Boolean.js +130 -1
  26. package/script/oas/number/Number.d.ts +179 -1
  27. package/script/oas/number/Number.d.ts.map +1 -1
  28. package/script/oas/number/Number.js +161 -1
  29. package/script/oas/parameter/Parameter.d.ts +160 -0
  30. package/script/oas/parameter/Parameter.d.ts.map +1 -1
  31. package/script/oas/parameter/Parameter.js +144 -0
  32. package/script/oas/response/Response.d.ts +190 -0
  33. package/script/oas/response/Response.d.ts.map +1 -1
  34. package/script/oas/response/Response.js +183 -0
  35. package/script/oas/void/Void.d.ts +130 -3
  36. package/script/oas/void/Void.d.ts.map +1 -1
  37. package/script/oas/void/Void.js +125 -3
@@ -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,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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", {
@@ -5,12 +5,202 @@ import type { OasRef } from '../ref/Ref.js';
5
5
  import type { OasSchema } from '../schema/Schema.js';
6
6
  import type { ToJsonSchemaOptions } from '../schema/Schema.js';
7
7
  import type { OpenAPIV3 } from 'openapi-types';
8
+ /**
9
+ * Constructor fields for {@link OasResponse}.
10
+ */
8
11
  export type ResponseFields = {
12
+ /** A description of the response */
9
13
  description?: string | undefined;
14
+ /** Response headers that can be sent */
10
15
  headers?: Record<string, OasHeader | OasRef<'header'>> | undefined;
16
+ /** Response content for different media types */
11
17
  content?: Record<string, OasMediaType> | undefined;
18
+ /** Custom extension fields (x-* properties) */
12
19
  extensionFields?: Record<string, unknown>;
13
20
  };
21
+ /**
22
+ * Represents a Response Object in the OpenAPI Specification.
23
+ *
24
+ * The `OasResponse` class encapsulates the definition of a single HTTP response,
25
+ * including its description, headers, and content for different media types.
26
+ * Responses describe the possible outcomes of API operations and can include
27
+ * both successful and error scenarios.
28
+ *
29
+ * This class provides comprehensive support for response definitions with typed
30
+ * content, custom headers, and multiple media type representations.
31
+ *
32
+ * ## Key Features
33
+ *
34
+ * - **Content Types**: Support for multiple media types (JSON, XML, HTML, etc.)
35
+ * - **Header Definitions**: Custom response headers with validation
36
+ * - **Schema Integration**: Typed response bodies through schema definitions
37
+ * - **Reference Support**: Can reference reusable response components
38
+ * - **Documentation**: Rich description support for API documentation
39
+ * - **JSON Schema**: Converts to standard JSON Schema format for validation
40
+ *
41
+ * @example Basic JSON response
42
+ * ```typescript
43
+ * import { OasResponse, OasMediaType, OasObject, OasString } from '@skmtc/core';
44
+ *
45
+ * const successResponse = new OasResponse({
46
+ * description: 'User retrieved successfully',
47
+ * content: {
48
+ * 'application/json': new OasMediaType({
49
+ * schema: new OasObject({
50
+ * properties: {
51
+ * id: new OasString(),
52
+ * name: new OasString(),
53
+ * email: new OasString({ format: 'email' })
54
+ * }
55
+ * })
56
+ * })
57
+ * }
58
+ * });
59
+ * ```
60
+ *
61
+ * @example Response with custom headers
62
+ * ```typescript
63
+ * const paginatedResponse = new OasResponse({
64
+ * description: 'Paginated list of items',
65
+ * headers: {
66
+ * 'X-Total-Count': new OasHeader({
67
+ * description: 'Total number of items',
68
+ * schema: new OasInteger({ minimum: 0 })
69
+ * }),
70
+ * 'X-Page-Number': new OasHeader({
71
+ * description: 'Current page number',
72
+ * schema: new OasInteger({ minimum: 1 })
73
+ * }),
74
+ * 'Link': new OasHeader({
75
+ * description: 'Pagination links',
76
+ * schema: new OasString()
77
+ * })
78
+ * },
79
+ * content: {
80
+ * 'application/json': new OasMediaType({
81
+ * schema: new OasArray({
82
+ * items: new OasRef({ $ref: '#/components/schemas/Item' })
83
+ * })
84
+ * })
85
+ * }
86
+ * });
87
+ * ```
88
+ *
89
+ * @example Multiple content types
90
+ * ```typescript
91
+ * const multiFormatResponse = new OasResponse({
92
+ * description: 'User data in multiple formats',
93
+ * content: {
94
+ * 'application/json': new OasMediaType({
95
+ * schema: new OasRef({ $ref: '#/components/schemas/User' })
96
+ * }),
97
+ * 'application/xml': new OasMediaType({
98
+ * schema: new OasObject({
99
+ * // XML-specific schema definition
100
+ * properties: {
101
+ * user: new OasRef({ $ref: '#/components/schemas/User' })
102
+ * }
103
+ * })
104
+ * }),
105
+ * 'text/csv': new OasMediaType({
106
+ * schema: new OasString({
107
+ * description: 'User data in CSV format'
108
+ * })
109
+ * })
110
+ * }
111
+ * });
112
+ * ```
113
+ *
114
+ * @example Error responses
115
+ * ```typescript
116
+ * const errorResponse = new OasResponse({
117
+ * description: 'Validation error occurred',
118
+ * content: {
119
+ * 'application/json': new OasMediaType({
120
+ * schema: new OasObject({
121
+ * properties: {
122
+ * error: new OasString({ description: 'Error message' }),
123
+ * code: new OasString({ description: 'Error code' }),
124
+ * details: new OasArray({
125
+ * items: new OasObject({
126
+ * properties: {
127
+ * field: new OasString(),
128
+ * message: new OasString()
129
+ * }
130
+ * })
131
+ * })
132
+ * },
133
+ * required: ['error', 'code']
134
+ * })
135
+ * })
136
+ * }
137
+ * });
138
+ * ```
139
+ *
140
+ * @example File download response
141
+ * ```typescript
142
+ * const fileDownloadResponse = new OasResponse({
143
+ * description: 'File download',
144
+ * headers: {
145
+ * 'Content-Disposition': new OasHeader({
146
+ * description: 'Attachment filename',
147
+ * schema: new OasString({ example: 'attachment; filename="report.pdf"' })
148
+ * }),
149
+ * 'Content-Length': new OasHeader({
150
+ * description: 'File size in bytes',
151
+ * schema: new OasInteger({ minimum: 0 })
152
+ * })
153
+ * },
154
+ * content: {
155
+ * 'application/pdf': new OasMediaType({
156
+ * schema: new OasString({
157
+ * format: 'binary',
158
+ * description: 'PDF file content'
159
+ * })
160
+ * }),
161
+ * 'application/octet-stream': new OasMediaType({
162
+ * schema: new OasString({
163
+ * format: 'binary',
164
+ * description: 'Generic binary content'
165
+ * })
166
+ * })
167
+ * }
168
+ * });
169
+ * ```
170
+ *
171
+ * @example No content response
172
+ * ```typescript
173
+ * const noContentResponse = new OasResponse({
174
+ * description: 'Operation completed successfully, no content returned'
175
+ * // No content or headers - represents HTTP 204 No Content
176
+ * });
177
+ * ```
178
+ *
179
+ * @example Using in operation definitions
180
+ * ```typescript
181
+ * const getUserOperation = new OasOperation({
182
+ * path: '/users/{id}',
183
+ * method: 'get',
184
+ * responses: {
185
+ * '200': successResponse,
186
+ * '404': new OasResponse({
187
+ * description: 'User not found',
188
+ * content: {
189
+ * 'application/json': new OasMediaType({
190
+ * schema: new OasObject({
191
+ * properties: {
192
+ * error: new OasString({ example: 'User not found' }),
193
+ * code: new OasString({ example: 'USER_NOT_FOUND' })
194
+ * }
195
+ * })
196
+ * })
197
+ * }
198
+ * }),
199
+ * '500': new OasRef({ $ref: '#/components/responses/InternalServerError' })
200
+ * }
201
+ * });
202
+ * ```
203
+ */
14
204
  export declare class OasResponse {
15
205
  oasType: 'response';
16
206
  description: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"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