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

Create non-pointer map/slice fields from optional properties

Open karupanerura opened this issue 4 years ago • 5 comments

Partially resolves #266.

No support for string, as it is still under discussion. map/slice can represent nil without making it a pointer, so this patch should be able to resolve the issue about for map/slice.

karupanerura avatar Jun 09 '21 02:06 karupanerura

I'd love to see this go in. Is there an issue blocking merge? If so, can I help?

The build failure appears to come from the main branch.

ckarenz avatar Aug 12 '21 23:08 ckarenz

Thank you. I think you are right, the build failure appears to come from the main branch. Now I'm waiting for the fix and this patch to be reviewed and accepted. No TODO.

karupanerura avatar Aug 13 '21 00:08 karupanerura

@deepmap-marcinr is this will be merged?

icecube092 avatar Oct 22 '21 09:10 icecube092

@deepmap-marcinr is there any updates on this change?

jfcavalcante avatar Jul 21 '22 17:07 jfcavalcante

This will break existing generated code. I've taken the approach of making these kinds of changes changed by flag. Your change moves the decision from templates ({{if not .Requored}}) to code. Could you extend the code generation options to provide the old behavior with an option? Please see: https://github.com/deepmap/oapi-codegen/blob/master/pkg/codegen/configuration.go#L37

Whenever changes liek this go in, they cause some hate mail.

deepmap-marcinr avatar Jul 21 '22 17:07 deepmap-marcinr

@deepmap-marcinr Hi,

Would it be an option to introduce an extended property such as x-go-non-pointer to make a filed with this tag presented as non-pointer in go code?

amanbolat avatar Feb 02 '23 17:02 amanbolat

Is there any interest in this PR?

I just bumped into this and would like to get it sorted.

@karupanerura do you have any interest in doing the change yourself? Should I fork the PR and send an upgraded one to address anything else required to merge it? Do maintainers have any interest to get it done?

Thank you?

dlsniper avatar Jun 16 '23 20:06 dlsniper

@dlsniper Sorry for the late reply. I'm happy if you fork from this branch. I don't have enough time to solve the problem for a while.

karupanerura avatar Jul 03 '23 06:07 karupanerura