fix(codegen): generate pointer types for nullable array items#2167
fix(codegen): generate pointer types for nullable array items#2167putcho01 wants to merge 1 commit intooapi-codegen:mainfrom
Conversation
When an array schema has items with `nullable: true`, the generated Go type now correctly uses pointer types (e.g., `[]*float32` instead of `[]float32`) to properly represent nullable values. This fix follows the same pattern already used for nullable additional properties, checking the OAPISchema.Nullable field and prefixing the item type with `*` when nullable is true. Fixes oapi-codegen#2016
|
Would using the Output Option |
|
@jamietanna
|
|
Gotcha, thanks - should we also be correctly using |
|
@jamietanna That said, I want to make sure I understand your concern correctly. |
|
Hi @jamietanna , just checking if you had a chance to look at my question above. Let me know what you think! |
This PR adds capability to generate pointer types for nullable array items.
When an array's items have
nullable: true, the generated Go type now correctly uses pointer types (e.g.,[]*float32instead of[]float32) to properly represent nullable values.Ref Issue: #2016
Changes
oapiSchemaToGoType()inpkg/codegen/schema.goto check thenullableproperty of array itemsinternal/test/issues/issue-2016/covering:Example
Input schema: Sample
Before (incorrect)
After (correct)