oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Skip pointer by default

Open aksdb opened this issue 1 year ago • 3 comments

I had a similar requirement as in issue #1454 and discussion #1460 a while a go and implemented the following solution.

This is likely not of the necessary quality for merging, but I would still like to open this PR as a discussion about the implementation. If I missed anything obvious that could cause problems down the line, I will certainly adjust as necessary.

aksdb avatar Jul 10 '24 12:07 aksdb

Thanks for this - will try and look at it once the backlog of items for v2.4.0 are down!

jamietanna avatar Jul 10 '24 15:07 jamietanna

FYI this would also link in nicely with https://github.com/oapi-codegen/oapi-codegen/issues/1561 (as two alternative ways)

jamietanna avatar Aug 20 '24 20:08 jamietanna

Kind of from the side, but I personally would like something similar to this. More specifically, I would LOVE to have a "pointers-for-values-with-defaults" such that I can set it to "false" (or something like that). Scattering the x-go-type-skip-optional-pointer is very tedious for some of my optonal types that have defaults. I use kin-openapi for validation, and it just sets all the defaults values for me.

Napam avatar Aug 28 '24 18:08 Napam

Just curious if any progress has been made on getting this merged? Would love to use it

mminklet avatar Feb 04 '25 04:02 mminklet

Related: https://github.com/oapi-codegen/oapi-codegen/discussions/1860

jamietanna avatar May 10 '25 16:05 jamietanna