Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(swagger): use swagger-ui-express to display simple and administration api doc #85

Merged
merged 6 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker/distributions/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ COPY /docker/config /home/docker/config/
### Dossier de l'application
WORKDIR /home/docker/app
COPY src ./src/
### Dossier documentation apis
COPY documentation/apis ./documentation/apis
### Récupération des sources de l'application
COPY *.json ./

Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"https-proxy-agent": "5.0.1",
"log4js": "6.7.1",
"nconf": "0.12.0",
"proj4": "2.8.0"
"proj4": "2.8.0",
"swagger-ui-express": "4.6.3",
"yaml": "2.3.1"
},
"optionalDependencies": {
"osrm": "5.26.0",
Expand All @@ -53,6 +55,8 @@
"assert",
"helmet",
"got",
"http-proxy-agent"
"http-proxy-agent",
"swagger-ui-express",
"yaml"
]
}
12 changes: 12 additions & 0 deletions src/js/apis/simple/1.0.0/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
'use strict';


const fs = require('fs');
const path = require('path');
const express = require('express');
const log4js = require('log4js');
const controller = require('./controller/controller');
const errorManager = require('../../../utils/errorManager');
const swaggerUi = require('swagger-ui-express');
const YAML = require('yaml')

var LOGGER = log4js.getLogger("SIMPLE");
var router = express.Router();
Expand Down Expand Up @@ -44,6 +48,14 @@ router.all("/", function(req, res) {
res.send("Road2 via l'API simple 1.0.0");
});


// swagger-ui
var apiYamlPath = path.join(__dirname, '..', '..', '..','..','..', 'documentation','apis','simple', '1.0.0', 'api.yaml')
LOGGER.info("Utilisation fichier .yaml '"+ apiYamlPath + "' pour initialisation swagger-ui de l'API simple en version 1.0.0");
var file = fs.readFileSync(apiYamlPath, 'utf8')
var swaggerDocument = YAML.parse(file)
router.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

// GetCapabilities
router.all("/getcapabilities", function(req, res) {

Expand Down
Loading