@@ -88,6 +88,10 @@ interface GenerateApiParams {
8888 * extract request params to data contract (Also combine path params and query params into one object)
8989 */
9090 extractRequestParams ?: boolean ;
91+ /**
92+ * extract request body type to data contract
93+ */
94+ extractRequestBody ?: boolean ;
9195 /**
9296 * prettier configuration
9397 */
@@ -131,14 +135,9 @@ export interface Hooks {
131135 /** customize configuration object before sending it to ETA templates */
132136 onPrepareConfig ?: < C extends GenerateApiConfiguration > ( currentConfiguration : C ) => C | void ;
133137 /** customize route name as you need */
134- onCreateRouteName ?: (
135- routeNameInfo : RouteNameInfo ,
136- rawRouteInfo : RawRouteInfo ,
137- ) => RouteNameInfo | void ;
138+ onCreateRouteName ?: ( routeNameInfo : RouteNameInfo , rawRouteInfo : RawRouteInfo ) => RouteNameInfo | void ;
138139 /** customize request params (path params, query params) */
139- onCreateRequestParams ?: (
140- rawType : SchemaComponent [ "rawTypeData" ] ,
141- ) => SchemaComponent [ "rawTypeData" ] | void ;
140+ onCreateRequestParams ?: ( rawType : SchemaComponent [ "rawTypeData" ] ) => SchemaComponent [ "rawTypeData" ] | void ;
142141 /** customize name of model type */
143142 onFormatTypeName ?: ( typeName : string , rawTypeName ?: string ) => string | void ;
144143 /** customize name of route (operationId), you can do it with using onCreateRouteName too */
@@ -215,14 +214,10 @@ export interface SchemaComponent {
215214 discriminator ?: {
216215 propertyName ?: string ;
217216 } ;
218- $parsed : ParsedSchema <
219- SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent
220- > ;
217+ $parsed : ParsedSchema < SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent > ;
221218 } ;
222219 componentName : string ;
223- typeData : ParsedSchema <
224- SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent
225- > | null ;
220+ typeData : ParsedSchema < SchemaTypeObjectContent | SchemaTypeEnumContent | SchemaTypePrimitiveContent > | null ;
226221}
227222
228223export enum RequestContentKind {
@@ -346,25 +341,16 @@ export interface GenerateApiConfiguration {
346341 formatDescription : ( description : string , inline ?: boolean ) => string ;
347342 internalCase : ( value : string ) => string ;
348343 classNameCase : ( value : string ) => string ;
349- getInlineParseContent : (
350- rawTypeData : SchemaComponent [ "rawTypeData" ] ,
351- typeName ?: string ,
352- ) => string ;
344+ getInlineParseContent : ( rawTypeData : SchemaComponent [ "rawTypeData" ] , typeName ?: string ) => string ;
353345 getParseContent : ( rawTypeData : SchemaComponent [ "rawTypeData" ] , typeName ?: string ) => ModelType ;
354346 getComponentByRef : ( ref : string ) => SchemaComponent ;
355347 parseSchema : (
356348 rawSchema : string | SchemaComponent [ "rawTypeData" ] ,
357349 typeName ?: string ,
358350 formattersMap ?: Record < MAIN_SCHEMA_TYPES , ( content : ModelType ) => string > ,
359351 ) => ModelType ;
360- formatters : Record <
361- MAIN_SCHEMA_TYPES ,
362- ( content : string | object | string [ ] | object [ ] ) => string
363- > ;
364- inlineExtraFormatters : Record <
365- Exclude < MAIN_SCHEMA_TYPES , SCHEMA_TYPES . PRIMITIVE > ,
366- ( schema : ModelType ) => string
367- > ;
352+ formatters : Record < MAIN_SCHEMA_TYPES , ( content : string | object | string [ ] | object [ ] ) => string > ;
353+ inlineExtraFormatters : Record < Exclude < MAIN_SCHEMA_TYPES , SCHEMA_TYPES . PRIMITIVE > , ( schema : ModelType ) => string > ;
368354 formatModelName : ( name : string ) => string ;
369355 fmtToJSDocLine : ( line : string , params ?: { eol ?: boolean } ) => string ;
370356 _ : import ( "lodash" ) . LoDashStatic ;
@@ -375,12 +361,7 @@ export interface GenerateApiConfiguration {
375361export interface GenerateApiOutput {
376362 configuration : GenerateApiConfiguration ;
377363 files : { name : string ; content : string ; declaration : { name : string ; content : string } | null } [ ] ;
378- createFile : ( params : {
379- path : string ;
380- fileName : string ;
381- content : string ;
382- withPrefix ?: boolean ;
383- } ) => void ;
364+ createFile : ( params : { path : string ; fileName : string ; content : string ; withPrefix ?: boolean } ) => void ;
384365 renderTemplate : (
385366 templateContent : string ,
386367 data : Record < string , unknown > ,
@@ -390,12 +371,6 @@ export interface GenerateApiOutput {
390371 formatTSContent : ( content : string ) => string ;
391372}
392373
393- export declare function generateApi (
394- params : Omit < GenerateApiParams , "url" | "spec" > ,
395- ) : Promise < GenerateApiOutput > ;
396- export declare function generateApi (
397- params : Omit < GenerateApiParams , "input" | "spec" > ,
398- ) : Promise < GenerateApiOutput > ;
399- export declare function generateApi (
400- params : Omit < GenerateApiParams , "input" | "url" > ,
401- ) : Promise < GenerateApiOutput > ;
374+ export declare function generateApi ( params : Omit < GenerateApiParams , "url" | "spec" > ) : Promise < GenerateApiOutput > ;
375+ export declare function generateApi ( params : Omit < GenerateApiParams , "input" | "spec" > ) : Promise < GenerateApiOutput > ;
376+ export declare function generateApi ( params : Omit < GenerateApiParams , "input" | "url" > ) : Promise < GenerateApiOutput > ;
0 commit comments