@skmtc/core 0.0.808 → 0.0.810

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 (73) hide show
  1. package/esm/context/types.d.ts +0 -8
  2. package/esm/context/types.d.ts.map +1 -1
  3. package/esm/dsl/model/toModelBase.d.ts +24 -2
  4. package/esm/dsl/model/toModelBase.d.ts.map +1 -1
  5. package/esm/dsl/model/types.d.ts +2 -2
  6. package/esm/dsl/operation/toOperationBase.d.ts +26 -3
  7. package/esm/dsl/operation/toOperationBase.d.ts.map +1 -1
  8. package/esm/dsl/operation/types.d.ts +2 -2
  9. package/esm/oas/array/array-types.d.ts +238 -25
  10. package/esm/oas/array/array-types.d.ts.map +1 -1
  11. package/esm/oas/array/array-types.js +97 -5
  12. package/esm/oas/boolean/boolean-types.d.ts +81 -9
  13. package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
  14. package/esm/oas/boolean/boolean-types.js +32 -2
  15. package/esm/oas/contact/contact-types.d.ts +176 -0
  16. package/esm/oas/contact/contact-types.d.ts.map +1 -1
  17. package/esm/oas/contact/contact-types.js +102 -0
  18. package/esm/oas/header/Header.d.ts +8 -185
  19. package/esm/oas/header/Header.d.ts.map +1 -1
  20. package/esm/oas/header/Header.js +57 -220
  21. package/esm/oas/mediaType/toMediaTypeItemV3.d.ts +288 -0
  22. package/esm/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
  23. package/esm/oas/mediaType/toMediaTypeItemV3.js +272 -0
  24. package/esm/oas/operation/operation-types.d.ts +251 -0
  25. package/esm/oas/operation/operation-types.d.ts.map +1 -1
  26. package/esm/oas/operation/operation-types.js +98 -0
  27. package/esm/oas/string/string-types.d.ts +192 -18
  28. package/esm/oas/string/string-types.d.ts.map +1 -1
  29. package/esm/oas/string/string-types.js +76 -4
  30. package/esm/types/ModuleExport.d.ts +130 -0
  31. package/esm/types/ModuleExport.d.ts.map +1 -1
  32. package/esm/types/ModuleExport.js +36 -0
  33. package/esm/typescript/List.d.ts +2 -2
  34. package/esm/typescript/List.d.ts.map +1 -1
  35. package/esm/typescript/List.js +4 -4
  36. package/esm/typescript/toPathTemplate.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/script/context/types.d.ts +0 -8
  39. package/script/context/types.d.ts.map +1 -1
  40. package/script/dsl/model/toModelBase.d.ts +24 -2
  41. package/script/dsl/model/toModelBase.d.ts.map +1 -1
  42. package/script/dsl/model/types.d.ts +2 -2
  43. package/script/dsl/operation/toOperationBase.d.ts +26 -3
  44. package/script/dsl/operation/toOperationBase.d.ts.map +1 -1
  45. package/script/dsl/operation/types.d.ts +2 -2
  46. package/script/oas/array/array-types.d.ts +238 -25
  47. package/script/oas/array/array-types.d.ts.map +1 -1
  48. package/script/oas/array/array-types.js +97 -5
  49. package/script/oas/boolean/boolean-types.d.ts +81 -9
  50. package/script/oas/boolean/boolean-types.d.ts.map +1 -1
  51. package/script/oas/boolean/boolean-types.js +32 -2
  52. package/script/oas/contact/contact-types.d.ts +176 -0
  53. package/script/oas/contact/contact-types.d.ts.map +1 -1
  54. package/script/oas/contact/contact-types.js +102 -0
  55. package/script/oas/header/Header.d.ts +8 -185
  56. package/script/oas/header/Header.d.ts.map +1 -1
  57. package/script/oas/header/Header.js +57 -220
  58. package/script/oas/mediaType/toMediaTypeItemV3.d.ts +288 -0
  59. package/script/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
  60. package/script/oas/mediaType/toMediaTypeItemV3.js +272 -0
  61. package/script/oas/operation/operation-types.d.ts +251 -0
  62. package/script/oas/operation/operation-types.d.ts.map +1 -1
  63. package/script/oas/operation/operation-types.js +98 -0
  64. package/script/oas/string/string-types.d.ts +192 -18
  65. package/script/oas/string/string-types.d.ts.map +1 -1
  66. package/script/oas/string/string-types.js +76 -4
  67. package/script/types/ModuleExport.d.ts +130 -0
  68. package/script/types/ModuleExport.d.ts.map +1 -1
  69. package/script/types/ModuleExport.js +36 -0
  70. package/script/typescript/List.d.ts +2 -2
  71. package/script/typescript/List.d.ts.map +1 -1
  72. package/script/typescript/List.js +4 -4
  73. package/script/typescript/toPathTemplate.d.ts.map +1 -1
@@ -1,15 +1,3 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _OasHeader_fields;
13
1
  /**
14
2
  * Represents a Header Object in the OpenAPI Specification.
15
3
  *
@@ -21,15 +9,6 @@ var _OasHeader_fields;
21
9
  * This class provides comprehensive support for header definitions with typed
22
10
  * values, validation schemas, examples, and documentation.
23
11
  *
24
- * ## Key Features
25
- *
26
- * - **Schema Validation**: Typed header values through schema definitions
27
- * - **Examples**: Multiple example values for documentation and testing
28
- * - **Content Types**: Support for complex header values with media types
29
- * - **Deprecation Support**: Mark headers as deprecated with proper warnings
30
- * - **Required/Optional**: Control whether headers are mandatory
31
- * - **Documentation**: Rich description support for API documentation
32
- *
33
12
  * @example Basic authentication header
34
13
  * ```typescript
35
14
  * import { OasHeader, OasString } from '@skmtc/core';
@@ -49,173 +28,6 @@ var _OasHeader_fields;
49
28
  * }
50
29
  * });
51
30
  * ```
52
- *
53
- * @example Pagination headers
54
- * ```typescript
55
- * const totalCountHeader = new OasHeader({
56
- * description: 'Total number of items available',
57
- * required: false,
58
- * schema: new OasInteger({
59
- * minimum: 0,
60
- * description: 'Non-negative integer count'
61
- * }),
62
- * examples: {
63
- * empty: new OasExample({ value: 0, description: 'No items' }),
64
- * normal: new OasExample({ value: 150, description: 'Normal case' }),
65
- * large: new OasExample({ value: 10000, description: 'Large dataset' })
66
- * }
67
- * });
68
- *
69
- * const linkHeader = new OasHeader({
70
- * description: 'Pagination links (RFC 5988)',
71
- * required: false,
72
- * schema: new OasString({
73
- * description: 'Comma-separated list of link relations'
74
- * }),
75
- * examples: {
76
- * withNext: new OasExample({
77
- * value: '</api/users?page=2>; rel="next", </api/users?page=10>; rel="last"'
78
- * }),
79
- * lastPage: new OasExample({
80
- * value: '</api/users?page=9>; rel="prev", </api/users?page=1>; rel="first"'
81
- * })
82
- * }
83
- * });
84
- * ```
85
- *
86
- * @example Content type and encoding headers
87
- * ```typescript
88
- * const contentTypeHeader = new OasHeader({
89
- * description: 'MIME type of the response content',
90
- * required: true,
91
- * schema: new OasString({
92
- * enum: [
93
- * 'application/json',
94
- * 'application/xml',
95
- * 'text/csv',
96
- * 'application/pdf',
97
- * 'application/octet-stream'
98
- * ]
99
- * }),
100
- * examples: {
101
- * json: new OasExample({ value: 'application/json' }),
102
- * xml: new OasExample({ value: 'application/xml' }),
103
- * csv: new OasExample({ value: 'text/csv' })
104
- * }
105
- * });
106
- *
107
- * const contentLengthHeader = new OasHeader({
108
- * description: 'Size of the response body in bytes',
109
- * required: false,
110
- * schema: new OasInteger({
111
- * minimum: 0,
112
- * description: 'Content size in bytes'
113
- * })
114
- * });
115
- * ```
116
- *
117
- * @example Rate limiting headers
118
- * ```typescript
119
- * const rateLimitHeader = new OasHeader({
120
- * description: 'Number of requests remaining in the current window',
121
- * required: false,
122
- * schema: new OasInteger({
123
- * minimum: 0,
124
- * description: 'Remaining request count'
125
- * }),
126
- * examples: {
127
- * available: new OasExample({ value: 95, description: '95 requests remaining' }),
128
- * depleted: new OasExample({ value: 0, description: 'Rate limit reached' })
129
- * }
130
- * });
131
- *
132
- * const rateLimitResetHeader = new OasHeader({
133
- * description: 'Unix timestamp when the rate limit window resets',
134
- * required: false,
135
- * schema: new OasInteger({
136
- * minimum: 0,
137
- * description: 'Unix timestamp in seconds'
138
- * }),
139
- * examples: {
140
- * reset: new OasExample({
141
- * value: 1634567890,
142
- * description: 'Reset at 2021-10-18 12:31:30 UTC'
143
- * })
144
- * }
145
- * });
146
- * ```
147
- *
148
- * @example Custom application headers
149
- * ```typescript
150
- * const requestIdHeader = new OasHeader({
151
- * description: 'Unique identifier for request tracing',
152
- * required: false,
153
- * schema: new OasString({
154
- * format: 'uuid',
155
- * description: 'UUID v4 request identifier'
156
- * }),
157
- * examples: {
158
- * uuid: new OasExample({
159
- * value: '123e4567-e89b-12d3-a456-426614174000',
160
- * description: 'Request tracking ID'
161
- * })
162
- * }
163
- * });
164
- *
165
- * const serverTimingHeader = new OasHeader({
166
- * description: 'Server-side performance metrics',
167
- * required: false,
168
- * schema: new OasString({
169
- * description: 'Server-Timing header format (RFC 8760)'
170
- * }),
171
- * examples: {
172
- * timing: new OasExample({
173
- * value: 'db;dur=53, app;dur=47.2',
174
- * description: 'Database took 53ms, app logic 47.2ms'
175
- * })
176
- * }
177
- * });
178
- * ```
179
- *
180
- * @example Deprecated header
181
- * ```typescript
182
- * const deprecatedHeader = new OasHeader({
183
- * description: 'Legacy API version header (deprecated)',
184
- * required: false,
185
- * deprecated: true,
186
- * schema: new OasString({
187
- * enum: ['v1', 'v2'],
188
- * description: 'Use Accept or Content-Type header instead'
189
- * }),
190
- * examples: {
191
- * legacy: new OasExample({
192
- * value: 'v1',
193
- * description: 'Legacy version (use Accept header instead)'
194
- * })
195
- * }
196
- * });
197
- * ```
198
- *
199
- * @example Using in response definitions
200
- * ```typescript
201
- * const successResponse = new OasResponse({
202
- * description: 'Paginated user list',
203
- * headers: {
204
- * 'X-Total-Count': totalCountHeader,
205
- * 'Link': linkHeader,
206
- * 'X-Rate-Limit-Remaining': rateLimitHeader,
207
- * 'X-Rate-Limit-Reset': rateLimitResetHeader,
208
- * 'X-Request-ID': requestIdHeader
209
- * },
210
- * content: {
211
- * 'application/json': new OasMediaType({
212
- * schema: new OasArray({
213
- * items: new OasRef({ $ref: '#/components/schemas/User' })
214
- * })
215
- * })
216
- * }
217
- * });
218
- * ```
219
31
  */
220
32
  export class OasHeader {
221
33
  constructor(fields) {
@@ -225,36 +37,62 @@ export class OasHeader {
225
37
  writable: true,
226
38
  value: 'header'
227
39
  });
228
- _OasHeader_fields.set(this, void 0);
229
- __classPrivateFieldSet(this, _OasHeader_fields, fields, "f");
230
- }
231
- /** Brief description of header */
232
- get description() {
233
- return __classPrivateFieldGet(this, _OasHeader_fields, "f").description;
234
- }
235
- /** Indicates if header is mandatory. Default value is `false` */
236
- get required() {
237
- return __classPrivateFieldGet(this, _OasHeader_fields, "f").required;
238
- }
239
- /** Indicates if header is deprecated and should no longer be used. Default value is false */
240
- get deprecated() {
241
- return __classPrivateFieldGet(this, _OasHeader_fields, "f").deprecated;
242
- }
243
- /** Schema for the header */
244
- get schema() {
245
- return __classPrivateFieldGet(this, _OasHeader_fields, "f").schema;
246
- }
247
- /** Examples of the header */
248
- get examples() {
249
- return __classPrivateFieldGet(this, _OasHeader_fields, "f").examples;
250
- }
251
- /** Content of the header */
252
- get content() {
253
- return __classPrivateFieldGet(this, _OasHeader_fields, "f").content;
254
- }
255
- /** Specification Extension fields */
256
- get extensionFields() {
257
- return __classPrivateFieldGet(this, _OasHeader_fields, "f").extensionFields;
40
+ /** Brief description of header */
41
+ Object.defineProperty(this, "description", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true,
45
+ value: void 0
46
+ });
47
+ /** Indicates if header is mandatory. Default value is `false` */
48
+ Object.defineProperty(this, "required", {
49
+ enumerable: true,
50
+ configurable: true,
51
+ writable: true,
52
+ value: void 0
53
+ });
54
+ /** Indicates if header is deprecated and should no longer be used. Default value is false */
55
+ Object.defineProperty(this, "deprecated", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: void 0
60
+ });
61
+ /** Schema for the header */
62
+ Object.defineProperty(this, "schema", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true,
66
+ value: void 0
67
+ });
68
+ /** Examples of the header */
69
+ Object.defineProperty(this, "examples", {
70
+ enumerable: true,
71
+ configurable: true,
72
+ writable: true,
73
+ value: void 0
74
+ });
75
+ /** Content of the header */
76
+ Object.defineProperty(this, "content", {
77
+ enumerable: true,
78
+ configurable: true,
79
+ writable: true,
80
+ value: void 0
81
+ });
82
+ /** Specification Extension fields */
83
+ Object.defineProperty(this, "extensionFields", {
84
+ enumerable: true,
85
+ configurable: true,
86
+ writable: true,
87
+ value: void 0
88
+ });
89
+ this.description = fields.description;
90
+ this.required = fields.required;
91
+ this.deprecated = fields.deprecated;
92
+ this.schema = fields.schema;
93
+ this.examples = fields.examples;
94
+ this.content = fields.content;
95
+ this.extensionFields = fields.extensionFields;
258
96
  }
259
97
  /** Returns true if object is a reference */
260
98
  isRef() {
@@ -276,7 +114,7 @@ export class OasHeader {
276
114
  if (this.schema) {
277
115
  return this.schema;
278
116
  }
279
- const schema = __classPrivateFieldGet(this, _OasHeader_fields, "f").content?.[mediaType]?.schema;
117
+ const schema = this.content?.[mediaType]?.schema;
280
118
  if (!schema) {
281
119
  throw new Error(`Schema not found for media type ${mediaType}`);
282
120
  }
@@ -292,4 +130,3 @@ export class OasHeader {
292
130
  };
293
131
  }
294
132
  }
295
- _OasHeader_fields = new WeakMap();
@@ -1,21 +1,309 @@
1
1
  import type { OpenAPIV3 } from 'openapi-types';
2
2
  import type { ParseContext } from '../../context/ParseContext.js';
3
3
  import { OasMediaType } from './MediaType.js';
4
+ /**
5
+ * Arguments for transforming an OpenAPI v3 media type item into an OAS media type.
6
+ */
4
7
  type ToMediaTypeItemV3Args = {
8
+ /** The OpenAPI v3 media type object to transform */
5
9
  mediaTypeItem: OpenAPIV3.MediaTypeObject;
10
+ /** The media type string (e.g., 'application/json', 'text/plain') */
6
11
  mediaType: string;
12
+ /** The parsing context for tracing and processing */
7
13
  context: ParseContext;
8
14
  };
15
+ /**
16
+ * Transforms an OpenAPI v3 media type object into an internal OAS media type representation.
17
+ *
18
+ * This function processes OpenAPI v3 MediaType objects, extracting schema definitions,
19
+ * examples, encoding information, and specification extensions. It creates a structured
20
+ * internal representation that can be used by the SKMTC pipeline for code generation
21
+ * and validation.
22
+ *
23
+ * The transformation handles all standard OpenAPI v3 MediaType properties including
24
+ * schema references, inline schemas, examples, encoding specifications, and custom
25
+ * extension fields that begin with 'x-'.
26
+ *
27
+ * @param args - Transformation arguments
28
+ * @param args.mediaTypeItem - The OpenAPI v3 media type object to process
29
+ * @param args.mediaType - The media type identifier (MIME type)
30
+ * @param args.context - Parsing context for tracing and error handling
31
+ * @returns Structured OAS media type object for internal processing
32
+ *
33
+ * @example Transforming JSON media type
34
+ * ```typescript
35
+ * import { toMediaTypeItemV3 } from '@skmtc/core/oas/mediaType';
36
+ *
37
+ * const jsonMediaType = {
38
+ * schema: {
39
+ * type: 'object',
40
+ * properties: {
41
+ * name: { type: 'string' },
42
+ * email: { type: 'string', format: 'email' }
43
+ * }
44
+ * },
45
+ * example: {
46
+ * name: 'John Doe',
47
+ * email: 'john@example.com'
48
+ * }
49
+ * };
50
+ *
51
+ * const result = toMediaTypeItemV3({
52
+ * mediaTypeItem: jsonMediaType,
53
+ * mediaType: 'application/json',
54
+ * context: parseContext
55
+ * });
56
+ *
57
+ * console.log(result.mediaType); // 'application/json'
58
+ * console.log(result.schema); // Processed schema object
59
+ * ```
60
+ *
61
+ * @example Processing form data with encoding
62
+ * ```typescript
63
+ * const formMediaType = {
64
+ * schema: {
65
+ * type: 'object',
66
+ * properties: {
67
+ * file: { type: 'string', format: 'binary' },
68
+ * metadata: { type: 'string' }
69
+ * }
70
+ * },
71
+ * encoding: {
72
+ * file: {
73
+ * contentType: 'image/png',
74
+ * headers: {
75
+ * 'X-Rate-Limit': {
76
+ * schema: { type: 'integer' }
77
+ * }
78
+ * }
79
+ * }
80
+ * }
81
+ * };
82
+ *
83
+ * const result = toMediaTypeItemV3({
84
+ * mediaTypeItem: formMediaType,
85
+ * mediaType: 'multipart/form-data',
86
+ * context: parseContext
87
+ * });
88
+ *
89
+ * console.log(result.encoding); // Processed encoding configuration
90
+ * ```
91
+ *
92
+ * @example Handling multiple examples
93
+ * ```typescript
94
+ * const mediaTypeWithExamples = {
95
+ * schema: { type: 'string' },
96
+ * examples: {
97
+ * success: {
98
+ * summary: 'Successful response',
99
+ * value: 'Operation completed'
100
+ * },
101
+ * error: {
102
+ * summary: 'Error response',
103
+ * value: 'Operation failed'
104
+ * }
105
+ * }
106
+ * };
107
+ *
108
+ * const result = toMediaTypeItemV3({
109
+ * mediaTypeItem: mediaTypeWithExamples,
110
+ * mediaType: 'text/plain',
111
+ * context: parseContext
112
+ * });
113
+ *
114
+ * console.log(Object.keys(result.examples)); // ['success', 'error']
115
+ * ```
116
+ */
9
117
  export declare const toMediaTypeItemV3: ({ mediaTypeItem, mediaType, context }: ToMediaTypeItemV3Args) => OasMediaType;
118
+ /**
119
+ * Arguments for transforming multiple OpenAPI v3 media type items.
120
+ */
10
121
  type ToMediaTypeItemsV3Args = {
122
+ /** Map of media type strings to OpenAPI v3 MediaType objects */
11
123
  content: Record<string, OpenAPIV3.MediaTypeObject>;
124
+ /** The parsing context for tracing and processing */
12
125
  context: ParseContext;
13
126
  };
127
+ /**
128
+ * Transforms multiple OpenAPI v3 media type objects into internal OAS representations.
129
+ *
130
+ * This function processes a complete content map from OpenAPI v3, transforming each
131
+ * media type entry into its internal OAS representation. It's commonly used to process
132
+ * the `content` property of request bodies, responses, and parameters that support
133
+ * multiple media types.
134
+ *
135
+ * The function maintains the original media type keys while transforming the values
136
+ * into structured OAS media type objects. Each transformation is traced for debugging
137
+ * and error tracking purposes.
138
+ *
139
+ * @param args - Transformation arguments
140
+ * @param args.content - Map of media types to OpenAPI MediaType objects
141
+ * @param args.context - Parsing context for tracing and error handling
142
+ * @returns Map of media type strings to processed OAS media type objects
143
+ *
144
+ * @example Processing multiple content types
145
+ * ```typescript
146
+ * import { toMediaTypeItemsV3 } from '@skmtc/core/oas/mediaType';
147
+ *
148
+ * const content = {
149
+ * 'application/json': {
150
+ * schema: {
151
+ * type: 'object',
152
+ * properties: { message: { type: 'string' } }
153
+ * }
154
+ * },
155
+ * 'application/xml': {
156
+ * schema: {
157
+ * type: 'string'
158
+ * }
159
+ * },
160
+ * 'text/plain': {
161
+ * schema: {
162
+ * type: 'string'
163
+ * },
164
+ * example: 'Plain text response'
165
+ * }
166
+ * };
167
+ *
168
+ * const result = toMediaTypeItemsV3({
169
+ * content,
170
+ * context: parseContext
171
+ * });
172
+ *
173
+ * console.log(Object.keys(result)); // ['application/json', 'application/xml', 'text/plain']
174
+ * console.log(result['application/json'].mediaType); // 'application/json'
175
+ * ```
176
+ *
177
+ * @example Processing request body content types
178
+ * ```typescript
179
+ * const requestBodyContent = {
180
+ * 'application/json': {
181
+ * schema: { $ref: '#/components/schemas/CreateUserRequest' }
182
+ * },
183
+ * 'application/x-www-form-urlencoded': {
184
+ * schema: {
185
+ * type: 'object',
186
+ * properties: {
187
+ * name: { type: 'string' },
188
+ * email: { type: 'string' }
189
+ * }
190
+ * },
191
+ * encoding: {
192
+ * email: {
193
+ * style: 'form',
194
+ * explode: false
195
+ * }
196
+ * }
197
+ * }
198
+ * };
199
+ *
200
+ * const processed = toMediaTypeItemsV3({
201
+ * content: requestBodyContent,
202
+ * context: parseContext
203
+ * });
204
+ *
205
+ * // Each media type is processed with its specific configuration
206
+ * console.log(processed['application/json'].schema); // Reference object
207
+ * console.log(processed['application/x-www-form-urlencoded'].encoding); // Form encoding config
208
+ * ```
209
+ */
14
210
  export declare const toMediaTypeItemsV3: ({ content, context }: ToMediaTypeItemsV3Args) => Record<string, OasMediaType>;
211
+ /**
212
+ * Arguments for optionally transforming OpenAPI v3 media type items.
213
+ */
15
214
  type ToOptionalMediaTypeItemsV3Args = {
215
+ /** Optional map of media type strings to OpenAPI v3 MediaType objects */
16
216
  content: Record<string, OpenAPIV3.MediaTypeObject> | undefined;
217
+ /** The parsing context for tracing and processing */
17
218
  context: ParseContext;
18
219
  };
220
+ /**
221
+ * Optionally transforms OpenAPI v3 media type objects when content is provided.
222
+ *
223
+ * This function provides a safe way to process media type content that may or may not
224
+ * be present in the OpenAPI specification. It handles the common pattern where content
225
+ * properties are optional in OpenAPI objects (like responses without bodies or
226
+ * operations without request bodies).
227
+ *
228
+ * When content is undefined, the function returns undefined without processing.
229
+ * When content is provided, it delegates to `toMediaTypeItemsV3` for full processing.
230
+ *
231
+ * @param args - Transformation arguments
232
+ * @param args.content - Optional map of media types to OpenAPI MediaType objects
233
+ * @param args.context - Parsing context for tracing and error handling
234
+ * @returns Map of processed media types if content exists, undefined otherwise
235
+ *
236
+ * @example Handling optional response content
237
+ * ```typescript
238
+ * import { toOptionalMediaTypeItemsV3 } from '@skmtc/core/oas/mediaType';
239
+ *
240
+ * // Response with content
241
+ * const responseWithContent = {
242
+ * description: 'Successful response',
243
+ * content: {
244
+ * 'application/json': {
245
+ * schema: { type: 'object' }
246
+ * }
247
+ * }
248
+ * };
249
+ *
250
+ * const withContent = toOptionalMediaTypeItemsV3({
251
+ * content: responseWithContent.content,
252
+ * context: parseContext
253
+ * });
254
+ * console.log(withContent); // { 'application/json': OasMediaType }
255
+ *
256
+ * // Response without content (like 204 No Content)
257
+ * const responseNoContent = {
258
+ * description: 'No content response'
259
+ * };
260
+ *
261
+ * const noContent = toOptionalMediaTypeItemsV3({
262
+ * content: responseNoContent.content, // undefined
263
+ * context: parseContext
264
+ * });
265
+ * console.log(noContent); // undefined
266
+ * ```
267
+ *
268
+ * @example Processing operations with optional request bodies
269
+ * ```typescript
270
+ * function processOperation(operation: OpenAPIV3.OperationObject) {
271
+ * const requestBodyContent = toOptionalMediaTypeItemsV3({
272
+ * content: operation.requestBody?.content,
273
+ * context: parseContext
274
+ * });
275
+ *
276
+ * if (requestBodyContent) {
277
+ * console.log('Operation has request body with media types:');
278
+ * console.log(Object.keys(requestBodyContent));
279
+ * } else {
280
+ * console.log('Operation has no request body');
281
+ * }
282
+ * }
283
+ * ```
284
+ *
285
+ * @example Safe processing in response handlers
286
+ * ```typescript
287
+ * class ResponseProcessor {
288
+ * processResponse(response: OpenAPIV3.ResponseObject) {
289
+ * const mediaTypes = toOptionalMediaTypeItemsV3({
290
+ * content: response.content,
291
+ * context: this.context
292
+ * });
293
+ *
294
+ * // Safe to check without worrying about undefined content
295
+ * const hasJsonResponse = mediaTypes && 'application/json' in mediaTypes;
296
+ *
297
+ * if (hasJsonResponse) {
298
+ * const jsonMediaType = mediaTypes['application/json'];
299
+ * return this.generateJsonResponseHandler(jsonMediaType);
300
+ * }
301
+ *
302
+ * return this.generateEmptyResponseHandler();
303
+ * }
304
+ * }
305
+ * ```
306
+ */
19
307
  export declare const toOptionalMediaTypeItemsV3: ({ content, context }: ToOptionalMediaTypeItemsV3Args) => Record<string, OasMediaType> | undefined;
20
308
  export {};
21
309
  //# sourceMappingURL=toMediaTypeItemV3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toMediaTypeItemV3.d.ts","sourceRoot":"","sources":["../../../src/oas/mediaType/toMediaTypeItemV3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAGjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAI7C,KAAK,qBAAqB,GAAG;IAC3B,aAAa,EAAE,SAAS,CAAC,eAAe,CAAA;IACxC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,uCAI/B,qBAAqB,KAAG,YA0B1B,CAAA;AAED,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EA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