-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Generating Huma Code from OpenAPI Spec #439
Comments
@srilman thanks for the question! Unfortunately that isn't possible at the moment. Huma does not generate anything from OpenAPI specs itself. It would be possible to create a template for other code generators that spits out Go code using Huma, but I don't think that exists at the moment. As a side note, it's also a bit complicated because Huma supports most but not all of the OpenAPI features, and some OpenAPI documents can be written in a way that makes it hard to generate sane Go code (for example using Anyway I'd be happy if someone wants to build this, otherwise you may just have to manually convert it to Go code for the time being. |
Good point about the complex spec features ( I think for the time being, I'm going to write a small Python script using https://github.com/Dorthu/openapi3 to generate a template, and then fill in the blanks for anything too complicated. Once I have something working, I'm happy to share a Gist. |
Is there any way to generate a REST API using Huma from an OpenAPI spec? The docs mention the opposite, using Huma and
oapi-generator
to reconstruct a server without Huma. However, I have a use-case where I have an existing OpenAPI spec that I want to implement while retaining some of the other benefits of Huma (validation, docs generation, etc) without needing to copy everything over.I wasn't sure whether to ask this question in this repo or the
oapi-generator
repo. I does seem like more their alley, but they may not store all of the spec info for codegen.The text was updated successfully, but these errors were encountered: