Skip to content

Swagger for Apostrophe. #4543

Answered by boutell
kklicmhenya asked this question in Q&A
May 16, 2024 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

Hi @kklicmhenya,

As you say the Express app object is available, as apos.app. I see from the Swagger documentation that you'll need this in order to do apos.app.use.

However there is another issue. There is a catch-all route in Apostrophe which tries to serve a URL as a page if it isn't found otherwise, and finally a 404 is sent.

So to avoid that you need to register your route early. You can do that by using self.apos.app.use in the init() function of your own module, let's say it's modules/swagger/index.js. Make sure you add your module to app.js as well.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@kklicmhenya
Comment options

Comment options

You must be logged in to vote
4 replies
@kklicmhenya
Comment options

@kklicmhenya
Comment options

@boutell
Comment options

@kklicmhenya
Comment options

Answer selected by kklicmhenya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants