@@ -168,6 +168,37 @@ interface GenerateApiParamsBase {
168
168
169
169
/** configuration for fetching swagger schema requests */
170
170
requestOptions ?: null | Partial < import ( "node-fetch" ) . RequestInit > ;
171
+
172
+ /** ts compiler configuration object (for --to-js option) */
173
+ compilerTsConfig ?: Record < string , any > ;
174
+
175
+ /**
176
+ * custom ts->* translator
177
+ * do not use constructor args, it can break functionality of this property, just send class reference
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * const { Translator } = require("swagger-typescript-api/src/translators/translator");
182
+ *
183
+ * class MyTranslator extends Translator {
184
+ *
185
+ * translate({ fileName, fileExtension, fileContent }) {
186
+ * this.codeFormatter.format()
187
+ * this.config.
188
+ * this.logger.
189
+ *
190
+ * return [
191
+ * {
192
+ * fileName,
193
+ * fileExtension,
194
+ * fileContent,
195
+ * }
196
+ * ]
197
+ * }
198
+ * }
199
+ * ```
200
+ */
201
+ customTranslator ?: new ( ) => typeof import ( "./src/translators/translator" ) . Translator ;
171
202
}
172
203
173
204
type CodeGenConstruct = {
@@ -505,6 +536,9 @@ export interface GenerateApiConfiguration {
505
536
hooks : Hooks ;
506
537
enumNamesAsValues : boolean ;
507
538
version : string ;
539
+ compilerTsConfig : Record < string , any > ;
540
+ /** do not use constructor args, it can break functionality of this property, just send class reference */
541
+ customTranslator ?: new ( ...args : never [ ] ) => typeof import ( "./src/translators/translator" ) . Translator ;
508
542
internalTemplateOptions : {
509
543
addUtilRequiredKeysType : boolean ;
510
544
} ;
@@ -569,9 +603,18 @@ export interface GenerateApiConfiguration {
569
603
} ;
570
604
}
571
605
606
+ type FileInfo = {
607
+ /** @example myFilename */
608
+ fileName : string ;
609
+ /** @example .d.ts */
610
+ fileExtension : string ;
611
+ /** content of the file */
612
+ fileContent : string ;
613
+ } ;
614
+
572
615
export interface GenerateApiOutput {
573
616
configuration : GenerateApiConfiguration ;
574
- files : { name : string ; content : string ; declaration : { name : string ; content : string } | null } [ ] ;
617
+ files : FileInfo [ ] ;
575
618
createFile : ( params : { path : string ; fileName : string ; content : string ; withPrefix ?: boolean } ) => void ;
576
619
renderTemplate : (
577
620
templateContent : string ,
0 commit comments