| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Closes: #2430 OpenAPI 3.1 allows a schema whose only type is "null", which validates exactly the JSON value null. The type dispatch in oapiSchemaToGoType had no branch for it, so codegen failed with "unhandled Schema type: &[null]". Map such schemas to `any`, mirroring the permissive mapping used for typeless schemas, and skip the optional pointer since nil is already the zero value of `any`. Includes a regression test under internal/test/issues/issue-2430. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Greptile SummaryFixes a codegen crash introduced by OAI 3.1 schemas whose only type is "null" by adding a t.Is("null") branch in oapiSchemaToGoType that maps such schemas to any with the optional pointer suppressed, and adds a full regression test package under internal/test/issues/issue-2430.
Confidence Score: 4/5The change is small, self-contained, and only fires for the previously-unhandled pure-null type; existing generated output for all other types is unaffected. The fix is correct and well-tested. The only observation is that the new branch emits "any" as the Go type string while the equivalent typeless-schema path in GenerateGoSchema emits "interface{}", producing a minor inconsistency in generated output across the two code paths. pkg/codegen/schema.go — the any vs interface{} string choice relative to the typeless-schema branch is the only thing worth a second look. Important Files Changed
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
pkg/codegen/schema.go:1198-1200
The PR description says this mirrors "the permissive mapping used for typeless schemas," but the typeless-schema branch in `GenerateGoSchema` (line 782) emits `"interface{}"` as the Go type string, while this new branch emits `"any"`. Both are equivalent in Go 1.18+, but they produce different text in generated output and create an inconsistency within the same codebase. Aligning on one spelling avoids surprising downstream teams with mixed generated output.
```suggestion
outSchema.GoType = "interface{}"
outSchema.SkipOptionalPointer = true
outSchema.DefineViaAlias = true
```
Reviews (1): Last reviewed commit: "Handle pure nullable types" | Re-trigger Greptile |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes: #2430
OpenAPI 3.1 allows a schema whose only type is "null", which validates exactly the JSON value null. The type dispatch in oapiSchemaToGoType had no branch for it, so codegen failed with "unhandled Schema type: &[null]". Map such schemas to any, mirroring the permissive mapping used for typeless schemas, and skip the optional pointer since nil is already the zero value of any. Includes a regression test under internal/test/issues/issue-2430.