Registry / serialization / protoc-gen-swagger

protoc-gen-swagger

JSON →
library0.1.0pypypi✓ verified 86d ago

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.

pip install protoc-gen-swagger
INSTALL
IMPORT
SIG · PROTOC-GEN-SWAGGER
P
protoc-gen-swagger
serializationpythonv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

protoc_gen_swagger
import protoc_gen_swagger
Direct import of the module works if you need to invoke the plugin programmatically.

Invoke protoc with the swagger plugin (requires protoc-gen-swagger installed and in PATH).

# Generate swagger.json from a .proto file using the protoc plugin # Make sure you have protoc installed, then run: # protoc --swagger_out=. --proto_path=protos protos/your_service.proto import subprocess import os proto_file = "your_service.proto" proto_path = "protos" output_dir = "." cmd = [ "protoc", f"--swagger_out={output_dir}", f"--proto_path={proto_path}", proto_file ] subprocess.run(cmd, check=True) print("Generated swagger.json")
protoc-gen-swagger --version
Debug
Known issues
gotchaThe plugin is very early (0.1.0). It may not support all protobuf features and can generate incomplete or incorrect swagger specs. Test thoroughly.
fix
Validate output swagger.json against your schema expectations.
affects: <=0.1.0
gotchaprotoc-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'.
fix
Install protoc from https://github.com/protocolbuffers/protobuf/releases.
affects: all
Errors
Common errors & fixes
protoc-gen-swagger: command not found
The plugin executable is not in PATH after pip install.
fix
Ensure the Python Scripts directory (e.g., ~/.local/bin on Linux) is in your PATH. Or run: python -m protoc_gen_swagger
protoc: error: Unknown flag: --swagger_out
protoc does not see the plugin, likely because protoc-gen-swagger is not installed or not in PATH.
fix
Verify protoc-gen-swagger is installed and in PATH (type 'which protoc-gen-swagger'). Reinstall if needed.
Upgrade
Version history
0.1.0latest on PyPI · released Jan 29, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
protoc-gen-swagger — pip install protoc-gen-swagger · libregistry