scottie1984 / swagger-ui-express

Adds middleware to your express app to serve the Swagger UI bound to your Swagger document. This acts as living documentation for your API hosted from within your app.
MIT License
1.42k stars 225 forks source link

HTML page rendered as code #260

Closed GustavoCinque closed 3 years ago

GustavoCinque commented 3 years ago

Hi.

I'm using dist, and my swagger is created as an pre code of an html page.

image

This is my configuration:

import path from 'path';
import swaggerJsdoc from 'swagger-jsdoc';
import swaggerUi from 'swagger-ui-express';
import { Express } from 'express'
import swaggerDefinition from './docs/info'

export default (app: Express): void => {
    const swaggerOptions = {
        swaggerDefinition,
        apis: [path.join(__dirname, '..', '..', '..', 'main', 'server.js'), path.join(__dirname, '..', '..', '..', 'main', 'routes', '*-route.js')]
    }
    const swaggerDocs = swaggerJsdoc(swaggerOptions);
    app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocs))
}

My definitions isn't detailed yet:

export default {
    title: 'Email Service',
    description: 'Email service',
    termsOfService: '',
    contact: {
        name: '',
        url: '',
        email: ''
    },
    license: {
        name: '',
        url: ''
    },
    servers: [process.env.API || 'http://localhost:8080/api'],
    version: '0.0.1'
}