File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { withExpress } from "./middleware/express";
12
12
import { withRequestLogs } from "./middleware/logs" ;
13
13
import { withOpenApi } from "./middleware/open-api" ;
14
14
import { withRoutes } from "./routes" ;
15
+ import { writeOpenApiToFile } from "./utils/openapi" ;
15
16
16
17
const __dirname = new URL ( "." , import . meta. url ) . pathname ;
17
18
@@ -65,10 +66,7 @@ const main = async () => {
65
66
} ,
66
67
) ;
67
68
68
- fs . writeFileSync (
69
- "./dist/openapi.json" ,
70
- JSON . stringify ( server . swagger ( ) , undefined , 2 ) ,
71
- ) ;
69
+ writeOpenApiToFile ( server ) ;
72
70
} ;
73
71
74
72
main ( ) ;
Original file line number Diff line number Diff line change
1
+ import { FastifyInstance } from "fastify" ;
2
+ import fs from "fs" ;
3
+
4
+ export const writeOpenApiToFile = ( server : FastifyInstance ) => {
5
+ try {
6
+ fs . writeFileSync (
7
+ "./dist/openapi.json" ,
8
+ JSON . stringify ( server . swagger ( ) , undefined , 2 ) ,
9
+ ) ;
10
+ } catch {
11
+ // no-op
12
+ }
13
+ } ;
You can’t perform that action at this time.
0 commit comments