Skip to main content

OpenAPI Swagger

Use protoc to generate openapi.yaml

The new project Makefile has been integrated by default with the commands associated with generating openapi.yaml, and here's how to use them


First, install the protoc plug-in globally.

go install


If you're using kratos-layout, execute this command directly to generate.

make api

Or you can use the protoc command directly at the root of the project, note that modifying the final proto file path of the command is the actual path

protoc --proto_path=. \
--proto_path=./third_party \
--openapi_out=fq_schema_naming=true,default_response=false:. \


Once the above command has been executed successfully, the corresponding openapi.yaml file will be generated in the directory where your proto file is located. You can import it into any platform that supports the Open API specification for browsing, such as: