FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi-typescript-codegen/src/utils/writeClientIndex.ts at main · thulium/openapi-typescript-codegen · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
thulium
/
openapi-typescript-codegen
Public
forked from
ferdikoomen/openapi-typescript-codegen
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
21
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
openapi-typescript-codegen
/
src
/
utils
/
writeClientIndex.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (53 loc) · 1.98 KB
Breadcrumbs
openapi-typescript-codegen
/
src
/
utils
/
writeClientIndex.ts
Copy path
File metadata and controls
56 lines (53 loc) · 1.98 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import
{
resolve
}
from
'path'
;
import
type
{
Client
}
from
'../client/interfaces/Client'
;
import
{
writeFile
}
from
'./fileSystem'
;
import
{
isDefined
}
from
'./isDefined'
;
import
{
Templates
}
from
'./registerHandlebarTemplates'
;
import
{
sortModelsByName
}
from
'./sortModelsByName'
;
import
{
sortServicesByName
}
from
'./sortServicesByName'
;
/**
* Generate the OpenAPI client index file using the Handlebar template and write it to disk.
* The index file just contains all the exports you need to use the client as a standalone
* library. But yuo can also import individual models and services directly.
*
@param
client Client object, containing, models, schemas and services
*
@param
templates The loaded handlebar templates
*
@param
outputPath Directory to write the generated files to
*
@param
useUnionTypes Use union types instead of enums
*
@param
exportCore Generate core
*
@param
exportServices Generate services
*
@param
exportModels Generate models
*
@param
exportSchemas Generate schemas
*
@param
postfixServices Service name postfix
*
@param
postfixModels Model name postfix
*
@param
clientName Custom client class name
*/
export
const
writeClientIndex
=
async
(
client
:
Client
,
templates
:
Templates
,
outputPath
:
string
,
useUnionTypes
:
boolean
,
exportCore
:
boolean
,
exportServices
:
boolean
,
exportModels
:
boolean
,
exportSchemas
:
boolean
,
postfixServices
:
string
,
postfixModels
:
string
,
clientName
?:
string
)
:
Promise
<
void
>
=>
{
const
templateResult
=
templates
.
index
(
{
exportCore
,
exportServices
,
exportModels
,
exportSchemas
,
useUnionTypes
,
postfixServices
,
postfixModels
,
clientName
,
server
:
client
.
server
,
version
:
client
.
version
,
models
:
sortModelsByName
(
client
.
models
)
,
services
:
sortServicesByName
(
client
.
services
)
,
exportClient
:
isDefined
(
clientName
)
,
}
)
;
await
writeFile
(
resolve
(
outputPath
,
'index.ts'
)
,
templateResult
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL