DEV Community

aaronblondeau
aaronblondeau

Posted on

Can I stop forgetting to update my OpenAPI docs?

"Did you remember to update the OpenAPI docs for that API endpoint you modified earlier today?", says my brain at three in the morning. I decide to put a book on the floor so when I get up I'll see it and remember. Then, when I wake up: "What the heck is this book here for?"

I have been using OpenAPI (Swagger) docs for my Node.js APIs for quite some time. All that time I have been using JSDoc to define the swagger specs for my endpoints and the schemas that they accept and return. This has worked very well except for the fact that whenever I add a new field to a model in my API I tend to forget to add it to the docs.

Earlier this week I discovered the Joi npm package while reading through the ArangoDB docs. A light bulb immediately went off in my head. Can I use Joi to validate inputs AND generate OpenAPI specs? Fortunately the answer is yes, and the setup is very simple. See the code setup here : https://github.com/aaronblondeau/joi-swagger-express/blob/main/index.js

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more