Skip to content

Create non-pointer map/slice fields from optional properties#382

Closed
karupanerura wants to merge 4 commits intooapi-codegen:mainfrom
karupanerura:feature/non-pointer-optional-slice-fields
Closed

Create non-pointer map/slice fields from optional properties#382
karupanerura wants to merge 4 commits intooapi-codegen:mainfrom
karupanerura:feature/non-pointer-optional-slice-fields

Conversation

@karupanerura
Copy link
Copy Markdown
Contributor

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.

@deepmap-marcinr deepmap-marcinr added the ☢️ breaking change This change would break existing users' code label Jun 18, 2021
@ckarenz
Copy link
Copy Markdown

ckarenz commented Aug 12, 2021

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.

@karupanerura
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown

@ckarenz ckarenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tagging @deepmap-marcinr for approval/merge.

IMO this is a fantastic change and worth the break.

@icecube092
Copy link
Copy Markdown

icecube092 commented Oct 22, 2021

@deepmap-marcinr is this will be merged?

@jfcavalcante
Copy link
Copy Markdown

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

@deepmap-marcinr
Copy link
Copy Markdown
Contributor

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.

@amanbolat
Copy link
Copy Markdown

@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?

@dlsniper
Copy link
Copy Markdown

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?

@karupanerura
Copy link
Copy Markdown
Contributor Author

@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.

@mromaszewicz
Copy link
Copy Markdown
Member

Thank you for contributing, and I'm very sorry for taking so long to get to this PR. At this point, the code has changed so much that it's no longer relevant because the prefer-skip-optional-pointer-on-container-types configuration option now exists and handles both maps and slices. This PR's exact feature has been implemented as an opt-in configuration option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ breaking change This change would break existing users' code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create slice/map/string fields without pointers (for optional fields)

8 participants