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

Support for serverless deployments #140

Closed
dsmileyephe opened this issue Aug 1, 2019 · 5 comments
Closed

Support for serverless deployments #140

dsmileyephe opened this issue Aug 1, 2019 · 5 comments

Comments

@dsmileyephe
Copy link

I recently was pulling my hair out trying to get swagger-ui-express to work with a serverless API that is deployed to API gateway. The biggest problem is that that the routes for the dependent files served up via swagger-ui-dist have to be exposed explicitly as routes in the serverless.yml file. For example:

Docs:
        handler: src/index.handler
        events:
            - http:
                path: /api-docs/{proxy+}
                method: get
                cors:
                    origin: '*'
                    headers:
                      - Content-Type
                      - Authorization
                      - x-amzn-trace-id
        warmup: true

In this example we are taking advantage of greedy paths defined here.
For people not familiar with serving static files in express they might overlook this. Can you update your documentation for users of serverless and include an example like this?

@scottie1984
Copy link
Owner

Happy to take a PR on this from someone who has gone through the process.

@connorads
Copy link

I also tried for a long time to get swagger-ui-express working with serverless-framework and aws-serverless-express.

Couldn't work out how to get it to work so I ditched swagger-ui-express and ended up just serving the Swagger HTML and OpenApi Spec JSON directly from different endpoints.

If anyone has an example of Swagger UI working with swagger-ui-express, serverless-framework and aws-serverless-express I'm very interested!

@chandima
Copy link

chandima commented Dec 31, 2020

Fix is here: #62 (comment)

app.use('/api-docs/', swaggerUi.serveWithOptions({ redirect: false }))

@mscottx88
Copy link

Turning off redirect causes basic authentication to keep popping up.

@tvpsh2021
Copy link

@connorads Thanks for the idea, this is brilliant! hahaha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants