forked from anneb/pgserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswagger.js
75 lines (68 loc) · 1.73 KB
/
swagger.js
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
71
72
73
74
75
const swaggerUi = require('swagger-ui-express');
const swaggerJSDoc = require('swagger-jsdoc');
/*
const YAML = require('yamljs');
const { join } = require('path');
module.exports = function(app) {
app.get('/api-docs/spec', (req, res) => res.json(apiSpec));
const apiSpec = YAML.load(join(__dirname, 'openapi.yaml'));
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(apiSpec,
{
customSiteTitle: 'Transport Planner API',
url: './spec',
baseUrl: './'
}),
);
};
*/
const swaggerDefinition = {
info: {
// API informations (required)
openapi: '3.0.3',
title: 'PGServer', // Title (required)
version: '0.0.1', // Version (required)
description: 'PostGIS http api', // Description (optional)
},
tags: [
{
name: 'meta',
description: 'meta information for tables and views'
},
{
name: 'geodata',
description: 'features in common formats for direct mapping'
}
],
servers: [
{
url: '../',
description: 'This Realm'
},
{
url: 'https://tiles.edugis.nl/pgserver',
description: 'Production server'
}
],
}
const swaggerJSDocOptions = {
swaggerDefinition,
apis: [
'./mvt.js',
'./list_layers.js',
'./layer_columns.js',
'./slds.js',
'./bbox.js',
'./geojson.js',
'./geobuf.js',
'./query.js',
'./column_stats.js'
]
}
const swaggerSpec = swaggerJSDoc(swaggerJSDocOptions);
module.exports = function(app) {
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec,
{
customSiteTitle: 'PGServer API Documentation'
}
));
}