File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -80,9 +80,9 @@ npx swagger-typescript-api -p ./swagger.json -o ./src -n myApi.ts
80
80
You can use this package from nodejs:
81
81
82
82
``` js
83
- const { generateApi , generateTemplates } = require ( " swagger-typescript-api " ) ;
84
- const path = require ( " path" ) ;
85
- const fs = require ( " fs " ) ;
83
+ import fs from " node:fs " ;
84
+ import path from " node: path" ;
85
+ import { generateApi , generateTemplates } from " swagger-typescript-api " ;
86
86
87
87
/* NOTE: all fields are optional expect one of `input`, `url`, `spec` */
88
88
generateApi ({
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ interface GenerateApiParamsBase {
192
192
*
193
193
* @example
194
194
* ```ts
195
- * const { Translator } = require( "swagger-typescript-api/src/translators/translator") ;
195
+ * import { Translator } from "swagger-typescript-api/src/translators/translator";
196
196
*
197
197
* class MyTranslator extends Translator {
198
198
*
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ const main = async () => {
301
301
try {
302
302
const customConfigPath = resolve ( process . cwd ( ) , options . customConfig ) ;
303
303
console . log ( `✨ found custom config at: ${ customConfigPath } ` ) ;
304
- customConfig = require ( customConfigPath ) ;
304
+ customConfig = await import ( customConfigPath ) ;
305
305
} catch ( e ) {
306
306
/* empty */
307
307
}
Original file line number Diff line number Diff line change @@ -76,21 +76,21 @@ class TemplatesWorker {
76
76
) ;
77
77
} ;
78
78
79
- requireFnFromTemplate = ( packageOrPath ) => {
79
+ requireFnFromTemplate = async ( packageOrPath ) => {
80
80
const isPath =
81
81
_ . startsWith ( packageOrPath , "./" ) || _ . startsWith ( packageOrPath , "../" ) ;
82
82
83
83
if ( isPath ) {
84
- return require (
84
+ return await import (
85
85
path . resolve (
86
86
this . config . templatePaths . custom ||
87
87
this . config . templatePaths . original ,
88
88
packageOrPath ,
89
- ) ,
89
+ )
90
90
) ;
91
91
}
92
92
93
- return require ( packageOrPath ) ;
93
+ return await import ( packageOrPath ) ;
94
94
} ;
95
95
96
96
getTemplate = ( { fileName, name, path } ) => {
You can’t perform that action at this time.
0 commit comments