FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add Dict and List sprig functions for template generation by deefdragon · Pull Request #1582 · oapi-codegen/oapi-codegen · GitHub

Add Dict and List sprig functions for template generation - #1582

Closed
deefdragon wants to merge 1 commit into
oapi-codegen:mainfrom
deefdragon:deefdragon-template-functions
Closed

Add Dict and List sprig functions for template generation#1582
deefdragon wants to merge 1 commit into
oapi-codegen:mainfrom
deefdragon:deefdragon-template-functions

Conversation

deefdragon commented Apr 29, 2024
edited
Loading

Copy link
Copy Markdown
Contributor

This is a starter on what functions to add from the sprig template funcs. This resolves parts of #1536, as it provides atleast a starting point.

This is a draft for conformation that these are good. If this looks good, I will go through and add the appropriate tests as well as add documentation for the functions that are listed and the existing functions.

I think that I will add fail as well if there is no push to not do so. It would assist users id doing their own schema/extension validations IE #1554.

Copy link
Copy Markdown

Maybe we can also add support for string to integer conversion and vice-versa.

This will help a lot with customization based on status code.

Also is this PR ready, or still in draft? @deefdragon

In case u are not getting time to wrap this up, maybe I can continue on finishing and adding more Template functions, as this seems to be a good change for better customization support for custom config templates.

phoenisx commented Oct 22, 2025
edited
Loading

Copy link
Copy Markdown

Also I feel it would be best to introduce strig as a dep to this project instead of us creating our own duplicate template functions.
We can always merge maps. So the following should work and be simpler compared to us maintaining the same code.

import "github.com/Masterminds/sprig/v3"
// ...
maps.Copy(TemplateFunctions, sprig.FuncMap())

Edit:
I do see that we can get conflicts between duplicate keys, but feels like if that happens it's high likely that the conflicted functions are doing the same thing.

Copy link
Copy Markdown

For now, since I need this change in my project, I'll fork this project.

But I'd love it if these changes can get reviewed/approved 💯

Copy link
Copy Markdown

@jamietanna Maybe you can help here.

This PR has been open for a year now.
I can work on it in case this has become stale and isn't worked upon anymore.

Or maybe you have better ideas around this?

Copy link
Copy Markdown
Contributor Author

Please feel free to take over. Unfortunately life has gotten in the way of me keeping up with the prs I have open, and my fork that just imports sprig as a dep has worked well enough for me that I've not had a push to work on this.

Copy link
Copy Markdown

U can close this one, if u aren't going to contribute anymore.
I'll create a separate PR, after testing 👍🏽

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL