-
Thanks for this nice framework, leveraging types, more declarative APIs (which is one thing I liked about hapi over express). I've got my API endpoints built, working great. I've got the OpenAPI spec constructed from those same routes, also working great. I've tried various ways to build and add an endpoint to serve the spec's yaml/json via swagger-ui-express, but the few attempts I've tried don't quite work correctly. I'm avoiding the usual Perhaps I'm missing something fundamental and/or obvious. Is swagger-ui-express the best package to use with express-zod-api to render the resulting spec? If not, what is? If so, are there any examples, templates, hints for using them together? Thanks, -Lance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @lpw , I never tried using In this regard, I believe, you should switch to custom app approach and You should create your own express app, apply Please try this approach and let me know if it works. |
Beta Was this translation helpful? Give feedback.
Hello @lpw ,
I never tried using
swagger-ui-express
, but reading its documentation I figured out that it consists of two parts: some express middleware and the handler that serves an HTML page, so that route is not a part of the API.In this regard, I believe, you should switch to custom app approach and
attachRouting()
method instead ofcreateServer()
.You should create your own express app, apply
app.use()
the wayswagger-ui-express
recommends, thenattachRouting()
and start listening the requests. Check out the example in the Readme.Please try this approach and let me know if it works.