@skmtc/core 0.0.799 → 0.0.800
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.
- package/esm/context/GenerateContext.d.ts +21 -1
- package/esm/context/GenerateContext.d.ts.map +1 -1
- package/esm/context/GenerateContext.js +21 -1
- package/esm/context/ParseContext.d.ts +64 -3
- package/esm/context/ParseContext.d.ts.map +1 -1
- package/esm/context/ParseContext.js +61 -0
- package/esm/context/ResultsHandler.d.ts +10 -3
- package/esm/context/ResultsHandler.d.ts.map +1 -1
- package/esm/dsl/model/types.d.ts +51 -4
- package/esm/dsl/model/types.d.ts.map +1 -1
- package/esm/dsl/operation/types.d.ts +61 -3
- package/esm/dsl/operation/types.d.ts.map +1 -1
- package/esm/oas/operation/Operation.d.ts +47 -2
- package/esm/oas/operation/Operation.d.ts.map +1 -1
- package/esm/oas/operation/Operation.js +43 -0
- package/esm/oas/ref/Ref.d.ts +49 -2
- package/esm/oas/ref/Ref.d.ts.map +1 -1
- package/esm/oas/ref/Ref.js +28 -0
- package/esm/typescript/List.d.ts +64 -3
- package/esm/typescript/List.d.ts.map +1 -1
- package/esm/typescript/List.js +43 -0
- package/package.json +1 -1
- package/script/context/GenerateContext.d.ts +21 -1
- package/script/context/GenerateContext.d.ts.map +1 -1
- package/script/context/GenerateContext.js +21 -1
- package/script/context/ParseContext.d.ts +64 -3
- package/script/context/ParseContext.d.ts.map +1 -1
- package/script/context/ParseContext.js +61 -0
- package/script/context/ResultsHandler.d.ts +10 -3
- package/script/context/ResultsHandler.d.ts.map +1 -1
- package/script/dsl/model/types.d.ts +51 -4
- package/script/dsl/model/types.d.ts.map +1 -1
- package/script/dsl/operation/types.d.ts +61 -3
- package/script/dsl/operation/types.d.ts.map +1 -1
- package/script/oas/operation/Operation.d.ts +47 -2
- package/script/oas/operation/Operation.d.ts.map +1 -1
- package/script/oas/operation/Operation.js +43 -0
- package/script/oas/ref/Ref.d.ts +49 -2
- package/script/oas/ref/Ref.d.ts.map +1 -1
- package/script/oas/ref/Ref.js +28 -0
- package/script/typescript/List.d.ts +64 -3
- package/script/typescript/List.d.ts.map +1 -1
- package/script/typescript/List.js +43 -0
|
@@ -255,6 +255,13 @@ class GenerateContext {
|
|
|
255
255
|
mappings: __classPrivateFieldGet(this, _GenerateContext_mappings, "f")
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Executes a function within a traced context for debugging and monitoring.
|
|
260
|
+
*
|
|
261
|
+
* @param token - Trace identifier or path segments
|
|
262
|
+
* @param fn - Function to execute within the trace context
|
|
263
|
+
* @returns The result of the traced function execution
|
|
264
|
+
*/
|
|
258
265
|
trace(token, fn) {
|
|
259
266
|
return (0, tracer_js_1.tracer)(this.stackTrail, token, fn, this.logger);
|
|
260
267
|
}
|
|
@@ -283,7 +290,12 @@ class GenerateContext {
|
|
|
283
290
|
noExport
|
|
284
291
|
});
|
|
285
292
|
}
|
|
286
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* Registers JSON content for output to a file.
|
|
295
|
+
*
|
|
296
|
+
* @experimental This method is experimental and may change in future versions
|
|
297
|
+
* @param args - Registration arguments with destination path and JSON content
|
|
298
|
+
*/
|
|
287
299
|
registerJson({ destinationPath, json }) {
|
|
288
300
|
const currentFile = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_getFile).call(this, destinationPath);
|
|
289
301
|
(0, tiny_invariant_1.default)(currentFile instanceof JsonFile_js_1.JsonFile, `File at "${destinationPath}" is not a "JsonFile" type`);
|
|
@@ -363,6 +375,14 @@ class GenerateContext {
|
|
|
363
375
|
});
|
|
364
376
|
return new Inserted_js_1.Inserted({ settings, definition });
|
|
365
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* Inserts a normalized model definition into the generation context.
|
|
380
|
+
*
|
|
381
|
+
* @param insertable - Model insertable configuration with prototype and transform functions
|
|
382
|
+
* @param schema - OAS schema, reference, or void type to generate model from
|
|
383
|
+
* @param options - Insertion options including generation type and destination
|
|
384
|
+
* @returns Inserted model instance with settings and definition
|
|
385
|
+
*/
|
|
366
386
|
insertNormalisedModel(insertable, { schema, fallbackName, destinationPath }, { noExport = false } = {}) {
|
|
367
387
|
if (schema.isRef()) {
|
|
368
388
|
const { definition } = this.insertModel(insertable, schema.toRefName(), {
|
|
@@ -30,7 +30,7 @@ export type ParseReturn = {
|
|
|
30
30
|
/**
|
|
31
31
|
* Base type for parse warning messages.
|
|
32
32
|
*/
|
|
33
|
-
type ParseWarningBase = {
|
|
33
|
+
export type ParseWarningBase = {
|
|
34
34
|
/** Issue severity level */
|
|
35
35
|
level: 'warning';
|
|
36
36
|
/** Warning message */
|
|
@@ -39,7 +39,7 @@ type ParseWarningBase = {
|
|
|
39
39
|
/**
|
|
40
40
|
* Base type for parse error messages.
|
|
41
41
|
*/
|
|
42
|
-
type ParseErrorBase = {
|
|
42
|
+
export type ParseErrorBase = {
|
|
43
43
|
/** Issue severity level */
|
|
44
44
|
level: 'error';
|
|
45
45
|
/** The error that occurred */
|
|
@@ -48,7 +48,7 @@ type ParseErrorBase = {
|
|
|
48
48
|
/**
|
|
49
49
|
* Base union type for parse issues.
|
|
50
50
|
*/
|
|
51
|
-
type ParseIssueBase = ParseErrorBase | ParseWarningBase;
|
|
51
|
+
export type ParseIssueBase = ParseErrorBase | ParseWarningBase;
|
|
52
52
|
/**
|
|
53
53
|
* Arguments for logging issues with a specific key.
|
|
54
54
|
*/
|
|
@@ -253,17 +253,78 @@ export declare class ParseContext {
|
|
|
253
253
|
issues: ParseIssue[];
|
|
254
254
|
/** Whether to suppress console output during parsing */
|
|
255
255
|
silent: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Creates a new ParseContext instance for the parsing phase.
|
|
258
|
+
*
|
|
259
|
+
* @param args - Constructor arguments including document object, logger, and options
|
|
260
|
+
*/
|
|
256
261
|
constructor({ documentObject, logger, stackTrail, silent }: ConstructorArgs);
|
|
262
|
+
/**
|
|
263
|
+
* Parses the OpenAPI v3 document and returns the internal OAS document representation.
|
|
264
|
+
*
|
|
265
|
+
* @returns Parsed OAS document with all components and operations
|
|
266
|
+
*/
|
|
257
267
|
parse(): OasDocument;
|
|
268
|
+
/**
|
|
269
|
+
* Removes items from the parsed document that encountered errors during parsing.
|
|
270
|
+
*/
|
|
258
271
|
removeErroredItems(): void;
|
|
272
|
+
/**
|
|
273
|
+
* Registers a reference ($ref) with its associated stack trail for error tracking.
|
|
274
|
+
*
|
|
275
|
+
* @param stackTrail - Current processing context stack trail
|
|
276
|
+
* @param $ref - OpenAPI reference string to register
|
|
277
|
+
*/
|
|
259
278
|
registerRef(stackTrail: StackTrail, $ref: string): void;
|
|
279
|
+
/**
|
|
280
|
+
* Registers an error that occurred while processing a reference.
|
|
281
|
+
*
|
|
282
|
+
* @param error - Error that occurred during reference processing
|
|
283
|
+
* @param $ref - Reference string that caused the error (if available)
|
|
284
|
+
*/
|
|
260
285
|
registerRefError(error: Error, $ref: string | undefined): void;
|
|
286
|
+
/**
|
|
287
|
+
* Executes a function within a traced context for debugging and monitoring.
|
|
288
|
+
*
|
|
289
|
+
* @param token - Trace identifier or path segments
|
|
290
|
+
* @param fn - Function to execute within the trace context
|
|
291
|
+
* @returns The result of the traced function execution
|
|
292
|
+
*/
|
|
261
293
|
trace<T>(token: string | string[], fn: () => T): T;
|
|
294
|
+
/**
|
|
295
|
+
* Logs warnings for fields that were skipped during parsing.
|
|
296
|
+
*
|
|
297
|
+
* @param args - Arguments containing skipped fields and parent context
|
|
298
|
+
*/
|
|
262
299
|
logSkippedFields({ skipped, parent, parentType }: LogSkippedValuesArgs): void;
|
|
300
|
+
/**
|
|
301
|
+
* Attempts to parse a value with optional error handling and logging.
|
|
302
|
+
*
|
|
303
|
+
* @param args - Parsing arguments including schema and error handling
|
|
304
|
+
* @returns Parsed value or undefined if parsing fails
|
|
305
|
+
*/
|
|
263
306
|
provisionalParse<T>({ key, value, parent, schema, toMessage, type }: ProvisionalParseArgs<T>): T | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* Logs a parsing issue with associated key context.
|
|
309
|
+
*
|
|
310
|
+
* @param args - Issue arguments including key, parent object, and issue details
|
|
311
|
+
*/
|
|
264
312
|
logIssue({ key, parent, type, ...issue }: LogIssueArgs): void;
|
|
313
|
+
/**
|
|
314
|
+
* Logs a parsing issue without specific key context.
|
|
315
|
+
*
|
|
316
|
+
* @param args - Issue arguments including parent object and issue details
|
|
317
|
+
*/
|
|
265
318
|
logIssueNoKey({ parent, type, ...issue }: LogIssueNoKeyArgs): void;
|
|
266
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Parses an OpenAPI v3 schema from string format (JSON or YAML).
|
|
322
|
+
*
|
|
323
|
+
* Automatically detects the format based on content and parses accordingly.
|
|
324
|
+
*
|
|
325
|
+
* @param schema - Schema string in JSON or YAML format
|
|
326
|
+
* @returns Parsed OpenAPI v3 document object
|
|
327
|
+
*/
|
|
267
328
|
export declare const parseSchema: (schema: string) => OpenAPIV3.Document;
|
|
268
329
|
export {};
|
|
269
330
|
//# sourceMappingURL=ParseContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParseContext.d.ts","sourceRoot":"","sources":["../../src/context/ParseContext.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAG9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,GAAG,MAAM,yCAAyC,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;GAEG;AACH,KAAK,eAAe,GAAG;IACrB,uCAAuC;IACvC,cAAc,EAAE,SAAS,CAAC,QAAQ,CAAA;IAClC,4CAA4C;IAC5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IACH,kBAAkB;IAoBlB;;;;;OAKG;IACH,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM;IAMhD;;;;;OAKG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS;IAQvD;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAIlD;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,oBAAoB;IAYtE;;;;;OAKG;IACH,gBAAgB,CAAC,CAAC,EAAE,EAClB,GAAG,EACH,KAAK,EACL,MAAM,EACN,MAAM,EACN,SAAS,EACT,IAAI,EACL,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;IAgB1C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY;IAItD;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB;CAqB5D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,KAAG,SAAS,CAAC,QAMtD,CAAA"}
|
|
@@ -161,6 +161,11 @@ const v = __importStar(require("valibot"));
|
|
|
161
161
|
* ```
|
|
162
162
|
*/
|
|
163
163
|
class ParseContext {
|
|
164
|
+
/**
|
|
165
|
+
* Creates a new ParseContext instance for the parsing phase.
|
|
166
|
+
*
|
|
167
|
+
* @param args - Constructor arguments including document object, logger, and options
|
|
168
|
+
*/
|
|
164
169
|
constructor({ documentObject, logger, stackTrail, silent = true }) {
|
|
165
170
|
/** The original OpenAPI v3 document being parsed */
|
|
166
171
|
Object.defineProperty(this, "documentObject", {
|
|
@@ -215,6 +220,11 @@ class ParseContext {
|
|
|
215
220
|
__classPrivateFieldSet(this, _ParseContext_refStackTrails, {}, "f");
|
|
216
221
|
__classPrivateFieldSet(this, _ParseContext_refErrors, {}, "f");
|
|
217
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Parses the OpenAPI v3 document and returns the internal OAS document representation.
|
|
225
|
+
*
|
|
226
|
+
* @returns Parsed OAS document with all components and operations
|
|
227
|
+
*/
|
|
218
228
|
parse() {
|
|
219
229
|
this.oasDocument.fields = (0, toDocumentFieldsV3_js_1.toDocumentFieldsV3)({
|
|
220
230
|
documentObject: this.documentObject,
|
|
@@ -223,6 +233,9 @@ class ParseContext {
|
|
|
223
233
|
this.removeErroredItems();
|
|
224
234
|
return this.oasDocument;
|
|
225
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Removes items from the parsed document that encountered errors during parsing.
|
|
238
|
+
*/
|
|
226
239
|
removeErroredItems() {
|
|
227
240
|
Object.entries(__classPrivateFieldGet(this, _ParseContext_refErrors, "f")).forEach(([$ref, errors]) => {
|
|
228
241
|
errors.forEach(error => {
|
|
@@ -241,19 +254,43 @@ class ParseContext {
|
|
|
241
254
|
});
|
|
242
255
|
});
|
|
243
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* Registers a reference ($ref) with its associated stack trail for error tracking.
|
|
259
|
+
*
|
|
260
|
+
* @param stackTrail - Current processing context stack trail
|
|
261
|
+
* @param $ref - OpenAPI reference string to register
|
|
262
|
+
*/
|
|
244
263
|
registerRef(stackTrail, $ref) {
|
|
245
264
|
const refStackTrails = __classPrivateFieldGet(this, _ParseContext_refStackTrails, "f")[$ref];
|
|
246
265
|
refStackTrails ? refStackTrails.push(stackTrail) : (__classPrivateFieldGet(this, _ParseContext_refStackTrails, "f")[$ref] = [stackTrail]);
|
|
247
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Registers an error that occurred while processing a reference.
|
|
269
|
+
*
|
|
270
|
+
* @param error - Error that occurred during reference processing
|
|
271
|
+
* @param $ref - Reference string that caused the error (if available)
|
|
272
|
+
*/
|
|
248
273
|
registerRefError(error, $ref) {
|
|
249
274
|
if ($ref) {
|
|
250
275
|
const refErrors = __classPrivateFieldGet(this, _ParseContext_refErrors, "f")[$ref];
|
|
251
276
|
refErrors ? refErrors.push(error) : (__classPrivateFieldGet(this, _ParseContext_refErrors, "f")[$ref] = [error]);
|
|
252
277
|
}
|
|
253
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Executes a function within a traced context for debugging and monitoring.
|
|
281
|
+
*
|
|
282
|
+
* @param token - Trace identifier or path segments
|
|
283
|
+
* @param fn - Function to execute within the trace context
|
|
284
|
+
* @returns The result of the traced function execution
|
|
285
|
+
*/
|
|
254
286
|
trace(token, fn) {
|
|
255
287
|
return (0, tracer_js_1.tracer)(this.stackTrail, token, fn, this.logger);
|
|
256
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Logs warnings for fields that were skipped during parsing.
|
|
291
|
+
*
|
|
292
|
+
* @param args - Arguments containing skipped fields and parent context
|
|
293
|
+
*/
|
|
257
294
|
logSkippedFields({ skipped, parent, parentType }) {
|
|
258
295
|
Object.keys(skipped).forEach(key => {
|
|
259
296
|
this.logIssue({
|
|
@@ -265,6 +302,12 @@ class ParseContext {
|
|
|
265
302
|
});
|
|
266
303
|
});
|
|
267
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Attempts to parse a value with optional error handling and logging.
|
|
307
|
+
*
|
|
308
|
+
* @param args - Parsing arguments including schema and error handling
|
|
309
|
+
* @returns Parsed value or undefined if parsing fails
|
|
310
|
+
*/
|
|
268
311
|
provisionalParse({ key, value, parent, schema, toMessage, type }) {
|
|
269
312
|
const parsed = v.safeParse(v.optional(schema), value);
|
|
270
313
|
if (parsed.success) {
|
|
@@ -278,9 +321,19 @@ class ParseContext {
|
|
|
278
321
|
type
|
|
279
322
|
});
|
|
280
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Logs a parsing issue with associated key context.
|
|
326
|
+
*
|
|
327
|
+
* @param args - Issue arguments including key, parent object, and issue details
|
|
328
|
+
*/
|
|
281
329
|
logIssue({ key, parent, type, ...issue }) {
|
|
282
330
|
this.trace(key, () => this.logIssueNoKey({ parent, type, ...issue }));
|
|
283
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Logs a parsing issue without specific key context.
|
|
334
|
+
*
|
|
335
|
+
* @param args - Issue arguments including parent object and issue details
|
|
336
|
+
*/
|
|
284
337
|
logIssueNoKey({ parent, type, ...issue }) {
|
|
285
338
|
if (issue.level === 'error') {
|
|
286
339
|
this.registerRefError(issue.error, this.stackTrail.toStackRef());
|
|
@@ -303,6 +356,14 @@ class ParseContext {
|
|
|
303
356
|
}
|
|
304
357
|
exports.ParseContext = ParseContext;
|
|
305
358
|
_ParseContext_refStackTrails = new WeakMap(), _ParseContext_refErrors = new WeakMap();
|
|
359
|
+
/**
|
|
360
|
+
* Parses an OpenAPI v3 schema from string format (JSON or YAML).
|
|
361
|
+
*
|
|
362
|
+
* Automatically detects the format based on content and parses accordingly.
|
|
363
|
+
*
|
|
364
|
+
* @param schema - Schema string in JSON or YAML format
|
|
365
|
+
* @returns Parsed OpenAPI v3 document object
|
|
366
|
+
*/
|
|
306
367
|
const parseSchema = (schema) => {
|
|
307
368
|
if (schema.trimStart().startsWith('{')) {
|
|
308
369
|
return JSON.parse(schema);
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { type LevelName } from '../deps/jsr.io/@std/log/0.224.14/levels.js';
|
|
2
2
|
import type { LogRecord } from '../deps/jsr.io/@std/log/0.224.14/logger.js';
|
|
3
3
|
import { BaseHandler } from '../deps/jsr.io/@std/log/0.224.14/base_handler.js';
|
|
4
|
-
import type { BaseHandlerOptions } from '../deps/jsr.io/@std/log/0.224.14/base_handler.js';
|
|
5
4
|
import type { CoreContext } from './CoreContext.js';
|
|
5
|
+
/**
|
|
6
|
+
* Base log handler interface for extending Deno standard library handlers.
|
|
7
|
+
*/
|
|
8
|
+
export interface LogHandlerBase {
|
|
9
|
+
handle(logRecord: LogRecord): void;
|
|
10
|
+
}
|
|
6
11
|
/**
|
|
7
12
|
* Configuration options for the {@link ResultsHandler}.
|
|
8
13
|
*/
|
|
9
|
-
export interface ResultsHandlerOptions
|
|
14
|
+
export interface ResultsHandlerOptions {
|
|
10
15
|
/** The CoreContext instance to capture results to */
|
|
11
16
|
context: CoreContext;
|
|
17
|
+
/** Formatter function for log messages */
|
|
18
|
+
formatter?: (logRecord: LogRecord) => string;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* Custom log handler that captures warning and error results for SKMTC processing.
|
|
@@ -77,7 +84,7 @@ export interface ResultsHandlerOptions extends BaseHandlerOptions {
|
|
|
77
84
|
* }
|
|
78
85
|
* ```
|
|
79
86
|
*/
|
|
80
|
-
export declare class ResultsHandler extends BaseHandler {
|
|
87
|
+
export declare class ResultsHandler extends BaseHandler implements LogHandlerBase {
|
|
81
88
|
#private;
|
|
82
89
|
/** The CoreContext instance for capturing results */
|
|
83
90
|
context: CoreContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultsHandler.d.ts","sourceRoot":"","sources":["../../src/context/ResultsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,4CAA4C,CAAA;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAC9E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ResultsHandler.d.ts","sourceRoot":"","sources":["../../src/context/ResultsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,4CAA4C,CAAA;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4CAA4C,CAAA;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,qDAAqD;IACrD,OAAO,EAAE,WAAW,CAAA;IACpB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,MAAM,CAAA;CAC7C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,qBAAa,cAAe,SAAQ,WAAY,YAAW,cAAc;;IACvE,qDAAqD;IACrD,OAAO,EAAE,WAAW,CAAA;IAOpB;;;;;;;;;;;;;;OAcG;gBACS,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB;IAMhE;;;;;;;OAOG;IACM,KAAK;IAMd;;;;;;;;;OASG;IACM,MAAM,CAAC,SAAS,EAAE,SAAS;IASpC;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,CAAC,SAAS,EAAE,MAAM;IAWrB;;;;;;;OAOG;IACH,KAAK;IAWL;;;;;;;;;;;;;;;;;;;;;OAqBG;IACM,OAAO;CAKjB"}
|
|
@@ -6,33 +6,73 @@ import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
|
6
6
|
import type * as v from 'valibot';
|
|
7
7
|
import type { MappingModule, PreviewModule } from '../../types/Preview.js';
|
|
8
8
|
import type { SchemaToValueFn } from '../../types/TypeSystem.js';
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Constructor arguments for model insertable instances.
|
|
11
|
+
*
|
|
12
|
+
* @template EnrichmentType - Optional enrichment data type for additional metadata
|
|
13
|
+
*/
|
|
14
|
+
export type ModelInsertableConstructorArgs<EnrichmentType = undefined> = {
|
|
10
15
|
context: GenerateContext;
|
|
11
16
|
refName: RefName;
|
|
12
17
|
settings: ContentSettings<EnrichmentType>;
|
|
13
18
|
destinationPath: string;
|
|
14
19
|
rootRef?: RefName;
|
|
15
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Interface for objects that provide model transformation capabilities.
|
|
23
|
+
*
|
|
24
|
+
* Used by generator configurations to transform model definitions
|
|
25
|
+
* during the code generation process.
|
|
26
|
+
*/
|
|
16
27
|
export type WithTransformModel = {
|
|
17
28
|
transformModel: (refName: RefName) => void;
|
|
18
29
|
};
|
|
19
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Arguments for generating enrichment data for models.
|
|
32
|
+
*/
|
|
33
|
+
export type ModelToEnrichmentsArgs = {
|
|
20
34
|
refName: RefName;
|
|
21
35
|
context: GenerateContext;
|
|
22
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Arguments passed to model transformation functions.
|
|
39
|
+
*
|
|
40
|
+
* @template Acc - Accumulator type for collecting transformation results
|
|
41
|
+
*/
|
|
23
42
|
export type TransformModelArgs<Acc> = {
|
|
24
43
|
context: GenerateContext;
|
|
25
44
|
refName: RefName;
|
|
26
45
|
acc: Acc | undefined;
|
|
27
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Arguments for generating model preview modules.
|
|
49
|
+
*
|
|
50
|
+
* Preview modules provide quick insights into generated models
|
|
51
|
+
* without full code generation.
|
|
52
|
+
*/
|
|
28
53
|
export type ToModelPreviewModuleArgs = {
|
|
29
54
|
context: GenerateContext;
|
|
30
55
|
refName: RefName;
|
|
31
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Arguments for generating model mapping information.
|
|
59
|
+
*
|
|
60
|
+
* Mappings track relationships between OAS schemas and generated models,
|
|
61
|
+
* enabling cross-references and dependency analysis.
|
|
62
|
+
*/
|
|
32
63
|
export type ToModelMappingArgs = {
|
|
33
64
|
context: GenerateContext;
|
|
34
65
|
refName: RefName;
|
|
35
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Configuration object for insertable model generators.
|
|
69
|
+
*
|
|
70
|
+
* Defines the contract for model generator classes that can be inserted
|
|
71
|
+
* into the generation context to produce type-safe model definitions.
|
|
72
|
+
*
|
|
73
|
+
* @template V - Generated value type produced by the model generator
|
|
74
|
+
* @template EnrichmentType - Optional enrichment data type for additional metadata
|
|
75
|
+
*/
|
|
36
76
|
export type ModelInsertable<V, EnrichmentType = undefined> = {
|
|
37
77
|
prototype: V;
|
|
38
78
|
} & {
|
|
@@ -41,10 +81,18 @@ export type ModelInsertable<V, EnrichmentType = undefined> = {
|
|
|
41
81
|
type: 'model';
|
|
42
82
|
toIdentifier: (refName: RefName) => Identifier;
|
|
43
83
|
toExportPath: (refName: RefName) => string;
|
|
44
|
-
toEnrichments: ({ refName, context }:
|
|
84
|
+
toEnrichments: ({ refName, context }: ModelToEnrichmentsArgs) => EnrichmentType;
|
|
45
85
|
schemaToValueFn: SchemaToValueFn;
|
|
46
86
|
createIdentifier: (name: string) => Identifier;
|
|
47
87
|
} & Function;
|
|
88
|
+
/**
|
|
89
|
+
* Configuration object for model generators.
|
|
90
|
+
*
|
|
91
|
+
* Defines the behavior and capabilities of model generators including
|
|
92
|
+
* transformation logic, preview generation, and enrichment handling.
|
|
93
|
+
*
|
|
94
|
+
* @template EnrichmentType - Optional enrichment data type for additional metadata
|
|
95
|
+
*/
|
|
48
96
|
export type ModelConfig<EnrichmentType = undefined> = {
|
|
49
97
|
id: string;
|
|
50
98
|
type: 'model';
|
|
@@ -54,5 +102,4 @@ export type ModelConfig<EnrichmentType = undefined> = {
|
|
|
54
102
|
toEnrichmentSchema?: () => v.BaseSchema<EnrichmentType, EnrichmentType, v.BaseIssue<unknown>>;
|
|
55
103
|
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(refName: RefName) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
56
104
|
};
|
|
57
|
-
export {};
|
|
58
105
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/model/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,CAAC,cAAc,GAAG,SAAS,IAAI;IACvE,OAAO,EAAE,eAAe,CAAA;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,CA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AK,cAAc,CAAA;IAC/E,eAAe,EAAE,eAAe,CAAA;IAChC,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,CAAA;CAE/C,GAAG,QAAQ,CAAA;AAEZ;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CAAC,cAAc,GAAG,SAAS,IAAI;IACpD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,OAAO,CAAA;IACb,SAAS,EAAE,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,kBAAkB,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IAClF,eAAe,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,wBAAwB,KAAK,aAAa,CAAA;IACnF,eAAe,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,kBAAkB,KAAK,aAAa,CAAA;IAC7E,kBAAkB,CAAC,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,cAAc,EAAE,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7F,mBAAmB,CAAC,EAAE,CAAC,mBAAmB,SAAS,cAAc,EAC/D,OAAO,EAAE,OAAO,KACb,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAA;CACxD,CAAA"}
|
|
@@ -5,40 +5,88 @@ import type { Identifier } from '../Identifier.js';
|
|
|
5
5
|
import type { EnrichmentRequest } from '../../types/EnrichmentRequest.js';
|
|
6
6
|
import type * as v from 'valibot';
|
|
7
7
|
import type { MappingModule, PreviewModule } from '../../types/Preview.js';
|
|
8
|
+
/**
|
|
9
|
+
* Arguments passed to operation insertable constructors.
|
|
10
|
+
*
|
|
11
|
+
* @template EnrichmentType - Optional enrichment data type for additional metadata
|
|
12
|
+
*/
|
|
8
13
|
export type OperationInsertableArgs<EnrichmentType = undefined> = {
|
|
9
14
|
context: GenerateContext;
|
|
10
15
|
settings: ContentSettings<EnrichmentType>;
|
|
11
16
|
operation: OasOperation;
|
|
12
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Arguments passed to operation transformation functions.
|
|
20
|
+
*
|
|
21
|
+
* @template Acc - Accumulator type for collecting transformation results
|
|
22
|
+
*/
|
|
13
23
|
export type TransformOperationArgs<Acc> = {
|
|
14
24
|
context: GenerateContext;
|
|
15
25
|
operation: OasOperation;
|
|
16
26
|
acc: Acc | undefined;
|
|
17
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Interface for objects that provide operation transformation capabilities.
|
|
30
|
+
*
|
|
31
|
+
* Used by generator configurations to transform operation definitions
|
|
32
|
+
* during the code generation process.
|
|
33
|
+
*/
|
|
18
34
|
export type WithTransformOperation = {
|
|
19
35
|
transformOperation: (operation: OasOperation) => void;
|
|
20
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Arguments for checking if an operation is supported with enrichment configuration.
|
|
39
|
+
*
|
|
40
|
+
* @template EnrichmentType - Optional enrichment data type for additional metadata
|
|
41
|
+
*/
|
|
21
42
|
export type IsSupportedOperationConfigArgs<EnrichmentType = undefined> = {
|
|
22
43
|
context: GenerateContext;
|
|
23
44
|
operation: OasOperation;
|
|
24
45
|
enrichments: EnrichmentType;
|
|
25
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Arguments for checking if an operation is supported for code generation.
|
|
49
|
+
*/
|
|
26
50
|
export type IsSupportedOperationArgs = {
|
|
27
51
|
context: GenerateContext;
|
|
28
52
|
operation: OasOperation;
|
|
29
53
|
};
|
|
30
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Arguments for generating enrichment data for operations.
|
|
56
|
+
*/
|
|
57
|
+
export type OperationToEnrichmentsArgs = {
|
|
31
58
|
operation: OasOperation;
|
|
32
59
|
context: GenerateContext;
|
|
33
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Arguments for generating operation preview modules.
|
|
63
|
+
*
|
|
64
|
+
* Preview modules provide quick insights into generated operations
|
|
65
|
+
* without full code generation.
|
|
66
|
+
*/
|
|
34
67
|
export type ToOperationPreviewModuleArgs = {
|
|
35
68
|
context: GenerateContext;
|
|
36
69
|
operation: OasOperation;
|
|
37
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Arguments for generating operation mapping information.
|
|
73
|
+
*
|
|
74
|
+
* Mappings track relationships between OAS operations and generated code,
|
|
75
|
+
* enabling cross-references and dependency analysis.
|
|
76
|
+
*/
|
|
38
77
|
export type ToOperationMappingArgs = {
|
|
39
78
|
context: GenerateContext;
|
|
40
79
|
operation: OasOperation;
|
|
41
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Configuration object for insertable operation generators.
|
|
83
|
+
*
|
|
84
|
+
* Defines the contract for operation generator classes that can be inserted
|
|
85
|
+
* into the generation context to produce type-safe operation definitions.
|
|
86
|
+
*
|
|
87
|
+
* @template V - Generated value type produced by the operation generator
|
|
88
|
+
* @template EnrichmentType - Optional enrichment data type for additional metadata
|
|
89
|
+
*/
|
|
42
90
|
export type OperationInsertable<V, EnrichmentType = undefined> = {
|
|
43
91
|
prototype: V;
|
|
44
92
|
} & {
|
|
@@ -47,12 +95,23 @@ export type OperationInsertable<V, EnrichmentType = undefined> = {
|
|
|
47
95
|
type: 'operation';
|
|
48
96
|
toIdentifier: (operation: OasOperation) => Identifier;
|
|
49
97
|
toExportPath: (operation: OasOperation) => string;
|
|
50
|
-
toEnrichments: ({ operation, context }:
|
|
98
|
+
toEnrichments: ({ operation, context }: OperationToEnrichmentsArgs) => EnrichmentType;
|
|
51
99
|
} & Function;
|
|
100
|
+
/**
|
|
101
|
+
* Arguments for checking if an operation is supported for generation.
|
|
102
|
+
*/
|
|
52
103
|
export type IsSupportedArgs = {
|
|
53
104
|
context: GenerateContext;
|
|
54
105
|
operation: OasOperation;
|
|
55
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Configuration object for operation generators.
|
|
109
|
+
*
|
|
110
|
+
* Defines the behavior and capabilities of operation generators including
|
|
111
|
+
* support detection, transformation logic, and enrichment handling.
|
|
112
|
+
*
|
|
113
|
+
* @template EnrichmentType - Optional enrichment data type for additional metadata
|
|
114
|
+
*/
|
|
56
115
|
export type OperationConfig<EnrichmentType = undefined> = {
|
|
57
116
|
id: string;
|
|
58
117
|
type: 'operation';
|
|
@@ -63,5 +122,4 @@ export type OperationConfig<EnrichmentType = undefined> = {
|
|
|
63
122
|
toMappingModule?: ({ context, operation }: ToOperationMappingArgs) => MappingModule;
|
|
64
123
|
toEnrichmentRequest?: <RequestedEnrichment extends EnrichmentType>(operation: OasOperation) => EnrichmentRequest<RequestedEnrichment> | undefined;
|
|
65
124
|
};
|
|
66
|
-
export {};
|
|
67
125
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/dsl/operation/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC1E,MAAM,MAAM,uBAAuB,CAAC,cAAc,GAAG,SAAS,IAAI;IAChE,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,CAAA;IACzC,SAAS,EAAE,YAAY,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,sBAAsB,CAAC,GAAG,IAAI;IACxC,OAAO,EAAE,eAAe,CAA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E,YAAY,KAAK,MAAM,CAAA;IACjD,aAAa,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,0BAA0B,KAAK,cAAc,CAAA;CAEtF,GAAG,QAAQ,CAAA;AAEZ;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,EAAE,YAAY,CAAA;CACxB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,cAAc,GAAG,SAAS,IAAI;IACxD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,EAAE,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,sBAAsB,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;IACxF,kBAAkB,CAAC,EAAE,MAAM,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA;IAC1D,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,eAAe,KAAK,OAAO,CAAA;IACjE,eAAe,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,4BAA4B,KAAK,aAAa,CAAA;IACzF,eAAe,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,sBAAsB,KAAK,aAAa,CAAA;IACnF,mBAAmB,CAAC,EAAE,CAAC,mBAAmB,SAAS,cAAc,EAC/D,SAAS,EAAE,YAAY,KACpB,iBAAiB,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAA;CACxD,CAAA"}
|
|
@@ -46,7 +46,10 @@ export type OperationFields = {
|
|
|
46
46
|
/** OpenAPI specification extensions */
|
|
47
47
|
extensionFields?: Record<string, unknown>;
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Arguments passed to request body mapping functions.
|
|
51
|
+
*/
|
|
52
|
+
export type ToRequestBodyMapArgs = {
|
|
50
53
|
schema: OasSchema | OasRef<'schema'>;
|
|
51
54
|
requestBody: OasRequestBody;
|
|
52
55
|
};
|
|
@@ -186,9 +189,35 @@ export declare class OasOperation {
|
|
|
186
189
|
deprecated: boolean | undefined;
|
|
187
190
|
/** OpenAPI specification extensions */
|
|
188
191
|
extensionFields: Record<string, unknown> | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* Creates a new OasOperation instance from operation field data.
|
|
194
|
+
*
|
|
195
|
+
* @param fields - Operation field data from OpenAPI specification
|
|
196
|
+
*/
|
|
189
197
|
constructor(fields: OperationFields);
|
|
198
|
+
/**
|
|
199
|
+
* Returns the successful response definition for this operation.
|
|
200
|
+
*
|
|
201
|
+
* Looks for the lowest numbered 2xx response code and returns its response definition.
|
|
202
|
+
*
|
|
203
|
+
* @returns Success response object or undefined if none found
|
|
204
|
+
*/
|
|
190
205
|
toSuccessResponse(): OasResponse | OasRef<'response'> | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* Returns the HTTP status code for the primary success response.
|
|
208
|
+
*
|
|
209
|
+
* Finds the lowest numbered 2xx status code in the responses.
|
|
210
|
+
*
|
|
211
|
+
* @returns Success status code as string or undefined if none found
|
|
212
|
+
*/
|
|
191
213
|
toSuccessResponseCode(): string | undefined;
|
|
214
|
+
/**
|
|
215
|
+
* Maps the request body schema to a custom value using the provided mapping function.
|
|
216
|
+
*
|
|
217
|
+
* @param map - Function to transform the request body schema and metadata
|
|
218
|
+
* @param mediaType - Media type to extract schema from (default: 'application/json')
|
|
219
|
+
* @returns Mapped value or undefined if no request body schema found
|
|
220
|
+
*/
|
|
192
221
|
toRequestBody<V>(map: ({ schema, requestBody }: ToRequestBodyMapArgs) => V, mediaType?: string): V | undefined;
|
|
193
222
|
/**
|
|
194
223
|
* Resolve all parameters and optionally filter by location
|
|
@@ -197,9 +226,25 @@ export declare class OasOperation {
|
|
|
197
226
|
* @returns
|
|
198
227
|
*/
|
|
199
228
|
toParams(filter?: OasParameterLocation[]): OasParameter[];
|
|
229
|
+
/**
|
|
230
|
+
* Creates an OAS object representation of operation parameters.
|
|
231
|
+
*
|
|
232
|
+
* @param filter - Optional array of parameter locations to include
|
|
233
|
+
* @returns OAS object with parameter properties
|
|
234
|
+
*/
|
|
200
235
|
toParametersObject(filter?: OasParameterLocation[]): OasObject;
|
|
236
|
+
/**
|
|
237
|
+
* Converts the operation to OpenAPI v3 JSON schema format.
|
|
238
|
+
*
|
|
239
|
+
* @param options - Conversion options for nested components
|
|
240
|
+
* @returns OpenAPI v3 operation object
|
|
241
|
+
*/
|
|
201
242
|
toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.OperationObject;
|
|
243
|
+
/**
|
|
244
|
+
* Serializes the operation to a plain JavaScript object.
|
|
245
|
+
*
|
|
246
|
+
* @returns Plain object representation of the operation
|
|
247
|
+
*/
|
|
202
248
|
toJSON(): object;
|
|
203
249
|
}
|
|
204
|
-
export {};
|
|
205
250
|
//# sourceMappingURL=Operation.d.ts.map
|