-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(output-options): correctly reference x-go-type-skip-optional-pointer in allOf
#2042
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
fix(output-options): correctly reference x-go-type-skip-optional-pointer in allOf
#2042
Conversation
Kusari Analysis ResultsAnalysis for commit: bd7226e, performed at: 2025-07-25T17:16:20Z • • Recommendation✅ PROCEED with this Pull Request Summary✅ No Flagged Issues Detected All values appear to be within acceptable risk parameters. No pinned version dependency changes, code issues or exposed secrets detected! Found this helpful? Give it a 👍 or 👎 reaction! |
…r` defined on referenced types
|
Kusari PR Analysis rerun based on - 42d87c7 performed at: 2025-07-23T02:19:13Z - link to updated analysis |
x-go-type-skip-optional-pointeron referenced typesx-go-type-skip-optional-pointer on referenced types
|
Hey @magnetikonline thanks for raising this! Taking a look at the example you've shared in the body of the PR, I can't seem to make this fail on On
|
|
Thanks @jamietanna will do. Things are certainly working as I'd expect with our internal schemas (which of course I can't post here) - but I'll get the example into a state which trips the change I'm trying to make. 👍 Cheers. |
|
Kusari PR Analysis rerun based on - 201bd1e performed at: 2025-07-23T07:54:13Z - link to updated analysis |
|
NP, thanks! I've pushed a (failing) change for the example above, which flags that the example you'd shared doesn't seem to work right now (I'm very happy to collaborate on this, or if you'd prefer I move the fix for the issue I've just pushed to a separate PR) |
|
Hey @jamietanna - was having a brain fart yesterday trying to work this out 😄 - with fresh eyes today and reviewing our internal schemas - I've been able to produce an example that shows drift between the prior It's when the referenced type is a child of an As a diff to your update: diff --git examples/output-options/preferskipoptionalpointer/api.yaml examples/output-options/preferskipoptionalpointer/api.yaml
index 369d281..8bb64c8 100644
--- examples/output-options/preferskipoptionalpointer/api.yaml
+++ examples/output-options/preferskipoptionalpointer/api.yaml
@@ -51,7 +51,8 @@ components:
# TODO
$ref: '#/components/schemas/ReferencedWithoutExtensionMap'
withExtension:
- $ref: '#/components/schemas/ReferencedWithExtension'
+ allOf:
+ - $ref: '#/components/schemas/ReferencedWithExtension'
ReferencedWithExtension:
type: objectThis will give different behaviour between this PR and the To expand as to why? Pre oapi-codegen/pkg/codegen/schema.go Lines 272 to 278 in e93501d
Since Moving to fad490f - now This PR will repair both these above cases. I still have to make changes to our schemas with an additional sprinkingling of I've not committed to my branch - I didn't want to clobber your commits - but I hope this should give you a good working example of what this PR fixes. I've also updated the PR description to suit to match the test example. 👍
nah more than happy to pair on this PR here 👍 |
|
Hey @magnetikonline happy for you to push up to this branch (you could do it as separate commits on top of what's pushed here, as we generally squash-merge external contributions) Thanks for digging into that, that makes sense |
…lpointer` OpenAPI YAML
|
Kusari PR Analysis rerun based on - 02f8b04 performed at: 2025-07-25T02:37:55Z - link to updated analysis |
|
Kusari PR Analysis rerun based on - 6ce0234 performed at: 2025-07-25T03:09:47Z - link to updated analysis |
Thanks @jamietanna - I've tried to keep the tests same/same to the others, I think that's enough to show it does what it proposes on the tin. 👍
not a problem - happy I was able to explain myself! |
|
Kusari PR Analysis rerun based on - c362f22 performed at: 2025-07-25T17:09:45Z - link to updated analysis |
x-go-type-skip-optional-pointer on referenced typesx-go-type-skip-optional-pointer in allOf
|
Kusari PR Analysis rerun based on - bd7226e performed at: 2025-07-25T17:16:20Z - link to updated analysis |
|
Thanks @jamietanna for your time on this and getting it merged. Most appreciated. 👍 |
I've noted a regression as part of #2021.
Previously, since
Schema{}.SkipOptionalPointerwas never set, it always defaulted tofalse, which suited our use case.With the change as part of #2021 and in the new https://github.com/oapi-codegen/oapi-codegen/releases/tag/v2.5.0 release - this now uses the global output option setting of
prefer-skip-optional-pointer:in all cases - and can't be over-ridden locally within a type.This change fixes that behaviour, with
x-go-type-skip-optional-pointerchecked and evaluated up front for the type/referenced type - meaning a schema blob such as below will now respect thex-go-type-skip-optional-pointer: falsevalue where referenced againstapples|orangesand of course fallback to the global output option if unset:Example: