Skip to content
Snippets Groups Projects
Commit dad2609e authored by esikkala's avatar esikkala
Browse files

Define /api-docs route first

parent 9b25736f
No related branches found
No related tags found
No related merge requests found
...@@ -40,9 +40,17 @@ app.use(function (req, res, next) { ...@@ -40,9 +40,17 @@ app.use(function (req, res, next) {
next() next()
}) })
let publicPath = null // Generate API docs from YAML file with Swagger UI
let swaggerDocument
try {
swaggerDocument = yaml.safeLoad(fs.readFileSync(path.join(__dirname, './openapi.yaml'), 'utf8'))
} catch (e) {
console.log(e)
}
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
// Express server is used to serve the React app only in production // Express server is used to serve the React app only in production
let publicPath = null
if (!isDevelopment) { if (!isDevelopment) {
// The root directory from which to serve static assets // The root directory from which to serve static assets
publicPath = path.join(__dirname, './../public/') publicPath = path.join(__dirname, './../public/')
...@@ -53,16 +61,6 @@ if (!isDevelopment) { ...@@ -53,16 +61,6 @@ if (!isDevelopment) {
// React app makes requests to these api urls // React app makes requests to these api urls
const apiPath = '/api/v1' const apiPath = '/api/v1'
// Generate API docs from YAML file with Swagger UI
let swaggerDocument
try {
swaggerDocument = yaml.safeLoad(fs.readFileSync(path.join(__dirname, './openapi.yaml'), 'utf8'))
} catch (e) {
console.log(e)
}
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument))
new OpenApiValidator({ new OpenApiValidator({
apiSpec: swaggerDocument, apiSpec: swaggerDocument,
validateResponses: true validateResponses: true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment