Skip to content

Commit 7f329ad

Browse files
committed
fix nullable additional properties
1 parent cfdcfc9 commit 7f329ad

4 files changed

Lines changed: 591 additions & 3 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{!
2+
Renders the Go type for a property, accounting for nullable additionalProperties.
3+
Upstream Go codegen ignores `nullable: true` inside additionalProperties when
4+
computing the map value type, producing `map[string]string` instead of
5+
`map[string]*string`. This partial restores the missing `*` on the map value
6+
when the additionalProperties schema is nullable, and otherwise emits
7+
the upstream-computed dataType unchanged.
8+
}}{{#isMap}}{{#additionalProperties.isNullable}}map[string]*{{{additionalProperties.dataType}}}{{/additionalProperties.isNullable}}{{^additionalProperties.isNullable}}{{{dataType}}}{{/additionalProperties.isNullable}}{{/isMap}}{{^isMap}}{{{dataType}}}{{/isMap}}

languages/golang/compat-layer/templates/model_simple.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,11 +633,11 @@ func set{{classname}}{{getter}}AttributeType(arg *{{classname}}{{getter}}Attribu
633633
{{^isArray}}
634634
// isContainer
635635
// Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead
636-
type {{classname}}{{getter}}AttributeType = *{{dataType}}
636+
type {{classname}}{{getter}}AttributeType = *{{>field_type}}
637637
// Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead
638-
type {{classname}}{{getter}}ArgType = {{#isNullable}}*{{/isNullable}}{{dataType}}
638+
type {{classname}}{{getter}}ArgType = {{#isNullable}}*{{/isNullable}}{{>field_type}}
639639
// Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead
640-
type {{classname}}{{getter}}RetType = {{#isNullable}}*{{/isNullable}}{{dataType}}
640+
type {{classname}}{{getter}}RetType = {{#isNullable}}*{{/isNullable}}{{>field_type}}
641641
// Deprecated: Will be removed after 2026-09-30. Move to the packages generated for each available API version instead
642642
func get{{classname}}{{getter}}AttributeTypeOk(arg {{classname}}{{getter}}AttributeType) (ret {{classname}}{{getter}}RetType, ok bool) {
643643
if arg == nil {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{!
2+
Renders the Go type for a property, accounting for nullable additionalProperties.
3+
Upstream Go codegen ignores `nullable: true` inside additionalProperties when
4+
computing the map value type, producing `map[string]string` instead of
5+
`map[string]*string`. This partial restores the missing `*` on the map value
6+
when the additionalProperties schema is nullable, and otherwise emits
7+
the upstream-computed dataType unchanged.
8+
}}{{#isMap}}{{#additionalProperties.isNullable}}map[string]*{{{additionalProperties.dataType}}}{{/additionalProperties.isNullable}}{{^additionalProperties.isNullable}}{{{dataType}}}{{/additionalProperties.isNullable}}{{/isMap}}{{^isMap}}{{{dataType}}}{{/isMap}}

0 commit comments

Comments
 (0)