I wanted to share a simple JS script I built that uses Anthropic's Claude AI to auto-generate OpenAPI specs from code.
Keeping OpenAPI specs in sync is tedious and error-prone. I was wasting too much time manually updating YAMLs.
To fix this, I created a script that leverages Claude to parse source code and produce OpenAPI specs, no annotations needed.
It's a gist you can copy/paste into your project: https://gist.github.com/hotkartoffel/2d2ca5a5a4ace98ca7fe87f...
Feed it your code and Claude handles inferring the OpenAPI objects.
I've tested it on JavaScript and Python APIs, but it's framework-agnostic. If Claude understands the code, it can generate the spec.
You need an Anthropic API key for Claude. But if you want to try the script, I'm happy to provide a small hosted demo - just ping me!
Adding this to CI/CD means fresh OpenAPI specs on each code change, no manual updates required.
Definitely a bit flimsy atm, but wanted to gather feedback.