Skip to content

feat: Automate OpenAPI generation from JSON Schema #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tadasant
Copy link
Member

@tadasant tadasant commented Jul 12, 2025

⚠️ DRAFT - NOT READY FOR REVIEW ⚠️

Just FYI @toby @joelverhagen @modelcontextprotocol/registry I am WIP on this. Don't quite love where it's at right now, will be working more on it.

This is part of #159 and the mission to make our server.json/openapi spec DRY.


Summary

This PR introduces automated generation of OpenAPI schemas from our canonical server.json JSON Schema, ensuring that shared data models stay in sync between the two specifications.

What's changed

  • Created tools/server-json-to-openapi-sync/ - a Go tool that converts JSON Schema definitions to OpenAPI component schemas
  • Reorganized OpenAPI files into docs/server-registry-api/generation/:
    • openapi-manual.yaml - Hand-written API endpoints and registry-specific schemas
    • openapi-components-generated.yaml - Auto-generated from server.json
    • Final openapi.yaml is generated by bundling these together
  • Added go generate support for running the generation pipeline
  • Registry-specific fields (like id on Server) remain manually defined

How it works

  1. Run go generate -tags generate ./... or make -C docs/server-registry-api/generation all
  2. The tool converts docs/server-json/schema.json → OpenAPI components
  3. Redocly CLI bundles manual + generated files → final openapi.yaml

Benefits

  • Single source of truth for shared data models
  • API-specific extensions remain flexible
  • No manual synchronization needed
  • Clean separation of concerns

TODO before review

  • Verify all schemas are correctly generated
  • Add CI check to ensure generation was run
  • Update documentation

- Create server-json-to-openapi-sync tool to convert JSON Schema to OpenAPI components
- Set up generation workflow with separate manual and generated files
- Organize generation files in docs/server-registry-api/generation/
- Add go generate support for running the full pipeline
- Preserve existing OpenAPI structure while enabling DRY schema management
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant