Skip to content

OpenAPI/Swagger support #82

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

Open
ilyakharlamov opened this issue Jan 12, 2025 · 4 comments · May be fixed by #87
Open

OpenAPI/Swagger support #82

ilyakharlamov opened this issue Jan 12, 2025 · 4 comments · May be fixed by #87

Comments

@ilyakharlamov
Copy link

Hey @DanielLiu1123
I became interested in this library because of its unique JSON transcoding feature.
The main purpose of REST transcoding is to enable calling REST interfaces from UI, so that browser can invoke gRPC methods.

Since UIs are typically written in TypeScript, they require type definitions, which can be generated from OpenAPI/Swagger definitions. So I needed to plug OpenAPI generator to grpc-starter transcoding feature. I attempted to use @springdoc/springdoc-openapi, but it doesn’t seem to be compatible with this library.

Would it be possible to add OpenAPI support?

@DanielLiu1123
Copy link
Owner

DanielLiu1123 commented Jan 12, 2025

Thanks for noticing this feature.

springdoc-openapi parses Spring REST endpoints to generate OpenAPI definitions. I believe you’re looking for a tool that converts protobuf service definitions into OpenAPI definitions: protoc-gen-openapi.

Here’s an example of using protoc-gen-openapi: examples/transcoding/best-practice/bp-api.

Would it be possible to add OpenAPI support?

This project doesn’t offer direct OpenAPI support. It’s better to use a dedicated tool for this problem, like protoc-gen-openapi or protoc-gen-openapiv2.

@ilyakharlamov
Copy link
Author

protoc-gen-openapi is written in golang, so it does not fit well into the tech stack.
I am looking for a solution that will allow to use services for both gRPC and browser using JDK.

@DanielLiu1123
Copy link
Owner

protoc-gen-openapi is just a tool, and it works very well. You don’t need to specifically learn or know Go to use it.

I’m very cautious about adding new features. Considering that existing tools already support this functionality, I won’t include built-in support for it in the framework. Thank you for your understanding.

@DanielLiu1123
Copy link
Owner

I took another look at this feature, and it might work since it doesn’t need to depend on buf to build. I’m reopening this issue to get more feedback.

@DanielLiu1123 DanielLiu1123 reopened this Jan 31, 2025
@DanielLiu1123 DanielLiu1123 pinned this issue Jan 31, 2025
@DanielLiu1123 DanielLiu1123 linked a pull request Jan 31, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants