@skmtc/core 0.0.790 → 0.0.792

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 (61) hide show
  1. package/esm/helpers/naming.d.ts +65 -1
  2. package/esm/helpers/naming.d.ts.map +1 -1
  3. package/esm/helpers/naming.js +65 -1
  4. package/esm/oas/example/Example.d.ts +81 -1
  5. package/esm/oas/example/Example.d.ts.map +1 -1
  6. package/esm/oas/example/Example.js +74 -1
  7. package/esm/oas/header/Header.d.ts +217 -1
  8. package/esm/oas/header/Header.d.ts.map +1 -1
  9. package/esm/oas/header/Header.js +207 -1
  10. package/esm/oas/info/Info.d.ts +72 -0
  11. package/esm/oas/info/Info.d.ts.map +1 -1
  12. package/esm/oas/info/Info.js +62 -0
  13. package/esm/oas/mediaType/MediaType.d.ts +85 -0
  14. package/esm/oas/mediaType/MediaType.d.ts.map +1 -1
  15. package/esm/oas/mediaType/MediaType.js +77 -0
  16. package/esm/oas/number/Number.d.ts +179 -1
  17. package/esm/oas/number/Number.d.ts.map +1 -1
  18. package/esm/oas/number/Number.js +161 -1
  19. package/esm/oas/pathItem/PathItem.d.ts +92 -0
  20. package/esm/oas/pathItem/PathItem.d.ts.map +1 -1
  21. package/esm/oas/pathItem/PathItem.js +85 -0
  22. package/esm/oas/requestBody/RequestBody.d.ts +264 -0
  23. package/esm/oas/requestBody/RequestBody.d.ts.map +1 -1
  24. package/esm/oas/requestBody/RequestBody.js +257 -0
  25. package/esm/oas/response/Response.d.ts +190 -0
  26. package/esm/oas/response/Response.d.ts.map +1 -1
  27. package/esm/oas/response/Response.js +183 -0
  28. package/esm/oas/void/Void.d.ts +130 -3
  29. package/esm/oas/void/Void.d.ts.map +1 -1
  30. package/esm/oas/void/Void.js +125 -3
  31. package/package.json +1 -1
  32. package/script/helpers/naming.d.ts +65 -1
  33. package/script/helpers/naming.d.ts.map +1 -1
  34. package/script/helpers/naming.js +65 -1
  35. package/script/oas/example/Example.d.ts +81 -1
  36. package/script/oas/example/Example.d.ts.map +1 -1
  37. package/script/oas/example/Example.js +74 -1
  38. package/script/oas/header/Header.d.ts +217 -1
  39. package/script/oas/header/Header.d.ts.map +1 -1
  40. package/script/oas/header/Header.js +207 -1
  41. package/script/oas/info/Info.d.ts +72 -0
  42. package/script/oas/info/Info.d.ts.map +1 -1
  43. package/script/oas/info/Info.js +62 -0
  44. package/script/oas/mediaType/MediaType.d.ts +85 -0
  45. package/script/oas/mediaType/MediaType.d.ts.map +1 -1
  46. package/script/oas/mediaType/MediaType.js +77 -0
  47. package/script/oas/number/Number.d.ts +179 -1
  48. package/script/oas/number/Number.d.ts.map +1 -1
  49. package/script/oas/number/Number.js +161 -1
  50. package/script/oas/pathItem/PathItem.d.ts +92 -0
  51. package/script/oas/pathItem/PathItem.d.ts.map +1 -1
  52. package/script/oas/pathItem/PathItem.js +85 -0
  53. package/script/oas/requestBody/RequestBody.d.ts +264 -0
  54. package/script/oas/requestBody/RequestBody.d.ts.map +1 -1
  55. package/script/oas/requestBody/RequestBody.js +257 -0
  56. package/script/oas/response/Response.d.ts +190 -0
  57. package/script/oas/response/Response.d.ts.map +1 -1
  58. package/script/oas/response/Response.js +183 -0
  59. package/script/oas/void/Void.d.ts +130 -3
  60. package/script/oas/void/Void.d.ts.map +1 -1
  61. package/script/oas/void/Void.js +125 -3
@@ -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,E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AAW;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"}
@@ -2,6 +2,189 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OasResponse = void 0;
4
4
  require("../../_dnt.polyfills.js");
5
+ /**
6
+ * Represents a Response Object in the OpenAPI Specification.
7
+ *
8
+ * The `OasResponse` class encapsulates the definition of a single HTTP response,
9
+ * including its description, headers, and content for different media types.
10
+ * Responses describe the possible outcomes of API operations and can include
11
+ * both successful and error scenarios.
12
+ *
13
+ * This class provides comprehensive support for response definitions with typed
14
+ * content, custom headers, and multiple media type representations.
15
+ *
16
+ * ## Key Features
17
+ *
18
+ * - **Content Types**: Support for multiple media types (JSON, XML, HTML, etc.)
19
+ * - **Header Definitions**: Custom response headers with validation
20
+ * - **Schema Integration**: Typed response bodies through schema definitions
21
+ * - **Reference Support**: Can reference reusable response components
22
+ * - **Documentation**: Rich description support for API documentation
23
+ * - **JSON Schema**: Converts to standard JSON Schema format for validation
24
+ *
25
+ * @example Basic JSON response
26
+ * ```typescript
27
+ * import { OasResponse, OasMediaType, OasObject, OasString } from '@skmtc/core';
28
+ *
29
+ * const successResponse = new OasResponse({
30
+ * description: 'User retrieved successfully',
31
+ * content: {
32
+ * 'application/json': new OasMediaType({
33
+ * schema: new OasObject({
34
+ * properties: {
35
+ * id: new OasString(),
36
+ * name: new OasString(),
37
+ * email: new OasString({ format: 'email' })
38
+ * }
39
+ * })
40
+ * })
41
+ * }
42
+ * });
43
+ * ```
44
+ *
45
+ * @example Response with custom headers
46
+ * ```typescript
47
+ * const paginatedResponse = new OasResponse({
48
+ * description: 'Paginated list of items',
49
+ * headers: {
50
+ * 'X-Total-Count': new OasHeader({
51
+ * description: 'Total number of items',
52
+ * schema: new OasInteger({ minimum: 0 })
53
+ * }),
54
+ * 'X-Page-Number': new OasHeader({
55
+ * description: 'Current page number',
56
+ * schema: new OasInteger({ minimum: 1 })
57
+ * }),
58
+ * 'Link': new OasHeader({
59
+ * description: 'Pagination links',
60
+ * schema: new OasString()
61
+ * })
62
+ * },
63
+ * content: {
64
+ * 'application/json': new OasMediaType({
65
+ * schema: new OasArray({
66
+ * items: new OasRef({ $ref: '#/components/schemas/Item' })
67
+ * })
68
+ * })
69
+ * }
70
+ * });
71
+ * ```
72
+ *
73
+ * @example Multiple content types
74
+ * ```typescript
75
+ * const multiFormatResponse = new OasResponse({
76
+ * description: 'User data in multiple formats',
77
+ * content: {
78
+ * 'application/json': new OasMediaType({
79
+ * schema: new OasRef({ $ref: '#/components/schemas/User' })
80
+ * }),
81
+ * 'application/xml': new OasMediaType({
82
+ * schema: new OasObject({
83
+ * // XML-specific schema definition
84
+ * properties: {
85
+ * user: new OasRef({ $ref: '#/components/schemas/User' })
86
+ * }
87
+ * })
88
+ * }),
89
+ * 'text/csv': new OasMediaType({
90
+ * schema: new OasString({
91
+ * description: 'User data in CSV format'
92
+ * })
93
+ * })
94
+ * }
95
+ * });
96
+ * ```
97
+ *
98
+ * @example Error responses
99
+ * ```typescript
100
+ * const errorResponse = new OasResponse({
101
+ * description: 'Validation error occurred',
102
+ * content: {
103
+ * 'application/json': new OasMediaType({
104
+ * schema: new OasObject({
105
+ * properties: {
106
+ * error: new OasString({ description: 'Error message' }),
107
+ * code: new OasString({ description: 'Error code' }),
108
+ * details: new OasArray({
109
+ * items: new OasObject({
110
+ * properties: {
111
+ * field: new OasString(),
112
+ * message: new OasString()
113
+ * }
114
+ * })
115
+ * })
116
+ * },
117
+ * required: ['error', 'code']
118
+ * })
119
+ * })
120
+ * }
121
+ * });
122
+ * ```
123
+ *
124
+ * @example File download response
125
+ * ```typescript
126
+ * const fileDownloadResponse = new OasResponse({
127
+ * description: 'File download',
128
+ * headers: {
129
+ * 'Content-Disposition': new OasHeader({
130
+ * description: 'Attachment filename',
131
+ * schema: new OasString({ example: 'attachment; filename="report.pdf"' })
132
+ * }),
133
+ * 'Content-Length': new OasHeader({
134
+ * description: 'File size in bytes',
135
+ * schema: new OasInteger({ minimum: 0 })
136
+ * })
137
+ * },
138
+ * content: {
139
+ * 'application/pdf': new OasMediaType({
140
+ * schema: new OasString({
141
+ * format: 'binary',
142
+ * description: 'PDF file content'
143
+ * })
144
+ * }),
145
+ * 'application/octet-stream': new OasMediaType({
146
+ * schema: new OasString({
147
+ * format: 'binary',
148
+ * description: 'Generic binary content'
149
+ * })
150
+ * })
151
+ * }
152
+ * });
153
+ * ```
154
+ *
155
+ * @example No content response
156
+ * ```typescript
157
+ * const noContentResponse = new OasResponse({
158
+ * description: 'Operation completed successfully, no content returned'
159
+ * // No content or headers - represents HTTP 204 No Content
160
+ * });
161
+ * ```
162
+ *
163
+ * @example Using in operation definitions
164
+ * ```typescript
165
+ * const getUserOperation = new OasOperation({
166
+ * path: '/users/{id}',
167
+ * method: 'get',
168
+ * responses: {
169
+ * '200': successResponse,
170
+ * '404': new OasResponse({
171
+ * description: 'User not found',
172
+ * content: {
173
+ * 'application/json': new OasMediaType({
174
+ * schema: new OasObject({
175
+ * properties: {
176
+ * error: new OasString({ example: 'User not found' }),
177
+ * code: new OasString({ example: 'USER_NOT_FOUND' })
178
+ * }
179
+ * })
180
+ * })
181
+ * }
182
+ * }),
183
+ * '500': new OasRef({ $ref: '#/components/responses/InternalServerError' })
184
+ * }
185
+ * });
186
+ * ```
187
+ */
5
188
  class OasResponse {
6
189
  constructor(fields) {
7
190
  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
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Void.d.ts","sourceRoot":"","sources":["../../../src/oas/void/Void.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAA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GAAG,SAAS,CAAA;gBAEnB,MAAM,GAAE,UAAe;IAKnC,MAAM,CAAC,KAAK,IAAI,OAAO;IAIvB,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,OAAO;IAIlB,WAAW,IAAI,OAAO;CAGvB"}
@@ -3,9 +3,131 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OasVoid = void 0;
4
4
  require("../../_dnt.polyfills.js");
5
5
  /**
6
- * Object representing a void type in the OpenAPI Specification.
7
- * It is used to describe an absence of a value such as when no
8
- * content is returned by an operation.
6
+ * Represents a void (empty) schema in the OpenAPI Specification.
7
+ *
8
+ * The `OasVoid` class represents the absence of a value or content, commonly used
9
+ * in scenarios where operations don't return any content (like HTTP 204 No Content
10
+ * responses), optional properties that might not be present, or fallback cases
11
+ * in schema processing where no specific type is defined.
12
+ *
13
+ * This class serves as a type-safe representation of "nothing" in the OpenAPI
14
+ * type system, enabling proper handling of void responses and empty schemas
15
+ * throughout the SKMTC pipeline.
16
+ *
17
+ * ## Key Features
18
+ *
19
+ * - **Empty Content Representation**: Models operations that return no content
20
+ * - **Type Safety**: Provides a concrete type for void/empty scenarios
21
+ * - **Schema Processing**: Handles missing or undefined schema definitions
22
+ * - **Factory Pattern**: Convenient `empty()` static method for common usage
23
+ * - **Pipeline Integration**: Works seamlessly with the SKMTC processing pipeline
24
+ *
25
+ * @example Basic void schema for empty responses
26
+ * ```typescript
27
+ * import { OasVoid } from '@skmtc/core';
28
+ *
29
+ * const emptyResponse = new OasVoid({
30
+ * title: 'No Content',
31
+ * description: 'Operation completed successfully with no response body'
32
+ * });
33
+ *
34
+ * // Used for HTTP 204 No Content responses
35
+ * ```
36
+ *
37
+ * @example Using the empty factory method
38
+ * ```typescript
39
+ * const voidSchema = OasVoid.empty();
40
+ *
41
+ * // Equivalent to new OasVoid({})
42
+ * // Commonly used as a fallback or placeholder
43
+ * ```
44
+ *
45
+ * @example In operation responses
46
+ * ```typescript
47
+ * const deleteOperation = new OasOperation({
48
+ * path: '/users/{id}',
49
+ * method: 'delete',
50
+ * responses: {
51
+ * '204': new OasResponse({
52
+ * description: 'User deleted successfully',
53
+ * content: {
54
+ * // No content for successful deletion
55
+ * }
56
+ * }),
57
+ * '404': new OasResponse({
58
+ * description: 'User not found'
59
+ * })
60
+ * }
61
+ * });
62
+ *
63
+ * // The void response indicates successful deletion with no return value
64
+ * ```
65
+ *
66
+ * @example As a schema fallback
67
+ * ```typescript
68
+ * function processSchema(schema: OasSchema | undefined): OasSchema {
69
+ * if (!schema) {
70
+ * return OasVoid.empty(); // Fallback for missing schemas
71
+ * }
72
+ * return schema;
73
+ * }
74
+ *
75
+ * // Ensures type safety even when schemas are missing
76
+ * ```
77
+ *
78
+ * @example In optional object properties
79
+ * ```typescript
80
+ * const userProfile = new OasObject({
81
+ * properties: {
82
+ * name: new OasString({ description: 'User name' }),
83
+ * avatar: new OasString({
84
+ * description: 'Avatar URL',
85
+ * nullable: true
86
+ * }),
87
+ * // Some properties might be processed as void if not defined
88
+ * metadata: processOptionalSchema(rawSchema.metadata) // might return OasVoid
89
+ * }
90
+ * });
91
+ * ```
92
+ *
93
+ * @example HTTP operations with void responses
94
+ * ```typescript
95
+ * // Common HTTP operations that return void/empty content:
96
+ *
97
+ * // DELETE - Resource removal
98
+ * const deleteResponse = new OasVoid({
99
+ * title: 'Deletion Successful',
100
+ * description: 'Resource was successfully deleted'
101
+ * });
102
+ *
103
+ * // PUT - Update with no response body
104
+ * const updateResponse = new OasVoid({
105
+ * title: 'Update Successful',
106
+ * description: 'Resource was successfully updated'
107
+ * });
108
+ *
109
+ * // POST - Action with no return value
110
+ * const actionResponse = new OasVoid({
111
+ * title: 'Action Completed',
112
+ * description: 'Action was successfully performed'
113
+ * });
114
+ * ```
115
+ *
116
+ * @example In code generation
117
+ * ```typescript
118
+ * class TypeScriptGenerator extends ModelBase {
119
+ * generateType(schema: OasSchema): string {
120
+ * if (schema.type === 'void') {
121
+ * return 'void'; // TypeScript void type
122
+ * }
123
+ * // Handle other types...
124
+ * return 'unknown';
125
+ * }
126
+ * }
127
+ *
128
+ * // Generates:
129
+ * // async function deleteUser(id: string): Promise<void>
130
+ * ```
9
131
  */
10
132
  class OasVoid {
11
133
  constructor(fields = {}) {