@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
@@ -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,MAAM,eAAe,CAAA;AAK9C,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,oBAAoB,CAAA;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC9B,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;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AAI,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"}
@@ -1,4 +1,148 @@
1
1
  import "../../_dnt.polyfills.js";
2
+ /**
3
+ * Represents a Parameter Object in the OpenAPI Specification.
4
+ *
5
+ * The `OasParameter` class encapsulates the definition of a single operation parameter,
6
+ * including its location, data type, validation rules, and serialization behavior.
7
+ * Parameters can be located in the path, query string, headers, or cookies.
8
+ *
9
+ * This class provides comprehensive support for parameter validation, serialization
10
+ * styles, and complex data types through schema definitions or content specifications.
11
+ *
12
+ * ## Key Features
13
+ *
14
+ * - **Location Support**: Path, query, header, and cookie parameters
15
+ * - **Schema Validation**: Comprehensive data type validation through schemas
16
+ * - **Serialization Styles**: Various parameter serialization formats
17
+ * - **Content Types**: Support for complex parameter content with media types
18
+ * - **Examples & Documentation**: Parameter examples and descriptive documentation
19
+ * - **Advanced Options**: Empty values, reserved characters, and explode behavior
20
+ *
21
+ * @example Basic path parameter
22
+ * ```typescript
23
+ * import { OasParameter, OasString } from '@skmtc/core';
24
+ *
25
+ * const userIdParam = new OasParameter({
26
+ * name: 'userId',
27
+ * location: 'path',
28
+ * description: 'Unique identifier for the user',
29
+ * required: true,
30
+ * schema: new OasString({
31
+ * pattern: '^[0-9a-f]{24}$',
32
+ * example: '507f1f77bcf86cd799439011'
33
+ * }),
34
+ * style: 'simple',
35
+ * explode: false
36
+ * });
37
+ *
38
+ * // Used in path: /users/{userId}
39
+ * ```
40
+ *
41
+ * @example Query parameter with validation
42
+ * ```typescript
43
+ * const pageSizeParam = new OasParameter({
44
+ * name: 'pageSize',
45
+ * location: 'query',
46
+ * description: 'Number of items to return per page',
47
+ * required: false,
48
+ * schema: new OasInteger({
49
+ * minimum: 1,
50
+ * maximum: 100,
51
+ * default: 20
52
+ * }),
53
+ * style: 'form',
54
+ * explode: true,
55
+ * examples: {
56
+ * small: new OasExample({ value: 10 }),
57
+ * medium: new OasExample({ value: 25 }),
58
+ * large: new OasExample({ value: 50 })
59
+ * }
60
+ * });
61
+ *
62
+ * // Used in query: ?pageSize=20
63
+ * ```
64
+ *
65
+ * @example Header parameter
66
+ * ```typescript
67
+ * const authHeaderParam = new OasParameter({
68
+ * name: 'Authorization',
69
+ * location: 'header',
70
+ * description: 'Bearer token for authentication',
71
+ * required: true,
72
+ * schema: new OasString({
73
+ * pattern: '^Bearer [A-Za-z0-9+/=]+$',
74
+ * example: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
75
+ * }),
76
+ * style: 'simple',
77
+ * explode: false
78
+ * });
79
+ * ```
80
+ *
81
+ * @example Complex parameter with content
82
+ * ```typescript
83
+ * const filterParam = new OasParameter({
84
+ * name: 'filter',
85
+ * location: 'query',
86
+ * description: 'Complex filter object',
87
+ * required: false,
88
+ * content: {
89
+ * 'application/json': new OasMediaType({
90
+ * schema: new OasObject({
91
+ * properties: {
92
+ * category: new OasString(),
93
+ * priceRange: new OasObject({
94
+ * properties: {
95
+ * min: new OasNumber(),
96
+ * max: new OasNumber()
97
+ * }
98
+ * })
99
+ * }
100
+ * })
101
+ * })
102
+ * },
103
+ * style: 'deepObject',
104
+ * explode: true
105
+ * });
106
+ *
107
+ * // Used as: ?filter[category]=electronics&filter[priceRange][min]=100
108
+ * ```
109
+ *
110
+ * @example Array parameter with explode
111
+ * ```typescript
112
+ * const tagsParam = new OasParameter({
113
+ * name: 'tags',
114
+ * location: 'query',
115
+ * description: 'Filter by multiple tags',
116
+ * required: false,
117
+ * schema: new OasArray({
118
+ * items: new OasString(),
119
+ * minItems: 1,
120
+ * maxItems: 10
121
+ * }),
122
+ * style: 'form',
123
+ * explode: true // Results in: ?tags=tech&tags=api&tags=rest
124
+ * });
125
+ *
126
+ * // Without explode: ?tags=tech,api,rest
127
+ * // With explode: ?tags=tech&tags=api&tags=rest
128
+ * ```
129
+ *
130
+ * @example Cookie parameter
131
+ * ```typescript
132
+ * const sessionParam = new OasParameter({
133
+ * name: 'sessionId',
134
+ * location: 'cookie',
135
+ * description: 'Session identifier cookie',
136
+ * required: false,
137
+ * schema: new OasString({
138
+ * minLength: 32,
139
+ * maxLength: 128
140
+ * }),
141
+ * style: 'form',
142
+ * explode: false
143
+ * });
144
+ * ```
145
+ */
2
146
  export class OasParameter {
3
147
  constructor(fields) {
4
148
  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":"Response.d.ts","sourceRoot":"","sources":["../../../src/oas/response/Response.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAA;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,CAAA;IAClD,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED,qBAAa,WAAW;IACtB,OAAO,EAAE,UAAU,CAAa;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAA;IACjE,OAAO,EAAE,MAAM,CAAC,MAA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,EAAE,OAAO,CAAC,CAAA;CAC1C,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsLG;AACH,qBAAa,WAAW;IACtB,OAAO,EAAE,UAAU,CAAa;IAChC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAA;IACjE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,CAAA;IACjD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;gBACxC,MAAM,EAAE,cAAc;IAOlC,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC;IAInC,OAAO,IAAI,WAAW;IAItB,WAAW,IAAI,WAAW;IAI1B,QAAQ,CAAC,SAAS,GAAE,MAA2B,GAAG,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAI1F,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC,cAAc;CAqBrE"}
@@ -1,4 +1,187 @@
1
1
  import "../../_dnt.polyfills.js";
2
+ /**
3
+ * Represents a Response Object in the OpenAPI Specification.
4
+ *
5
+ * The `OasResponse` class encapsulates the definition of a single HTTP response,
6
+ * including its description, headers, and content for different media types.
7
+ * Responses describe the possible outcomes of API operations and can include
8
+ * both successful and error scenarios.
9
+ *
10
+ * This class provides comprehensive support for response definitions with typed
11
+ * content, custom headers, and multiple media type representations.
12
+ *
13
+ * ## Key Features
14
+ *
15
+ * - **Content Types**: Support for multiple media types (JSON, XML, HTML, etc.)
16
+ * - **Header Definitions**: Custom response headers with validation
17
+ * - **Schema Integration**: Typed response bodies through schema definitions
18
+ * - **Reference Support**: Can reference reusable response components
19
+ * - **Documentation**: Rich description support for API documentation
20
+ * - **JSON Schema**: Converts to standard JSON Schema format for validation
21
+ *
22
+ * @example Basic JSON response
23
+ * ```typescript
24
+ * import { OasResponse, OasMediaType, OasObject, OasString } from '@skmtc/core';
25
+ *
26
+ * const successResponse = new OasResponse({
27
+ * description: 'User retrieved successfully',
28
+ * content: {
29
+ * 'application/json': new OasMediaType({
30
+ * schema: new OasObject({
31
+ * properties: {
32
+ * id: new OasString(),
33
+ * name: new OasString(),
34
+ * email: new OasString({ format: 'email' })
35
+ * }
36
+ * })
37
+ * })
38
+ * }
39
+ * });
40
+ * ```
41
+ *
42
+ * @example Response with custom headers
43
+ * ```typescript
44
+ * const paginatedResponse = new OasResponse({
45
+ * description: 'Paginated list of items',
46
+ * headers: {
47
+ * 'X-Total-Count': new OasHeader({
48
+ * description: 'Total number of items',
49
+ * schema: new OasInteger({ minimum: 0 })
50
+ * }),
51
+ * 'X-Page-Number': new OasHeader({
52
+ * description: 'Current page number',
53
+ * schema: new OasInteger({ minimum: 1 })
54
+ * }),
55
+ * 'Link': new OasHeader({
56
+ * description: 'Pagination links',
57
+ * schema: new OasString()
58
+ * })
59
+ * },
60
+ * content: {
61
+ * 'application/json': new OasMediaType({
62
+ * schema: new OasArray({
63
+ * items: new OasRef({ $ref: '#/components/schemas/Item' })
64
+ * })
65
+ * })
66
+ * }
67
+ * });
68
+ * ```
69
+ *
70
+ * @example Multiple content types
71
+ * ```typescript
72
+ * const multiFormatResponse = new OasResponse({
73
+ * description: 'User data in multiple formats',
74
+ * content: {
75
+ * 'application/json': new OasMediaType({
76
+ * schema: new OasRef({ $ref: '#/components/schemas/User' })
77
+ * }),
78
+ * 'application/xml': new OasMediaType({
79
+ * schema: new OasObject({
80
+ * // XML-specific schema definition
81
+ * properties: {
82
+ * user: new OasRef({ $ref: '#/components/schemas/User' })
83
+ * }
84
+ * })
85
+ * }),
86
+ * 'text/csv': new OasMediaType({
87
+ * schema: new OasString({
88
+ * description: 'User data in CSV format'
89
+ * })
90
+ * })
91
+ * }
92
+ * });
93
+ * ```
94
+ *
95
+ * @example Error responses
96
+ * ```typescript
97
+ * const errorResponse = new OasResponse({
98
+ * description: 'Validation error occurred',
99
+ * content: {
100
+ * 'application/json': new OasMediaType({
101
+ * schema: new OasObject({
102
+ * properties: {
103
+ * error: new OasString({ description: 'Error message' }),
104
+ * code: new OasString({ description: 'Error code' }),
105
+ * details: new OasArray({
106
+ * items: new OasObject({
107
+ * properties: {
108
+ * field: new OasString(),
109
+ * message: new OasString()
110
+ * }
111
+ * })
112
+ * })
113
+ * },
114
+ * required: ['error', 'code']
115
+ * })
116
+ * })
117
+ * }
118
+ * });
119
+ * ```
120
+ *
121
+ * @example File download response
122
+ * ```typescript
123
+ * const fileDownloadResponse = new OasResponse({
124
+ * description: 'File download',
125
+ * headers: {
126
+ * 'Content-Disposition': new OasHeader({
127
+ * description: 'Attachment filename',
128
+ * schema: new OasString({ example: 'attachment; filename="report.pdf"' })
129
+ * }),
130
+ * 'Content-Length': new OasHeader({
131
+ * description: 'File size in bytes',
132
+ * schema: new OasInteger({ minimum: 0 })
133
+ * })
134
+ * },
135
+ * content: {
136
+ * 'application/pdf': new OasMediaType({
137
+ * schema: new OasString({
138
+ * format: 'binary',
139
+ * description: 'PDF file content'
140
+ * })
141
+ * }),
142
+ * 'application/octet-stream': new OasMediaType({
143
+ * schema: new OasString({
144
+ * format: 'binary',
145
+ * description: 'Generic binary content'
146
+ * })
147
+ * })
148
+ * }
149
+ * });
150
+ * ```
151
+ *
152
+ * @example No content response
153
+ * ```typescript
154
+ * const noContentResponse = new OasResponse({
155
+ * description: 'Operation completed successfully, no content returned'
156
+ * // No content or headers - represents HTTP 204 No Content
157
+ * });
158
+ * ```
159
+ *
160
+ * @example Using in operation definitions
161
+ * ```typescript
162
+ * const getUserOperation = new OasOperation({
163
+ * path: '/users/{id}',
164
+ * method: 'get',
165
+ * responses: {
166
+ * '200': successResponse,
167
+ * '404': new OasResponse({
168
+ * description: 'User not found',
169
+ * content: {
170
+ * 'application/json': new OasMediaType({
171
+ * schema: new OasObject({
172
+ * properties: {
173
+ * error: new OasString({ example: 'User not found' }),
174
+ * code: new OasString({ example: 'USER_NOT_FOUND' })
175
+ * }
176
+ * })
177
+ * })
178
+ * }
179
+ * }),
180
+ * '500': new OasRef({ $ref: '#/components/responses/InternalServerError' })
181
+ * }
182
+ * });
183
+ * ```
184
+ */
2
185
  export class OasResponse {
3
186
  constructor(fields) {
4
187
  Object.defineProperty(this, "oasType", {
@@ -1,13 +1,140 @@
1
1
  import "../../_dnt.polyfills.js";
2
2
  import type { OasRef } from '../ref/Ref.js';
3
+ /**
4
+ * Constructor fields for {@link OasVoid}.
5
+ */
3
6
  export type VoidFields = {
7
+ /** A short summary of the void schema */
4
8
  title?: string;
9
+ /** A description of what the void represents */
5
10
  description?: string;
6
11
  };
7
12
  /**
8
- * Object representing a void type in the OpenAPI Specification.
9
- * It is used to describe an absence of a value such as when no
10
- * content is returned by an operation.
13
+ * Represents a void (empty) schema in the OpenAPI Specification.
14
+ *
15
+ * The `OasVoid` class represents the absence of a value or content, commonly used
16
+ * in scenarios where operations don't return any content (like HTTP 204 No Content
17
+ * responses), optional properties that might not be present, or fallback cases
18
+ * in schema processing where no specific type is defined.
19
+ *
20
+ * This class serves as a type-safe representation of "nothing" in the OpenAPI
21
+ * type system, enabling proper handling of void responses and empty schemas
22
+ * throughout the SKMTC pipeline.
23
+ *
24
+ * ## Key Features
25
+ *
26
+ * - **Empty Content Representation**: Models operations that return no content
27
+ * - **Type Safety**: Provides a concrete type for void/empty scenarios
28
+ * - **Schema Processing**: Handles missing or undefined schema definitions
29
+ * - **Factory Pattern**: Convenient `empty()` static method for common usage
30
+ * - **Pipeline Integration**: Works seamlessly with the SKMTC processing pipeline
31
+ *
32
+ * @example Basic void schema for empty responses
33
+ * ```typescript
34
+ * import { OasVoid } from '@skmtc/core';
35
+ *
36
+ * const emptyResponse = new OasVoid({
37
+ * title: 'No Content',
38
+ * description: 'Operation completed successfully with no response body'
39
+ * });
40
+ *
41
+ * // Used for HTTP 204 No Content responses
42
+ * ```
43
+ *
44
+ * @example Using the empty factory method
45
+ * ```typescript
46
+ * const voidSchema = OasVoid.empty();
47
+ *
48
+ * // Equivalent to new OasVoid({})
49
+ * // Commonly used as a fallback or placeholder
50
+ * ```
51
+ *
52
+ * @example In operation responses
53
+ * ```typescript
54
+ * const deleteOperation = new OasOperation({
55
+ * path: '/users/{id}',
56
+ * method: 'delete',
57
+ * responses: {
58
+ * '204': new OasResponse({
59
+ * description: 'User deleted successfully',
60
+ * content: {
61
+ * // No content for successful deletion
62
+ * }
63
+ * }),
64
+ * '404': new OasResponse({
65
+ * description: 'User not found'
66
+ * })
67
+ * }
68
+ * });
69
+ *
70
+ * // The void response indicates successful deletion with no return value
71
+ * ```
72
+ *
73
+ * @example As a schema fallback
74
+ * ```typescript
75
+ * function processSchema(schema: OasSchema | undefined): OasSchema {
76
+ * if (!schema) {
77
+ * return OasVoid.empty(); // Fallback for missing schemas
78
+ * }
79
+ * return schema;
80
+ * }
81
+ *
82
+ * // Ensures type safety even when schemas are missing
83
+ * ```
84
+ *
85
+ * @example In optional object properties
86
+ * ```typescript
87
+ * const userProfile = new OasObject({
88
+ * properties: {
89
+ * name: new OasString({ description: 'User name' }),
90
+ * avatar: new OasString({
91
+ * description: 'Avatar URL',
92
+ * nullable: true
93
+ * }),
94
+ * // Some properties might be processed as void if not defined
95
+ * metadata: processOptionalSchema(rawSchema.metadata) // might return OasVoid
96
+ * }
97
+ * });
98
+ * ```
99
+ *
100
+ * @example HTTP operations with void responses
101
+ * ```typescript
102
+ * // Common HTTP operations that return void/empty content:
103
+ *
104
+ * // DELETE - Resource removal
105
+ * const deleteResponse = new OasVoid({
106
+ * title: 'Deletion Successful',
107
+ * description: 'Resource was successfully deleted'
108
+ * });
109
+ *
110
+ * // PUT - Update with no response body
111
+ * const updateResponse = new OasVoid({
112
+ * title: 'Update Successful',
113
+ * description: 'Resource was successfully updated'
114
+ * });
115
+ *
116
+ * // POST - Action with no return value
117
+ * const actionResponse = new OasVoid({
118
+ * title: 'Action Completed',
119
+ * description: 'Action was successfully performed'
120
+ * });
121
+ * ```
122
+ *
123
+ * @example In code generation
124
+ * ```typescript
125
+ * class TypeScriptGenerator extends ModelBase {
126
+ * generateType(schema: OasSchema): string {
127
+ * if (schema.type === 'void') {
128
+ * return 'void'; // TypeScript void type
129
+ * }
130
+ * // Handle other types...
131
+ * return 'unknown';
132
+ * }
133
+ * }
134
+ *
135
+ * // Generates:
136
+ * // async function deleteUser(id: string): Promise<void>
137
+ * ```
11
138
  */
12
139
  export declare class OasVoid {
13
140
  /**