1- import { FastifyInstance } from "fastify"
2- const swagger = require ( '@fastify/swagger' )
3- const swaggerUI = require ( '@fastify/swagger-ui' )
4-
5- export const initSwaggerViewer = async ( server : FastifyInstance ) : Promise < void > => {
6- await server . register ( swagger , {
7- openapi : {
8- openapi : '3.0.0' ,
9- info : {
10- title : 'NodeNotes (api - v1)' ,
11- description : 'NodeNotes backend REST API endpoints specification' ,
12- version : '1.0.0'
13- } ,
14- servers : [
15- {
16- url : 'http://localhost:8080' ,
17- description : 'Development server'
18- }
19- ] ,
20- tags : [
21- { name : 'users' , description : 'User related end-points (may require JWT in "Bearer" auth header)' } ,
22- { name : 'auth' , description : 'Authorization end-points (may require JWT in "Bearer" auth header)' } ,
23- { name : 'notes' , description : 'Note related end-points (requires JWT in "Bearer" auth header)' }
24- ] ,
25- externalDocs : {
26- url : 'https://github.com/LCcodder/NodeNotes' ,
27- description : 'GitHub repo'
28- }
29- }
30- } )
31-
32- await server . register ( swaggerUI , {
33- routePrefix : '/documentation' ,
34- uiConfig : {
35- deepLinking : false
36- } ,
37- staticCSP : true ,
38- transformStaticCSP : ( header : any ) => header ,
39- transformSpecification : ( swaggerObject : any , _request : any , _reply : any ) => { return swaggerObject } ,
40- transformSpecificationClone : true
41- } )
1+ import { FastifyInstance } from "fastify"
2+ const swagger = require ( '@fastify/swagger' )
3+ const swaggerUI = require ( '@fastify/swagger-ui' )
4+
5+ export const initSwaggerViewer = async ( server : FastifyInstance ) : Promise < void > => {
6+ await server . register ( swagger , {
7+ openapi : {
8+ openapi : '3.0.0' ,
9+ info : {
10+ title : 'NodeNotes (api - v1)' ,
11+ description : 'NodeNotes backend REST API endpoints specification' ,
12+ version : '1.0.0'
13+ } ,
14+ servers : [
15+ {
16+ url : 'http://localhost:8080' ,
17+ description : 'Development server'
18+ }
19+ ] ,
20+ tags : [
21+ { name : 'users' , description : 'User related end-points (may require JWT in "Bearer" auth header)' } ,
22+ { name : 'auth' , description : 'Authorization end-points (may require JWT in "Bearer" auth header)' } ,
23+ { name : 'notes' , description : 'Note related end-points (requires JWT in "Bearer" auth header)' }
24+ ] ,
25+ externalDocs : {
26+ url : 'https://github.com/LCcodder/NodeNotes' ,
27+ description : 'GitHub repo'
28+ }
29+ }
30+ } )
31+
32+ await server . register ( swaggerUI , {
33+ routePrefix : '/documentation' ,
34+ uiConfig : {
35+ deepLinking : false
36+ } ,
37+ staticCSP : true ,
38+ transformStaticCSP : ( header : any ) => header ,
39+ transformSpecification : ( swaggerObject : any , _request : any , _reply : any ) => { return swaggerObject } ,
40+ transformSpecificationClone : true
41+ } )
4242}
0 commit comments