unknown extension grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema
vvayne676 opened this issue · comments
buf.yaml
build:
excludes:
- ./vendor
deps:
- buf.build/googleapis/googleapis
- buf.build/bufbuild/protovalidate
- buf.build/grpc-ecosystem/grpc-gateway
breaking:
use:
- FILE
lint:
use:
- DEFAULT
buf.gen.yaml
managed:
enabled: true
plugins:
# generate go struct code
- name: go
out: "."
# opt: paths=source_relative
# generate grpc service code
- name: go-grpc
out: "."
# opt: paths=source_relative
- name: validate
out: "."
opt:
# - paths=source_relative
- lang=go
- plugin: buf.build/grpc-ecosystem/openapiv2
out: "swagger-ui"
robot.proto
package robot;
option go_package = "api/server/robot;robot";
import "buf/validate/validate.proto";
import "protoc-gen-openapiv2/options/openapiv2.proto";
message SimpleMessage {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
json_schema: {
title: "SimpleMessage"
description: "A simple message."
required: [ "id" ]
}
};
// Id represents the message identifier.
string id = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "The unique identifier of the simple message."
}];
}
Hello
im trying to use buf to generate swagger json file. yet I have encountered this error
"""
unknown extension grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema
unknown extension grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field
"""
Im confused what did I do wrong
The message option grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema
is defined in the file protoc-gen-openapiv2/options/annotations.proto
(see line 29 here), so you need to import this one, not protoc-gen-openapiv2/options/openapiv2.proto
.
Hi timostamm, appreciate the quick response,I just started to use buf and proto recently, it did work.