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.4k stars 225 forks source link

swagger on Firebase Cloud Functions #325

Open lopezjuanma96 opened 1 year ago

lopezjuanma96 commented 1 year ago

I have some Cloud Functions deployed on Firebase and I wanted to add some documentation to it.

For some reason, after setting an endpoint for 'docs', if I accessed the URL normally it would redirect to a similar URL but with the last slice of the path removed, you can read the whole process I went through [https://stackoverflow.com/questions/74803435/setting-up-swagger-ui-in-firebase-functions-server/74813031#74813031](on this Stack Overflow post), but basically if swagger ui was served on endpoint 'something/docs' accessing the URL 'https://base.url/something/docs' would redirect to 'https://base.url/docs' which is an invalid endpoint (and also would raise some Firebase issues, you can read about them on the Stack Overflow post.

After many tests, I found out this redirection did not happen if you add an extra forward slash to the URL, so in the case above, the documentation loads no problem if you go to 'https://base.url/something/docs/'.

I could not find why this is or if there's another way to solve it. I believe it only happens on Firebase too.

scottie1984 commented 1 year ago

Maybe this will help? https://github.com/scottie1984/swagger-ui-express/issues/140#issuecomment-752850014

lopezjuanma96 commented 1 year ago

Mmm should test it, haven't touched that project since I wrote the issue, but I will test it as soon as i can and tell you! thanks for the response