-
-
Notifications
You must be signed in to change notification settings - Fork 813
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
feat: implement skipping pointer type #1102
feat: implement skipping pointer type #1102
Conversation
Signed-off-by: Gabor Boros <gabor.brs@gmail.com>
@alexandear I assume you are a maintainer in the repo. May I ask a review from you? I found no contribution guidelines. |
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
@gabor-boros in fact, I'm not an official oapi-codegen maintainer. And don't have permission to merge this PR. So, we should wait for maintainers. |
Ah! I was misunderstanding this from the number of contributions. Sorry for the noise in this case and thank you for the replies! |
@alexandear do you have any suggestion who to ask about feedback on this PR? |
eepmap-marcinr is one of the maintainers. |
Great suggestion @alexandear, thank you! @deepmap-marcinr is there anything I could help out here with the review? |
This would be a huge relief from a lot of unnecessary boilerplate. @deepmap-marcinr this PR is backwards-compatible and shouldn't cause any hate mail (unlike similar PRs you commented on). Any chance it could be merged? |
Thank you. |
* feat: implement skipping pointer type Signed-off-by: Gabor Boros <gabor.brs@gmail.com> * docs: apply Go language naming Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com> --------- Signed-off-by: Gabor Boros <gabor.brs@gmail.com> Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
This PR implements skipping pointer types for optional fields to address #1039 and #1061. A new extension is defined to achieve the desired behaviour:
x-go-type-skip-optional-pointer
.The extension's name maybe longer than usual, but at least descriptive. If set to true, the type will not be a pointer if the field is optional or nullable. If set to false, the type will be a pointer.
In the case of custom types, like what was proposed in the mentioned issues (
Optional[string]
ornull.Bool
), the extension is respected, so it is controllable what to generate (ie. pointer or non-pointer type).I have already tested this on my own and works very well. Also, added some tests to cover value parsing and code generation. Probably there are cases I didn't prepare for, but I'm happy to add more scenarios.
Upon merge, this PR fixes #388, #382, #823, #1039, #1061 and closes #266, #479