{"id":27259,"library":"protoc-gen-swagger","title":"protoc-gen-swagger","description":"A Python protoc plugin that generates Swagger/OpenAPI specifications from annotated protobuf files. Currently at version 0.1.0, released as a minimal early release. No regular release cadence established yet.","status":"active","version":"0.1.0","language":"python","source_language":"en","source_url":"https://github.com/universe-proton/protoc-gen-swagger","tags":["protobuf","swagger","openapi","protoc-plugin","grpc"],"install":[{"cmd":"pip install protoc-gen-swagger","lang":"bash","label":"pip"}],"dependencies":[],"imports":[{"note":"Direct import of the module works if you need to invoke the plugin programmatically.","symbol":"protoc_gen_swagger","correct":"import protoc_gen_swagger"}],"quickstart":{"code":"# Generate swagger.json from a .proto file using the protoc plugin\n# Make sure you have protoc installed, then run:\n# protoc --swagger_out=. --proto_path=protos protos/your_service.proto\n\nimport subprocess\nimport os\n\nproto_file = \"your_service.proto\"\nproto_path = \"protos\"\noutput_dir = \".\"\n\ncmd = [\n    \"protoc\",\n    f\"--swagger_out={output_dir}\",\n    f\"--proto_path={proto_path}\",\n    proto_file\n]\nsubprocess.run(cmd, check=True)\nprint(\"Generated swagger.json\")\n","lang":"python","description":"Invoke protoc with the swagger plugin (requires protoc-gen-swagger installed and in PATH)."},"warnings":[{"fix":"Validate output swagger.json against your schema expectations.","message":"The plugin is very early (0.1.0). It may not support all protobuf features and can generate incomplete or incorrect swagger specs. Test thoroughly.","severity":"gotcha","affected_versions":"<=0.1.0"},{"fix":"Install protoc from https://github.com/protocolbuffers/protobuf/releases.","message":"protoc-gen-swagger depends on protoc being installed and the plugin being in your PATH. Missing protoc leads to cryptic errors like 'protoc: command not found'.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure the Python Scripts directory (e.g., ~/.local/bin on Linux) is in your PATH. Or run: python -m protoc_gen_swagger","cause":"The plugin executable is not in PATH after pip install.","error":"protoc-gen-swagger: command not found"},{"fix":"Verify protoc-gen-swagger is installed and in PATH (type 'which protoc-gen-swagger'). Reinstall if needed.","cause":"protoc does not see the plugin, likely because protoc-gen-swagger is not installed or not in PATH.","error":"protoc: error: Unknown flag: --swagger_out"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}