forked from fastify/fastify-swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
http2-types.test.ts
70 lines (65 loc) · 1.54 KB
/
http2-types.test.ts
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import fastify = require('fastify');
import fastifySwagger = require('.');
const app = fastify({
http2: true
});
app.register(fastifySwagger);
app.register(fastifySwagger, {});
app.register(fastifySwagger, { transform: (schema : any) => schema });
app.register(fastifySwagger, {
mode: 'static',
specification: {
document: 'path'
},
routePrefix: '/documentation',
exposeRoute: true,
});
app.put('/some-route/:id', {
schema: {
description: 'put me some data',
tags: ['user', 'code'],
summary: 'qwerty',
security: [{ apiKey: []}]
}
}, (req, reply) => {});
app.get('/public/route', {
schema: {
description: 'returns 200 OK',
summary: 'qwerty',
security: []
}
}, (req, reply) => {});
app
.register(fastifySwagger, {
routePrefix: '/documentation',
exposeRoute: true,
swagger: {
info: {
title: 'Test swagger',
description: 'testing the fastify swagger api',
version: '0.1.0'
},
externalDocs: {
url: 'https://swagger.io',
description: 'Find more info here'
},
host: 'localhost',
schemes: ['http'],
consumes: ['application/json'],
produces: ['application/json'],
tags: [
{ name: 'user', description: 'User related end-points' },
{ name: 'code', description: 'Code related end-points' }
],
securityDefinitions: {
apiKey: {
type: 'apiKey',
name: 'apiKey',
in: 'header'
}
}
}
})
.ready(err => {
app.swagger();
});