Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenApi spec generation? #703

Closed
lordvidex opened this issue Mar 3, 2024 · 1 comment
Closed

OpenApi spec generation? #703

lordvidex opened this issue Mar 3, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@lordvidex
Copy link

lordvidex commented Mar 3, 2024

I currently migrated from the default stack ( grpc-go with grpc-gateway ) to connect-go because I get a lot of features out of the box with minimal grpc boilerplate generation.

Connect currently supports grpc requests (which can be reflected easily with clients) and http requests. The problem is that the http part is missing certain features especially if one is using clients that work only with http.

grpc-gateway uses/includes the following binaries:

  • protoc-gen-grpc-gateway
  • protoc-gen-openapiv2
  • protoc-gen-go
  • protoc-gen-go-grpc

Currently, there is nothing in the connectrpc ecosystem that provides the features of protoc-gen-openapiv2. This will be especially useful to display http endpoints explicitly since connect doesn't strictly enforce standard http naming conventions and styles.

@lordvidex lordvidex added the enhancement New feature or request label Mar 3, 2024
@lordvidex
Copy link
Author

I'll close this issue because I found a solution to this. There is no need for an additional lib to expose the connect-go API. protoc-gen-openapiv2 can be used but there is a need to specify generate_unbound_methods=true option. Additional libs like github.com/swaggo/http-swagger/v2 can be used to host the swagger generated file.

protoc command

$(PROTOC) -I . -I vendor-proto \
	--plugin=protoc-gen-go=$(BINDIR)/protoc-gen-go --go_out=paths=source_relative:./pkg \
	--plugin=protoc-gen-connect-go=$(BINDIR)/protoc-gen-connect-go --connect-go_out=paths=source_relative:./pkg \
	--plugin=protoc-gen-openapiv2=$(BINDIR)/protoc-gen-openapiv2 --openapiv2_out api/openapiv2/ --openapiv2_opt logtostderr=true --openapiv2_opt generate_unbound_methods=true \
	$(PROTO_PATH)/api.proto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant