1
- import _ from "lodash" ;
2
- import ts from "typescript" ;
1
+ import * as lodash from "lodash" ;
2
+ import * as typescript from "typescript" ;
3
3
import { CodeFormatter } from "./code-formatter.js" ;
4
4
import { CodeGenConfig } from "./configuration.js" ;
5
5
import { SchemaComponentsMap } from "./schema-components-map.js" ;
@@ -103,8 +103,8 @@ class CodeGenProcess {
103
103
104
104
this . schemaComponentsMap . clear ( ) ;
105
105
106
- _ . each ( swagger . usageSchema . components , ( component , componentName ) =>
107
- _ . each ( component , ( rawTypeData , typeName ) => {
106
+ lodash . each ( swagger . usageSchema . components , ( component , componentName ) =>
107
+ lodash . each ( component , ( rawTypeData , typeName ) => {
108
108
this . schemaComponentsMap . createComponent (
109
109
this . schemaComponentsMap . createRef ( [
110
110
"components" ,
@@ -120,7 +120,7 @@ class CodeGenProcess {
120
120
* @type {SchemaComponent[] }
121
121
*/
122
122
const componentsToParse = this . schemaComponentsMap . filter (
123
- _ . compact ( [ "schemas" , this . config . extractResponses && "responses" ] ) ,
123
+ lodash . compact ( [ "schemas" , this . config . extractResponses && "responses" ] ) ,
124
124
) ;
125
125
126
126
const parsedSchemas = componentsToParse . map ( ( schemaComponent ) => {
@@ -228,7 +228,7 @@ class CodeGenProcess {
228
228
return ` * ${ line } ${ eol ? "\n" : "" } ` ;
229
229
} ,
230
230
NameResolver : NameResolver ,
231
- _,
231
+ _ : lodash ,
232
232
require : this . templatesWorker . requireFnFromTemplate ,
233
233
} ,
234
234
config : this . config ,
@@ -239,7 +239,7 @@ class CodeGenProcess {
239
239
const components = this . schemaComponentsMap . getComponents ( ) ;
240
240
let modelTypes = [ ] ;
241
241
242
- const modelTypeComponents = _ . compact ( [
242
+ const modelTypeComponents = lodash . compact ( [
243
243
"schemas" ,
244
244
this . config . extractResponses && "responses" ,
245
245
] ) ;
@@ -322,7 +322,7 @@ class CodeGenProcess {
322
322
? await this . createMultipleFileInfos ( templatesToRender , configuration )
323
323
: await this . createSingleFileInfo ( templatesToRender , configuration ) ;
324
324
325
- if ( ! _ . isEmpty ( configuration . extraTemplates ) ) {
325
+ if ( ! lodash . isEmpty ( configuration . extraTemplates ) ) {
326
326
for ( const extraTemplate of configuration . extraTemplates ) {
327
327
const content = this . templatesWorker . renderTemplate (
328
328
this . fileSystem . getFileContent ( extraTemplate . path ) ,
@@ -467,27 +467,29 @@ class CodeGenProcess {
467
467
return await this . createOutputFileInfo (
468
468
configuration ,
469
469
configuration . fileName ,
470
- _ . compact ( [
471
- this . templatesWorker . renderTemplate (
472
- templatesToRender . dataContracts ,
473
- configuration ,
474
- ) ,
475
- generateRouteTypes &&
476
- this . templatesWorker . renderTemplate (
477
- templatesToRender . routeTypes ,
478
- configuration ,
479
- ) ,
480
- generateClient &&
481
- this . templatesWorker . renderTemplate (
482
- templatesToRender . httpClient ,
483
- configuration ,
484
- ) ,
485
- generateClient &&
470
+ lodash
471
+ . compact ( [
486
472
this . templatesWorker . renderTemplate (
487
- templatesToRender . api ,
473
+ templatesToRender . dataContracts ,
488
474
configuration ,
489
475
) ,
490
- ] ) . join ( "\n" ) ,
476
+ generateRouteTypes &&
477
+ this . templatesWorker . renderTemplate (
478
+ templatesToRender . routeTypes ,
479
+ configuration ,
480
+ ) ,
481
+ generateClient &&
482
+ this . templatesWorker . renderTemplate (
483
+ templatesToRender . httpClient ,
484
+ configuration ,
485
+ ) ,
486
+ generateClient &&
487
+ this . templatesWorker . renderTemplate (
488
+ templatesToRender . api ,
489
+ configuration ,
490
+ ) ,
491
+ ] )
492
+ . join ( "\n" ) ,
491
493
) ;
492
494
} ;
493
495
@@ -500,7 +502,7 @@ class CodeGenProcess {
500
502
*/
501
503
createOutputFileInfo = async ( configuration , fileNameFull , content ) => {
502
504
const fileName = this . fileSystem . cropExtension ( fileNameFull ) ;
503
- const fileExtension = ts . Extension . Ts ;
505
+ const fileExtension = typescript . Extension . Ts ;
504
506
505
507
if ( configuration . translateToJavaScript ) {
506
508
this . logger . debug ( "using js translator for" , fileName ) ;
@@ -542,14 +544,14 @@ class CodeGenProcess {
542
544
servers : servers || [ ] ,
543
545
basePath,
544
546
host,
545
- externalDocs : _ . merge (
547
+ externalDocs : lodash . merge (
546
548
{
547
549
url : "" ,
548
550
description : "" ,
549
551
} ,
550
552
externalDocs ,
551
553
) ,
552
- tags : _ . compact ( tags ) ,
554
+ tags : lodash . compact ( tags ) ,
553
555
baseUrl : serverUrl ,
554
556
title,
555
557
version,
0 commit comments