-
Notifications
You must be signed in to change notification settings - Fork 2
Troubleshooting
Common errors and what they mean.
The generator refuses to overwrite by default. Either delete the file, or pass -force. This is a guardrail against accidentally clobbering hand-edited code.
Batch mode auto-derives package names from filename stems. Drop the -package flag.
-emit-v3 writes to a single path; it's incompatible with multi-spec input. Run it once per spec.
Two specs in your batch reduce to the same slug (e.g. v1/api.yaml and v2/api.yaml both → api). Rename one of the files so their stems differ.
The filename stem for batch mode starts with a digit, which isn't a valid Go identifier. Rename the spec file (e.g. 2024-billing.yaml → billing-2024.yaml).
The conversion via kin-openapi/openapi2conv failed. Common causes: malformed v2 spec, unresolved external $ref. Validate the v2 spec first with a tool like swagger-cli.
The spec — after any v2→v3 conversion — failed validation. The error message points at the offending node.
Your -client-import value doesn't match where you actually put the oapi-codegen output. Either move the output, or fix the import path.
The oapi-codegen client doesn't expose the operation. Make sure you generated with -generate types,client (not just types), and that the operation isn't excluded by your oapi-codegen config.
You passed a concrete client, but the operation needs the interface. Use oapi-codegen's *ClientWithResponses (the generated type), or set -client-type to your custom interface name.
Most often: the binary started, but RegisterXxxClient was never called. Check your main.go.
Less often: -exclude-by-default was set and no operations were tagged x-mcp: true.
-
Proxy mode: check the env var matches what the spec's
securitySchemesresolved to. The generatedREADME.mdlists the exact name per scheme. -
Companion mode: confirm your
WithRequestEditorFnorWithHTTPClientactually adds the auth header.
The LLM may need a clearer schema. If you're using a model that struggles with $ref or composition keywords, try -openai-compat to flatten the schema. See Schema Modes.
Use -emit-v3 to prune non-JSON responses before passing the spec to oapi-codegen:
openapi-go-mcp -spec api.yaml -emit-v3 api-v3.yaml
oapi-codegen -generate types,client -package api -o gen/api/api.gen.go api-v3.yamlThe generator picks one deterministically: application/json → form → multipart → octet-stream → text/* → other. Override with -prefer-content-type.
Repo · Releases · Issues · Discussions · Apache 2.0
Get started
Modes
Features
Deploy
Reference
Project