@skmtc/core 0.0.788 → 0.0.790

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 (49) hide show
  1. package/esm/context/ParseContext.d.ts +178 -0
  2. package/esm/context/ParseContext.d.ts.map +1 -1
  3. package/esm/context/ParseContext.js +108 -0
  4. package/esm/context/RenderContext.d.ts +190 -0
  5. package/esm/context/RenderContext.d.ts.map +1 -1
  6. package/esm/context/RenderContext.js +179 -0
  7. package/esm/dsl/Inserted.d.ts +240 -0
  8. package/esm/dsl/Inserted.d.ts.map +1 -1
  9. package/esm/dsl/Inserted.js +231 -0
  10. package/esm/helpers/refFns.d.ts +160 -0
  11. package/esm/helpers/refFns.d.ts.map +1 -1
  12. package/esm/helpers/refFns.js +156 -0
  13. package/esm/oas/boolean/Boolean.d.ts +142 -1
  14. package/esm/oas/boolean/Boolean.d.ts.map +1 -1
  15. package/esm/oas/boolean/Boolean.js +130 -1
  16. package/esm/oas/components/Components.d.ts +252 -2
  17. package/esm/oas/components/Components.d.ts.map +1 -1
  18. package/esm/oas/components/Components.js +241 -2
  19. package/esm/oas/parameter/Parameter.d.ts +160 -0
  20. package/esm/oas/parameter/Parameter.d.ts.map +1 -1
  21. package/esm/oas/parameter/Parameter.js +144 -0
  22. package/esm/oas/union/Union.d.ts +119 -5
  23. package/esm/oas/union/Union.d.ts.map +1 -1
  24. package/esm/oas/union/Union.js +108 -5
  25. package/package.json +1 -1
  26. package/script/context/ParseContext.d.ts +178 -0
  27. package/script/context/ParseContext.d.ts.map +1 -1
  28. package/script/context/ParseContext.js +108 -0
  29. package/script/context/RenderContext.d.ts +190 -0
  30. package/script/context/RenderContext.d.ts.map +1 -1
  31. package/script/context/RenderContext.js +179 -0
  32. package/script/dsl/Inserted.d.ts +240 -0
  33. package/script/dsl/Inserted.d.ts.map +1 -1
  34. package/script/dsl/Inserted.js +231 -0
  35. package/script/helpers/refFns.d.ts +160 -0
  36. package/script/helpers/refFns.d.ts.map +1 -1
  37. package/script/helpers/refFns.js +156 -0
  38. package/script/oas/boolean/Boolean.d.ts +142 -1
  39. package/script/oas/boolean/Boolean.d.ts.map +1 -1
  40. package/script/oas/boolean/Boolean.js +130 -1
  41. package/script/oas/components/Components.d.ts +252 -2
  42. package/script/oas/components/Components.d.ts.map +1 -1
  43. package/script/oas/components/Components.js +241 -2
  44. package/script/oas/parameter/Parameter.d.ts +160 -0
  45. package/script/oas/parameter/Parameter.d.ts.map +1 -1
  46. package/script/oas/parameter/Parameter.js +144 -0
  47. package/script/oas/union/Union.d.ts +119 -5
  48. package/script/oas/union/Union.d.ts.map +1 -1
  49. package/script/oas/union/Union.js +108 -5
@@ -2,17 +2,158 @@ import "../../_dnt.polyfills.js";
2
2
  import type { OpenAPIV3 } from 'openapi-types';
3
3
  import type { OasRef } from '../ref/Ref.js';
4
4
  import type { ToJsonSchemaOptions } from '../schema/Schema.js';
5
+ /**
6
+ * Constructor fields for {@link OasBoolean}.
7
+ *
8
+ * @template Nullable - Whether the boolean can be null (affects type unions)
9
+ */
5
10
  export type BooleanFields<Nullable extends boolean | undefined> = {
11
+ /** A short summary of the boolean schema */
6
12
  title?: string;
13
+ /** A description of the boolean schema */
7
14
  description?: string;
15
+ /** Whether the boolean value can be null */
8
16
  nullable?: Nullable;
17
+ /** Custom extension fields (x-* properties) */
9
18
  extensionFields?: Record<string, unknown>;
19
+ /** Example value for the boolean (null allowed if Nullable is true) */
10
20
  example?: Nullable extends true ? boolean | null | undefined : boolean | undefined;
21
+ /** Array of valid enum values for the boolean (null allowed if Nullable is true) */
11
22
  enums?: Nullable extends true ? (boolean | null)[] | undefined : boolean[] | undefined;
23
+ /** Default value for the boolean (null allowed if Nullable is true) */
12
24
  default?: Nullable extends true ? boolean | null | undefined : boolean | undefined;
13
25
  };
14
26
  /**
15
- * Object representing a boolean in the OpenAPI Specification.
27
+ * Represents a boolean schema in the OpenAPI Specification.
28
+ *
29
+ * The `OasBoolean` class handles boolean data types in OpenAPI schemas, supporting
30
+ * both simple true/false values and more complex boolean schemas with constraints,
31
+ * enumerations, and nullable types. This class provides type-safe boolean handling
32
+ * with optional null value support through generic typing.
33
+ *
34
+ * ## Key Features
35
+ *
36
+ * - **Type Safety**: Generic nullable type support with proper TypeScript inference
37
+ * - **Enum Support**: Constrain boolean values to specific true/false combinations
38
+ * - **Null Handling**: Optional null value support for nullable boolean types
39
+ * - **Validation**: Default values and example validation
40
+ * - **JSON Schema**: Converts to standard JSON Schema format for validation
41
+ * - **Documentation**: Rich metadata support for API documentation
42
+ *
43
+ * @template Nullable - Whether the boolean value itself can be null
44
+ *
45
+ * @example Basic boolean schema
46
+ * ```typescript
47
+ * import { OasBoolean } from '@skmtc/core';
48
+ *
49
+ * const isActiveSchema = new OasBoolean({
50
+ * title: 'Active Status',
51
+ * description: 'Whether the user account is active',
52
+ * default: true,
53
+ * example: true
54
+ * });
55
+ *
56
+ * // This represents: boolean with default true
57
+ * ```
58
+ *
59
+ * @example Nullable boolean schema
60
+ * ```typescript
61
+ * const nullableFlag = new OasBoolean<true>({
62
+ * title: 'Optional Flag',
63
+ * description: 'An optional boolean flag that can be null',
64
+ * nullable: true,
65
+ * default: null,
66
+ * example: true
67
+ * });
68
+ *
69
+ * // This represents: boolean | null
70
+ * ```
71
+ *
72
+ * @example Boolean with enum constraints
73
+ * ```typescript
74
+ * const strictBoolean = new OasBoolean({
75
+ * title: 'Confirmation',
76
+ * description: 'Must explicitly be true to confirm action',
77
+ * enums: [true], // Only true is allowed
78
+ * example: true
79
+ * });
80
+ *
81
+ * // This only accepts true, effectively making it required
82
+ * ```
83
+ *
84
+ * @example Boolean with null in enum
85
+ * ```typescript
86
+ * const triStateBoolean = new OasBoolean<true>({
87
+ * title: 'Approval Status',
88
+ * description: 'Approval can be true (approved), false (denied), or null (pending)',
89
+ * nullable: true,
90
+ * enums: [true, false, null],
91
+ * default: null,
92
+ * example: null
93
+ * });
94
+ *
95
+ * // This represents: true | false | null (tri-state logic)
96
+ * ```
97
+ *
98
+ * @example Feature flag schema
99
+ * ```typescript
100
+ * const featureFlag = new OasBoolean({
101
+ * title: 'Feature Enabled',
102
+ * description: 'Whether the new feature is enabled for this user',
103
+ * default: false,
104
+ * example: false
105
+ * });
106
+ *
107
+ * // Used in configuration objects
108
+ * const userConfig = new OasObject({
109
+ * properties: {
110
+ * darkMode: featureFlag,
111
+ * notifications: featureFlag,
112
+ * betaFeatures: featureFlag
113
+ * }
114
+ * });
115
+ * ```
116
+ *
117
+ * @example Consent and agreement booleans
118
+ * ```typescript
119
+ * const consentSchema = new OasBoolean({
120
+ * title: 'Terms Accepted',
121
+ * description: 'User has accepted the terms and conditions',
122
+ * enums: [true], // Must be true to be valid
123
+ * example: true
124
+ * });
125
+ *
126
+ * const privacyConsent = new OasBoolean({
127
+ * title: 'Privacy Policy Accepted',
128
+ * description: 'User has accepted the privacy policy',
129
+ * default: false,
130
+ * example: true
131
+ * });
132
+ *
133
+ * // Used in registration forms where consent is required
134
+ * ```
135
+ *
136
+ * @example Optional settings with nullable booleans
137
+ * ```typescript
138
+ * const userPreferences = new OasObject({
139
+ * properties: {
140
+ * emailNotifications: new OasBoolean<true>({
141
+ * title: 'Email Notifications',
142
+ * description: 'Enable email notifications (null means use default)',
143
+ * nullable: true,
144
+ * default: null
145
+ * }),
146
+ * smsNotifications: new OasBoolean<true>({
147
+ * title: 'SMS Notifications',
148
+ * description: 'Enable SMS notifications (null means not set)',
149
+ * nullable: true,
150
+ * default: null
151
+ * })
152
+ * }
153
+ * });
154
+ *
155
+ * // Allows: { emailNotifications: true, smsNotifications: null }
156
+ * ```
16
157
  */
17
158
  export declare class OasBoolean<Nullable extends boolean | undefined = boolean | undefined> {
18
159
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Boolean.d.ts","sourceRoot":"","sources":["../../../src/oas/boolean/Boolean.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CA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SAAS,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;gBAErE,MAAM,GAAE,aAAa,CAAC,QAAQ,CAAM;IAUhD,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,UAAU,CAAC,QAAQ,CAAC;IAI/B,WAAW,IAAI,UAAU,CAAC,QAAQ,CAAC;IAKnC,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC,oBAAoB;CAW5E"}
@@ -3,7 +3,136 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OasBoolean = void 0;
4
4
  require("../../_dnt.polyfills.js");
5
5
  /**
6
- * Object representing a boolean in the OpenAPI Specification.
6
+ * Represents a boolean schema in the OpenAPI Specification.
7
+ *
8
+ * The `OasBoolean` class handles boolean data types in OpenAPI schemas, supporting
9
+ * both simple true/false values and more complex boolean schemas with constraints,
10
+ * enumerations, and nullable types. This class provides type-safe boolean handling
11
+ * with optional null value support through generic typing.
12
+ *
13
+ * ## Key Features
14
+ *
15
+ * - **Type Safety**: Generic nullable type support with proper TypeScript inference
16
+ * - **Enum Support**: Constrain boolean values to specific true/false combinations
17
+ * - **Null Handling**: Optional null value support for nullable boolean types
18
+ * - **Validation**: Default values and example validation
19
+ * - **JSON Schema**: Converts to standard JSON Schema format for validation
20
+ * - **Documentation**: Rich metadata support for API documentation
21
+ *
22
+ * @template Nullable - Whether the boolean value itself can be null
23
+ *
24
+ * @example Basic boolean schema
25
+ * ```typescript
26
+ * import { OasBoolean } from '@skmtc/core';
27
+ *
28
+ * const isActiveSchema = new OasBoolean({
29
+ * title: 'Active Status',
30
+ * description: 'Whether the user account is active',
31
+ * default: true,
32
+ * example: true
33
+ * });
34
+ *
35
+ * // This represents: boolean with default true
36
+ * ```
37
+ *
38
+ * @example Nullable boolean schema
39
+ * ```typescript
40
+ * const nullableFlag = new OasBoolean<true>({
41
+ * title: 'Optional Flag',
42
+ * description: 'An optional boolean flag that can be null',
43
+ * nullable: true,
44
+ * default: null,
45
+ * example: true
46
+ * });
47
+ *
48
+ * // This represents: boolean | null
49
+ * ```
50
+ *
51
+ * @example Boolean with enum constraints
52
+ * ```typescript
53
+ * const strictBoolean = new OasBoolean({
54
+ * title: 'Confirmation',
55
+ * description: 'Must explicitly be true to confirm action',
56
+ * enums: [true], // Only true is allowed
57
+ * example: true
58
+ * });
59
+ *
60
+ * // This only accepts true, effectively making it required
61
+ * ```
62
+ *
63
+ * @example Boolean with null in enum
64
+ * ```typescript
65
+ * const triStateBoolean = new OasBoolean<true>({
66
+ * title: 'Approval Status',
67
+ * description: 'Approval can be true (approved), false (denied), or null (pending)',
68
+ * nullable: true,
69
+ * enums: [true, false, null],
70
+ * default: null,
71
+ * example: null
72
+ * });
73
+ *
74
+ * // This represents: true | false | null (tri-state logic)
75
+ * ```
76
+ *
77
+ * @example Feature flag schema
78
+ * ```typescript
79
+ * const featureFlag = new OasBoolean({
80
+ * title: 'Feature Enabled',
81
+ * description: 'Whether the new feature is enabled for this user',
82
+ * default: false,
83
+ * example: false
84
+ * });
85
+ *
86
+ * // Used in configuration objects
87
+ * const userConfig = new OasObject({
88
+ * properties: {
89
+ * darkMode: featureFlag,
90
+ * notifications: featureFlag,
91
+ * betaFeatures: featureFlag
92
+ * }
93
+ * });
94
+ * ```
95
+ *
96
+ * @example Consent and agreement booleans
97
+ * ```typescript
98
+ * const consentSchema = new OasBoolean({
99
+ * title: 'Terms Accepted',
100
+ * description: 'User has accepted the terms and conditions',
101
+ * enums: [true], // Must be true to be valid
102
+ * example: true
103
+ * });
104
+ *
105
+ * const privacyConsent = new OasBoolean({
106
+ * title: 'Privacy Policy Accepted',
107
+ * description: 'User has accepted the privacy policy',
108
+ * default: false,
109
+ * example: true
110
+ * });
111
+ *
112
+ * // Used in registration forms where consent is required
113
+ * ```
114
+ *
115
+ * @example Optional settings with nullable booleans
116
+ * ```typescript
117
+ * const userPreferences = new OasObject({
118
+ * properties: {
119
+ * emailNotifications: new OasBoolean<true>({
120
+ * title: 'Email Notifications',
121
+ * description: 'Enable email notifications (null means use default)',
122
+ * nullable: true,
123
+ * default: null
124
+ * }),
125
+ * smsNotifications: new OasBoolean<true>({
126
+ * title: 'SMS Notifications',
127
+ * description: 'Enable SMS notifications (null means not set)',
128
+ * nullable: true,
129
+ * default: null
130
+ * })
131
+ * }
132
+ * });
133
+ *
134
+ * // Allows: { emailNotifications: true, smsNotifications: null }
135
+ * ```
7
136
  */
8
137
  class OasBoolean {
9
138
  constructor(fields = {}) {
@@ -9,29 +9,279 @@ import type { OasRef } from '../ref/Ref.js';
9
9
  import type { OasSchema } from '../schema/Schema.js';
10
10
  import type { RefName } from '../../types/RefName.js';
11
11
  import type { OasSecurityScheme } from '../securitySchemes/SecurityScheme.js';
12
+ /**
13
+ * Available component types in an OpenAPI document.
14
+ */
12
15
  export declare const componentsKeys: string[];
16
+ /**
17
+ * Constructor fields for {@link OasComponents}.
18
+ */
13
19
  export type ComponentsFields = {
20
+ /** Reusable schema components */
14
21
  schemas?: Record<RefName, OasSchema | OasRef<'schema'>>;
22
+ /** Reusable response components */
15
23
  responses?: Record<RefName, OasResponse | OasRef<'response'>>;
24
+ /** Reusable parameter components */
16
25
  parameters?: Record<RefName, OasParameter | OasRef<'parameter'>>;
26
+ /** Reusable example components */
17
27
  examples?: Record<RefName, OasExample | OasRef<'example'>>;
28
+ /** Reusable request body components */
18
29
  requestBodies?: Record<RefName, OasRequestBody | OasRef<'requestBody'>>;
30
+ /** Reusable header components */
19
31
  headers?: Record<RefName, OasHeader | OasRef<'header'>>;
32
+ /** Reusable security scheme components */
20
33
  securitySchemes?: Record<string, OasSecurityScheme | OasRef<'securityScheme'>>;
34
+ /** Custom extension fields (x-* properties) */
21
35
  extensionFields?: Record<string, unknown>;
22
36
  };
23
- /** Container object for re-usable schema items within the API
37
+ /**
38
+ * Represents the OpenAPI Components Object in the SKMTC OAS processing system.
39
+ *
40
+ * The `OasComponents` class manages the reusable components section of an OpenAPI
41
+ * document, providing centralized access to shared schemas, responses, parameters,
42
+ * and other reusable elements that can be referenced throughout the API specification.
43
+ *
44
+ * This class serves as the central registry for all reusable components, enabling
45
+ * efficient reference resolution and reducing duplication in OpenAPI documents.
46
+ *
47
+ * ## Key Features
48
+ *
49
+ * - **Schema Management**: Central repository for reusable data schemas
50
+ * - **Response Reuse**: Common response definitions for consistent API responses
51
+ * - **Parameter Standardization**: Shared parameter definitions across operations
52
+ * - **Reference Resolution**: Support for internal references ($ref) to components
53
+ * - **Type Safety**: Strongly typed access to different component categories
54
+ * - **Extension Support**: Custom OpenAPI extension field handling
55
+ *
56
+ * @example Basic component access
57
+ * ```typescript
58
+ * import { OasComponents } from '@skmtc/core';
59
+ *
60
+ * // Typically created during document parsing
61
+ * const components = new OasComponents({
62
+ * schemas: {
63
+ * User: new OasObject({
64
+ * properties: {
65
+ * id: new OasString(),
66
+ * name: new OasString()
67
+ * }
68
+ * }),
69
+ * Product: new OasObject({
70
+ * properties: {
71
+ * id: new OasString(),
72
+ * price: new OasNumber()
73
+ * }
74
+ * })
75
+ * },
76
+ * responses: {
77
+ * NotFound: new OasResponse({
78
+ * description: '404 - Resource not found'
79
+ * })
80
+ * }
81
+ * });
82
+ *
83
+ * // Access schemas
84
+ * const userSchema = components.schemas?.['User'];
85
+ * const productSchema = components.schemas?.['Product'];
86
+ *
87
+ * // Access responses
88
+ * const notFoundResponse = components.responses?.['NotFound'];
89
+ * ```
90
+ *
91
+ * @example Schema management
92
+ * ```typescript
93
+ * // Get all schema reference names
94
+ * const schemaNames = components.toSchemasRefNames();
95
+ * console.log(schemaNames); // ['User', 'Product', 'Order']
96
+ *
97
+ * // Remove a schema (useful for processing)
98
+ * const removedSchema = components.removeSchema('ObsoleteSchema');
99
+ * console.log('Removed:', removedSchema);
100
+ *
101
+ * // Check remaining schemas
102
+ * const remainingSchemas = components.toSchemasRefNames();
103
+ * console.log('Remaining:', remainingSchemas);
104
+ * ```
105
+ *
106
+ * @example Parameter reuse
107
+ * ```typescript
108
+ * const components = new OasComponents({
109
+ * parameters: {
110
+ * PageSize: new OasParameter({
111
+ * name: 'pageSize',
112
+ * in: 'query',
113
+ * schema: new OasInteger({ minimum: 1, maximum: 100, default: 20 })
114
+ * }),
115
+ * PageNumber: new OasParameter({
116
+ * name: 'page',
117
+ * in: 'query',
118
+ * schema: new OasInteger({ minimum: 1, default: 1 })
119
+ * })
120
+ * }
121
+ * });
122
+ *
123
+ * // These parameters can be referenced in operations:
124
+ * // $ref: '#/components/parameters/PageSize'
125
+ * // $ref: '#/components/parameters/PageNumber'
126
+ * ```
127
+ *
128
+ * @example Response standardization
129
+ * ```typescript
130
+ * const components = new OasComponents({
131
+ * responses: {
132
+ * Success: new OasResponse({
133
+ * description: 'Successful operation',
134
+ * content: {
135
+ * 'application/json': {
136
+ * schema: new OasObject({
137
+ * properties: {
138
+ * success: new OasBoolean({ default: true }),
139
+ * data: new OasObject({ additionalProperties: true })
140
+ * }
141
+ * })
142
+ * }
143
+ * }
144
+ * }),
145
+ * ValidationError: new OasResponse({
146
+ * description: 'Validation failed',
147
+ * content: {
148
+ * 'application/json': {
149
+ * schema: new OasObject({
150
+ * properties: {
151
+ * error: new OasString(),
152
+ * details: new OasArray({
153
+ * items: new OasString()
154
+ * })
155
+ * }
156
+ * })
157
+ * }
158
+ * }
159
+ * })
160
+ * }
161
+ * });
162
+ *
163
+ * // Standardized responses across all operations
164
+ * ```
165
+ *
166
+ * @example Processing components in generators
167
+ * ```typescript
168
+ * class ComponentProcessor {
169
+ * processDocument(document: OasDocument) {
170
+ * const components = document.components;
171
+ * if (!components) return;
172
+ *
173
+ * // Process all schemas
174
+ * if (components.schemas) {
175
+ * Object.entries(components.schemas).forEach(([name, schema]) => {
176
+ * if (schema.isRef()) {
177
+ * console.log(`Schema ${name} is a reference to ${schema.$ref}`);
178
+ * } else {
179
+ * console.log(`Schema ${name} is a direct definition`);
180
+ * }
181
+ * });
182
+ * }
24
183
  *
25
- * Fields not yet implemented: **securitySchemes**, **links**, **callbacks**
184
+ * // Process parameters
185
+ * if (components.parameters) {
186
+ * Object.keys(components.parameters).forEach(paramName => {
187
+ * console.log(`Reusable parameter: ${paramName}`);
188
+ * });
189
+ * }
190
+ * }
191
+ * }
192
+ * ```
26
193
  */
27
194
  export declare class OasComponents {
28
195
  #private;
29
196
  /** Static identifier property for OasComponents */
30
197
  oasType: "components";
198
+ /**
199
+ * Creates a new OasComponents instance.
200
+ *
201
+ * @param fields - Component definitions (defaults to empty object)
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * const components = new OasComponents({
206
+ * schemas: {
207
+ * User: userSchema,
208
+ * Product: productSchema
209
+ * },
210
+ * responses: {
211
+ * NotFound: notFoundResponse
212
+ * }
213
+ * });
214
+ * ```
215
+ */
31
216
  constructor(fields?: ComponentsFields);
217
+ /**
218
+ * Gets all schema reference names.
219
+ *
220
+ * This method extracts the keys from the schemas object and returns them
221
+ * as an array of RefName types. Useful for iterating over all available
222
+ * schemas or checking schema availability.
223
+ *
224
+ * @returns Array of reference names for all schemas
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * const components = new OasComponents({
229
+ * schemas: {
230
+ * User: userSchema,
231
+ * Product: productSchema,
232
+ * Order: orderSchema
233
+ * }
234
+ * });
235
+ *
236
+ * const schemaNames = components.toSchemasRefNames();
237
+ * console.log(schemaNames); // ['User', 'Product', 'Order']
238
+ *
239
+ * // Use for processing
240
+ * schemaNames.forEach(name => {
241
+ * const schema = components.schemas?.[name];
242
+ * console.log(`Processing schema: ${name}`);
243
+ * });
244
+ * ```
245
+ */
32
246
  toSchemasRefNames(): RefName[];
33
247
  /** Record holding re-usable {@link OasSchema} objects or Refs */
34
248
  get schemas(): Record<RefName, OasSchema | OasRef<'schema'>> | undefined;
249
+ /**
250
+ * Removes a schema from the components and returns it.
251
+ *
252
+ * This method permanently removes a schema from the components object
253
+ * and returns the removed schema. This is useful during processing when
254
+ * you need to extract and handle specific schemas separately.
255
+ *
256
+ * @param refName - The reference name of the schema to remove
257
+ * @returns The removed schema object or reference
258
+ *
259
+ * @throws {Error} When the schema doesn't exist or schemas object is undefined
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * const components = new OasComponents({
264
+ * schemas: {
265
+ * User: userSchema,
266
+ * Product: productSchema,
267
+ * Internal: internalSchema
268
+ * }
269
+ * });
270
+ *
271
+ * // Remove internal schema that shouldn't be exposed
272
+ * const internalSchema = components.removeSchema('Internal');
273
+ * console.log('Removed internal schema');
274
+ *
275
+ * // Check remaining schemas
276
+ * const remainingSchemas = components.toSchemasRefNames();
277
+ * console.log(remainingSchemas); // ['User', 'Product']
278
+ *
279
+ * // Process removed schema separately
280
+ * if (!internalSchema.isRef()) {
281
+ * console.log('Processing internal schema privately');
282
+ * }
283
+ * ```
284
+ */
35
285
  removeSchema(refName: RefName): OasSchema | OasRef<'schema'>;
36
286
  /** Record holding re-usable {@link OasResponse} objects or Refs */
37
287
  get responses(): Record<RefName, OasResponse | OasRef<'response'>> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"Components.d.ts","sourceRoot":"","sources":["../../../src/oas/components/Components.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBA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