Swagger for Apostrophe. #4543
-
|
Hello everyone! I am currently working on my project based on ApostropheCMS and I need to have good documentation of all Routes, how can I competently connect swagger to ApostopheCMS? My main problems are not availability of getting the app object.
I use those docs: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
There is also a section in the documentation for the REST API endpoints. Not sure what else you would be looking for. Other than that I guess you will also have to consider routes created in your project through the module customization functions like |
Beta Was this translation helpful? Give feedback.
-
|
Hi @kklicmhenya, As you say the Express 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 |
Beta Was this translation helpful? Give feedback.
Hi @kklicmhenya,
As you say the Express
appobject is available, asapos.app. I see from the Swagger documentation that you'll need this in order to doapos.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.usein theinit()function of your own module, let's say it'smodules/swagger/index.js. Make sure you add your module toapp.jsas well.