Skip to content

feat(output-options): add prefer-skip-optional-pointer to default to skipping optional pointers #1694

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

Merged
merged 12 commits into from
May 10, 2025

Conversation

aksdb
Copy link
Contributor

@aksdb aksdb commented Jul 10, 2024

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 aksdb requested a review from a team as a code owner July 10, 2024 12:31
@jamietanna
Copy link
Member

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

@jamietanna
Copy link
Member

FYI this would also link in nicely with #1561 (as two alternative ways)

@Napam
Copy link

Napam commented Aug 28, 2024

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.

@mminklet
Copy link

mminklet commented Feb 4, 2025

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

@jamietanna jamietanna changed the title Skip pointer by default feat(output-options): add prefer-skip-optional-pointer to imply skipping optional pointers May 10, 2025
Comment on lines 269 to 270
// For object references pointers are the only way to denote optional, in contrast
// to other types where the zero-value can be used for that.
Copy link
Member

Choose a reason for hiding this comment

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

Where does this get triggered? I can't seem to work out where this may occur 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I actually don't remember anymore. If I spot anything later, I'll add it here (or in a discussion, or issue or whatever would be appropriate then 😄 )

@jamietanna
Copy link
Member

Related: #1860

@jamietanna jamietanna changed the title feat(output-options): add prefer-skip-optional-pointer to imply skipping optional pointers feat(output-options): add prefer-skip-optional-pointer to default to skipping optional pointers May 10, 2025
@jamietanna jamietanna added enhancement New feature or request notable changes Used for release notes to highlight these more highly labels May 10, 2025
Copy link
Member

@jamietanna jamietanna left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this 💜

@jamietanna jamietanna merged commit ccfe27a into oapi-codegen:main May 10, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request notable changes Used for release notes to highlight these more highly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy