-
Notifications
You must be signed in to change notification settings - Fork 2
Swagger 2.0 Workflow
openapi-go-mcp accepts Swagger 2.0 input natively — it's auto-converted via kin-openapi/openapi2conv before generation.
oapi-codegen does not accept Swagger 2.0. So when your spec is v2, you need a small extra step.
# 1. Convert Swagger 2.0 → OpenAPI 3 YAML.
openapi-go-mcp -spec petstore-v2.json -emit-v3 petstore-v3.yaml
# 2. Generate the typed HTTP client from the v3 output.
oapi-codegen -generate types,client -package pet -o gen/pet/pet.gen.go petstore-v3.yaml
# 3. Generate the MCP companion from the v3 output (or the v2 — both work here).
openapi-go-mcp \
-spec petstore-v3.yaml \
-out gen/petmcp \
-package petmcp \
-client-import github.com/me/gen/petUse the v3 YAML for both oapi-codegen and openapi-go-mcp so they see exactly the same shape.
- Loads the Swagger 2.0 spec.
- Converts it via
openapi2convon a deep clone — the original file is not mutated. - Prunes non-JSON content types from responses. This is a workaround for oapi-codegen v2.7.0 issues with responses exposed under multiple content types.
- Writes the result as YAML to the path you pass.
If you only need the MCP companion and not an oapi-codegen client, point openapi-go-mcp directly at the Swagger 2.0 file — internal conversion is automatic. -emit-v3 only matters when something else downstream (like oapi-codegen) consumes the spec.
Every loaded spec — v2 or v3 — passes openapi3.Validate after conversion. External $refs resolve against the spec file's directory.
Repo · Releases · Issues · Discussions · Apache 2.0
Get started
Modes
Features
Deploy
Reference
Project