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

Example of using IDL with hertz and javascript/typescript #726

Closed
Rainshaw opened this issue Apr 15, 2023 · 5 comments
Closed

Example of using IDL with hertz and javascript/typescript #726

Rainshaw opened this issue Apr 15, 2023 · 5 comments
Labels
question Further information is requested

Comments

@Rainshaw
Copy link

Describe the Question

Hello, thanks for your excellent work. I'm using hertz to build systems with IDL. It works well on the backend, but when IDL changed, I have to manually modify the js/ts code of frontend. I want to know if there is some way we could do this work more automatically. I searched the world and find some repos which can generate js/ts with IDL, but hz annotation does not works.

Reproducible Code

Give examples for generating js/ts code with using thrift/protobuf as IDL, and annotation should work.

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your question.

Hertz version:

Please provide the version of Hertz you are using.

Environment:

The output of go env.

Additional context

Add any other context about the question here.

@rogerogers
Copy link
Contributor

My understanding is that IDL is not very friendly to JavaScript, so I use IDL to convert to OpenAPI, and then convert to JavaScript.

@Rainshaw
Copy link
Author

My understanding is that IDL is not very friendly to JavaScript, so I use IDL to convert to OpenAPI, and then convert to JavaScript.

thanks for your reply. are you using protobuf with https://www.cloudwego.io/docs/hertz/tutorials/toolkit/plugin to gen openapi? how to do with thrift, I understand that thriftgo seems only support go language now...

and could you share which tool you used to covert openapi to js/ts?

@FGYFFFF
Copy link
Contributor

FGYFFFF commented Apr 17, 2023

Right now thriftgo does not have a plugin that generates openapi for "thrift", but you can investigate if there are other similar tools.

We don't currently offer a thrift to typescript conversion. Can you be more specific about the scenario? I'll do a research.

@Rainshaw
Copy link
Author

Previously we were using documentation to communicate API changes, now we want to use the features of hertz and IDL to do this.

hertz adds some annotations to IDL to generate Method and Path etc. in the code, this feature I understand should be achieved through hz as a protoc plugin. Currently we find some protoc plugins that generate js/ts but none of them support hz annotations, resulting in only being able to use the models generated by these plugins, and not the Service.

I hope to use this scenario as an example to add support for other language generation, for example, in the refactoring process, which may be refactored module by module, then microservices in other languages now only could use the idl generated model when using the idl provided by hertz, without the ability to have a client-like encapsulation.

@welkeyever
Copy link
Member

@Rainshaw Thank you very much for your trust!
If you are already using hertz in production, please let us know - we will provide high-quality support for the needs of enterprise users - all you need to do is just reply this issue 🤗

@li-jin-gou li-jin-gou added the question Further information is requested label Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

5 participants