Skip to content
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

Don't use pointer to slice of types #1561

Open
thatjames opened this issue Apr 20, 2024 · 2 comments
Open

Don't use pointer to slice of types #1561

thatjames opened this issue Apr 20, 2024 · 2 comments
Labels
enhancement New feature or request help wanted External contributions would be very much appreciated!

Comments

@thatjames
Copy link

Currently, the oapi-codegen tool will generate a pointer to a slice of types.

This is unnecessary, as slices are already reference values, per the language spec

This gives the ability to distinguish between an empty slice (len ==0) and an unset field (array == nil)

@jamietanna
Copy link
Collaborator

This is something I've considered before, too.

I think this keeps in line with the fact that if there's an optional value, it has a pointer associated with it.

However, I think adding an opt-in configuration via output-options would be reasonable, allowing folks to choose whether they want it or not.

@jamietanna jamietanna added enhancement New feature or request help wanted External contributions would be very much appreciated! labels Apr 20, 2024
@thatjames
Copy link
Author

That's a fair point, there are certainly valid reasons to use pointers to slices (beyond verifying if they are set or not).

I need to read up more on the output-options config items, sheepishly admitting I completely misunderstood that in my first read through...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted External contributions would be very much appreciated!
Projects
None yet
Development

No branches or pull requests

2 participants