-
Notifications
You must be signed in to change notification settings - Fork 804
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
Generate code from custom templates #1521
Comments
Hey, I'm just in the middle of a complete re-write of our docs to improve this - if you see https://github.com/deepmap/oapi-codegen?tab=readme-ov-file#making-changes-to-code-generation and scroll to the code at the bottom ,it should be possible to specify your own (local/remote) templates for generation - does that work for you or have I misunderstood? |
What I’d like to do is basically add custom templates that contain additional code (for example: mapping to internal types). My understanding is that the current template config only allows me to override templates already defined. Is that correct? |
It will pull in any templates provided in the user-templates object. Unfortunately, I did not set it up to have a way to call those templates. As such, you need to call those templates somewhere that already exists, which will require over-riding at-least one existing template. |
Made the PR ready for review. Could use a check on if the documentation I put in the readme makes sense @sagikazarmark |
I'd like to integrate models and types with a custom (in-house built) framework.
In order to do that, I'd like to generate custom marshaler/unmarshaler functions.
It would be nice if I could add arbitrary templates to the code generation process.
One thing I tried is overriding templates for a server that I don't use. To complicate things, we still use the Chi integration, so I actually need to support two servers at the same time...which is not allowed at the moment.
As a result, I'm now overriding Chi templates by copying the original ones and extending them with my custom code which is not ideal IMO.
The text was updated successfully, but these errors were encountered: