Commit 4c5c973
fix(generator): empty additionalProperties treated as falsy, breaking nullable map example generation (AAWF-1198) (#3952)
* fix(formatter): handle empty additionalProperties as map[string]interface{}
When `additionalProperties: {}` is set on a schema, Python's truthiness
evaluates the empty dict as falsy, causing the additionalProperties block
to be skipped. The generator then fell through to the nullable path and
emitted `*NewNullableXxx(&Xxx{})` — a constructor that is never generated
for map schemas — resulting in a Go compile error.
Fix the condition to check for the presence of the key and an explicit
`false` value rather than relying on truthiness. When additionalProperties
is an empty dict or boolean `true`, normalize to `interface{}` as the
nested value type and format values inline.
Also remove the now-unreachable dead-code branch that previously handled
`type: object + additionalProperties: {}` after the nullable check.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* pre-commit fixes
* fix(formatter): properly escape values in untyped additionalProperties
When formatting values for untyped additionalProperties (e.g. additionalProperties: {}),
infer the schema from the Python value type so that string escaping, boolean and
number formatting are handled correctly. Previously, the fallback `f'"{v}"'` would
embed raw newlines in Go string literals, causing compile errors for values like
multi-line strings.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* pre-commit fixes
* fix(formatter): use map type for named map schemas in array items
When array items are a $ref to a schema with additionalProperties (and
no properties), schema_name() returned the ref name (e.g.
IDPConfigValueItem) which was used as the Go type — but no struct is
ever generated for map schemas, causing a compile error.
Apply the same additionalProperties != False guard used elsewhere so
that named map schemas resolve to map[string]T instead of the struct
name, consistent with how type_to_go() handles them.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com> 064ea680 parents commit 4c5c973
6,217 files changed
Lines changed: 3283914 additions & 0 deletions
File tree
- lib/godoc
- analysis
- gopher
- images
- pkg
- github.com
- DataDog
- datadog-api-client-go
- v2
- api
- datadogV1
- datadogV2
- datadog
- src/github.com/DataDog/datadog-api-client-go/v2/api
- datadogV1
- datadogV2
- datadog
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Loading
Loading
Loading
Loading
Loading
Loading
Loading
0 commit comments