@skmtc/core 0.0.808 → 0.0.809

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 (43) hide show
  1. package/esm/oas/array/array-types.d.ts +238 -25
  2. package/esm/oas/array/array-types.d.ts.map +1 -1
  3. package/esm/oas/array/array-types.js +97 -5
  4. package/esm/oas/boolean/boolean-types.d.ts +81 -9
  5. package/esm/oas/boolean/boolean-types.d.ts.map +1 -1
  6. package/esm/oas/boolean/boolean-types.js +32 -2
  7. package/esm/oas/contact/contact-types.d.ts +176 -0
  8. package/esm/oas/contact/contact-types.d.ts.map +1 -1
  9. package/esm/oas/contact/contact-types.js +102 -0
  10. package/esm/oas/mediaType/toMediaTypeItemV3.d.ts +288 -0
  11. package/esm/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
  12. package/esm/oas/mediaType/toMediaTypeItemV3.js +272 -0
  13. package/esm/oas/operation/operation-types.d.ts +251 -0
  14. package/esm/oas/operation/operation-types.d.ts.map +1 -1
  15. package/esm/oas/operation/operation-types.js +98 -0
  16. package/esm/oas/string/string-types.d.ts +192 -18
  17. package/esm/oas/string/string-types.d.ts.map +1 -1
  18. package/esm/oas/string/string-types.js +76 -4
  19. package/esm/types/ModuleExport.d.ts +130 -0
  20. package/esm/types/ModuleExport.d.ts.map +1 -1
  21. package/esm/types/ModuleExport.js +36 -0
  22. package/package.json +1 -1
  23. package/script/oas/array/array-types.d.ts +238 -25
  24. package/script/oas/array/array-types.d.ts.map +1 -1
  25. package/script/oas/array/array-types.js +97 -5
  26. package/script/oas/boolean/boolean-types.d.ts +81 -9
  27. package/script/oas/boolean/boolean-types.d.ts.map +1 -1
  28. package/script/oas/boolean/boolean-types.js +32 -2
  29. package/script/oas/contact/contact-types.d.ts +176 -0
  30. package/script/oas/contact/contact-types.d.ts.map +1 -1
  31. package/script/oas/contact/contact-types.js +102 -0
  32. package/script/oas/mediaType/toMediaTypeItemV3.d.ts +288 -0
  33. package/script/oas/mediaType/toMediaTypeItemV3.d.ts.map +1 -1
  34. package/script/oas/mediaType/toMediaTypeItemV3.js +272 -0
  35. package/script/oas/operation/operation-types.d.ts +251 -0
  36. package/script/oas/operation/operation-types.d.ts.map +1 -1
  37. package/script/oas/operation/operation-types.js +98 -0
  38. package/script/oas/string/string-types.d.ts +192 -18
  39. package/script/oas/string/string-types.d.ts.map +1 -1
  40. package/script/oas/string/string-types.js +76 -4
  41. package/script/types/ModuleExport.d.ts +130 -0
  42. package/script/types/ModuleExport.d.ts.map +1 -1
  43. package/script/types/ModuleExport.js +36 -0
@@ -1,9 +1,185 @@
1
1
  import * as v from 'valibot';
2
+ /**
3
+ * Data type for OpenAPI contact information objects.
4
+ *
5
+ * This type represents contact information as specified in the OpenAPI v3 specification's
6
+ * Info Object. Contact information provides details about the person or organization
7
+ * responsible for the API, including optional name, website URL, and email address.
8
+ *
9
+ * The contact information is typically displayed in API documentation and used by
10
+ * developers to reach out for support, questions, or feedback about the API.
11
+ *
12
+ * ## Usage in SKMTC Pipeline
13
+ *
14
+ * This type is used by:
15
+ * - Info processors to validate and structure contact information
16
+ * - Documentation generators to display API maintainer information
17
+ * - Client generators to embed support contact details in generated code
18
+ * - Validation systems to ensure contact information completeness
19
+ *
20
+ * @example Basic contact information
21
+ * ```typescript
22
+ * import type { OasContactData } from '@skmtc/core/oas/contact';
23
+ *
24
+ * const apiContact: OasContactData = {
25
+ * oasType: 'contact',
26
+ * name: 'API Support Team',
27
+ * url: 'https://company.com/support',
28
+ * email: 'api-support@company.com'
29
+ * };
30
+ * ```
31
+ *
32
+ * @example Minimal contact with only email
33
+ * ```typescript
34
+ * const minimalContact: OasContactData = {
35
+ * oasType: 'contact',
36
+ * email: 'support@api-company.com'
37
+ * };
38
+ * ```
39
+ *
40
+ * @example Contact with name and URL
41
+ * ```typescript
42
+ * const teamContact: OasContactData = {
43
+ * oasType: 'contact',
44
+ * name: 'Development Team',
45
+ * url: 'https://github.com/company/api-repo'
46
+ * };
47
+ * ```
48
+ *
49
+ * @example Integration in OpenAPI Info object
50
+ * ```typescript
51
+ * const apiInfo = {
52
+ * title: 'My API',
53
+ * version: '1.0.0',
54
+ * description: 'A comprehensive API for managing resources',
55
+ * contact: {
56
+ * oasType: 'contact',
57
+ * name: 'Jane Doe',
58
+ * url: 'https://janedoe.dev',
59
+ * email: 'jane@company.com'
60
+ * }
61
+ * };
62
+ * ```
63
+ *
64
+ * @example Empty contact (valid but not recommended)
65
+ * ```typescript
66
+ * const emptyContact: OasContactData = {
67
+ * oasType: 'contact'
68
+ * // All fields are optional, but at least one should be provided
69
+ * };
70
+ * ```
71
+ */
2
72
  export type OasContactData = {
73
+ /** Type identifier for SKMTC internal processing */
3
74
  oasType: 'contact';
75
+ /** The identifying name of the contact person or organization */
4
76
  name?: string;
77
+ /** The URL pointing to the contact information (website, GitHub, etc.) */
5
78
  url?: string;
79
+ /** The email address of the contact person or organization */
6
80
  email?: string;
7
81
  };
82
+ /**
83
+ * Valibot schema for validating OpenAPI contact data objects.
84
+ *
85
+ * This schema validates OpenAPI contact information according to the OpenAPI v3
86
+ * specification. All contact fields are optional, allowing for flexible contact
87
+ * information configurations. The schema ensures proper string formatting for
88
+ * name, URL, and email fields while maintaining the required `oasType` identifier.
89
+ *
90
+ * Note that while all fields are optional according to the OpenAPI specification,
91
+ * it's recommended to provide at least one contact method for practical API usage.
92
+ *
93
+ * @example Validating complete contact information
94
+ * ```typescript
95
+ * import { oasContactData } from '@skmtc/core/oas/contact';
96
+ * import * as v from 'valibot';
97
+ *
98
+ * const contact = {
99
+ * oasType: 'contact',
100
+ * name: 'API Support',
101
+ * url: 'https://api.company.com/support',
102
+ * email: 'support@company.com'
103
+ * };
104
+ *
105
+ * const validated = v.parse(oasContactData, contact);
106
+ * console.log(validated.name); // 'API Support'
107
+ * console.log(validated.email); // 'support@company.com'
108
+ * ```
109
+ *
110
+ * @example Validating partial contact information
111
+ * ```typescript
112
+ * const partialContact = {
113
+ * oasType: 'contact',
114
+ * email: 'help@api.com'
115
+ * // name and url are optional and omitted
116
+ * };
117
+ *
118
+ * const result = v.parse(oasContactData, partialContact);
119
+ * console.log(result.email); // 'help@api.com'
120
+ * console.log(result.name); // undefined
121
+ * console.log(result.url); // undefined
122
+ * ```
123
+ *
124
+ * @example Validation error handling
125
+ * ```typescript
126
+ * const invalidContact = {
127
+ * oasType: 'contact',
128
+ * name: 123, // Invalid: should be string
129
+ * email: 'valid@email.com'
130
+ * };
131
+ *
132
+ * try {
133
+ * v.parse(oasContactData, invalidContact);
134
+ * } catch (error) {
135
+ * console.error('Contact validation failed:', error.message);
136
+ * // Handle validation errors appropriately
137
+ * }
138
+ * ```
139
+ *
140
+ * @example Usage in OpenAPI document processing
141
+ * ```typescript
142
+ * function processApiInfo(infoObject: unknown) {
143
+ * // Validate the info object structure
144
+ * const info = parseInfoObject(infoObject);
145
+ *
146
+ * // If contact information exists, validate it
147
+ * if (info.contact) {
148
+ * const validatedContact = v.parse(oasContactData, {
149
+ * oasType: 'contact',
150
+ * ...info.contact
151
+ * });
152
+ *
153
+ * console.log(`API maintained by: ${validatedContact.name || 'Unknown'}`);
154
+ * console.log(`Support: ${validatedContact.email || 'No email provided'}`);
155
+ * }
156
+ * }
157
+ * ```
158
+ *
159
+ * @example Integration with documentation generators
160
+ * ```typescript
161
+ * class DocumentationGenerator {
162
+ * generateContactSection(contactData: OasContactData): string {
163
+ * const validated = v.parse(oasContactData, contactData);
164
+ *
165
+ * let contactSection = '## Contact Information\n\n';
166
+ *
167
+ * if (validated.name) {
168
+ * contactSection += `**Maintainer:** ${validated.name}\n\n`;
169
+ * }
170
+ *
171
+ * if (validated.email) {
172
+ * contactSection += `**Email:** [${validated.email}](mailto:${validated.email})\n\n`;
173
+ * }
174
+ *
175
+ * if (validated.url) {
176
+ * contactSection += `**Website:** [${validated.url}](${validated.url})\n\n`;
177
+ * }
178
+ *
179
+ * return contactSection;
180
+ * }
181
+ * }
182
+ * ```
183
+ */
8
184
  export declare const oasContactData: v.GenericSchema<OasContactData>;
9
185
  //# sourceMappingURL=contact-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contact-types.d.ts","sourceRoot":"","sources":["../../../src/oas/contact/contact-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,SAAS,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,aAAa,CAAC,cAAc,CAKzD,CAAA"}
1
+ {"version":3,"file":"contact-types.d.ts","sourceRoot":"","sources":["../../../src/oas/contact/contact-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,oDAAoD;IACpD,OAAO,EAAE,SAAS,CAAA;IAClB,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqGG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,aAAa,CAAC,cAAc,CAKzD,CAAA"}
@@ -35,6 +35,108 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.oasContactData = void 0;
37
37
  const v = __importStar(require("valibot"));
38
+ /**
39
+ * Valibot schema for validating OpenAPI contact data objects.
40
+ *
41
+ * This schema validates OpenAPI contact information according to the OpenAPI v3
42
+ * specification. All contact fields are optional, allowing for flexible contact
43
+ * information configurations. The schema ensures proper string formatting for
44
+ * name, URL, and email fields while maintaining the required `oasType` identifier.
45
+ *
46
+ * Note that while all fields are optional according to the OpenAPI specification,
47
+ * it's recommended to provide at least one contact method for practical API usage.
48
+ *
49
+ * @example Validating complete contact information
50
+ * ```typescript
51
+ * import { oasContactData } from '@skmtc/core/oas/contact';
52
+ * import * as v from 'valibot';
53
+ *
54
+ * const contact = {
55
+ * oasType: 'contact',
56
+ * name: 'API Support',
57
+ * url: 'https://api.company.com/support',
58
+ * email: 'support@company.com'
59
+ * };
60
+ *
61
+ * const validated = v.parse(oasContactData, contact);
62
+ * console.log(validated.name); // 'API Support'
63
+ * console.log(validated.email); // 'support@company.com'
64
+ * ```
65
+ *
66
+ * @example Validating partial contact information
67
+ * ```typescript
68
+ * const partialContact = {
69
+ * oasType: 'contact',
70
+ * email: 'help@api.com'
71
+ * // name and url are optional and omitted
72
+ * };
73
+ *
74
+ * const result = v.parse(oasContactData, partialContact);
75
+ * console.log(result.email); // 'help@api.com'
76
+ * console.log(result.name); // undefined
77
+ * console.log(result.url); // undefined
78
+ * ```
79
+ *
80
+ * @example Validation error handling
81
+ * ```typescript
82
+ * const invalidContact = {
83
+ * oasType: 'contact',
84
+ * name: 123, // Invalid: should be string
85
+ * email: 'valid@email.com'
86
+ * };
87
+ *
88
+ * try {
89
+ * v.parse(oasContactData, invalidContact);
90
+ * } catch (error) {
91
+ * console.error('Contact validation failed:', error.message);
92
+ * // Handle validation errors appropriately
93
+ * }
94
+ * ```
95
+ *
96
+ * @example Usage in OpenAPI document processing
97
+ * ```typescript
98
+ * function processApiInfo(infoObject: unknown) {
99
+ * // Validate the info object structure
100
+ * const info = parseInfoObject(infoObject);
101
+ *
102
+ * // If contact information exists, validate it
103
+ * if (info.contact) {
104
+ * const validatedContact = v.parse(oasContactData, {
105
+ * oasType: 'contact',
106
+ * ...info.contact
107
+ * });
108
+ *
109
+ * console.log(`API maintained by: ${validatedContact.name || 'Unknown'}`);
110
+ * console.log(`Support: ${validatedContact.email || 'No email provided'}`);
111
+ * }
112
+ * }
113
+ * ```
114
+ *
115
+ * @example Integration with documentation generators
116
+ * ```typescript
117
+ * class DocumentationGenerator {
118
+ * generateContactSection(contactData: OasContactData): string {
119
+ * const validated = v.parse(oasContactData, contactData);
120
+ *
121
+ * let contactSection = '## Contact Information\n\n';
122
+ *
123
+ * if (validated.name) {
124
+ * contactSection += `**Maintainer:** ${validated.name}\n\n`;
125
+ * }
126
+ *
127
+ * if (validated.email) {
128
+ * contactSection += `**Email:** [${validated.email}](mailto:${validated.email})\n\n`;
129
+ * }
130
+ *
131
+ * if (validated.url) {
132
+ * contactSection += `**Website:** [${validated.url}](${validated.url})\n\n`;
133
+ * }
134
+ *
135
+ * return contactSection;
136
+ * }
137
+ * }
138
+ * ```
139
+ */
38
140
  exports.oasContactData = v.object({
39
141
  oasType: v.literal('contact'),
40
142
  name: v.optional(v.string()),
@@ -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,EAAE,SAAS,CAAC,eAAe,CAAC,CAAA;IAClD,OAAO,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,sBAGhC,sBAAsB,KAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAatD,CAAA;AAED,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,S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