Skip to content

Fix generator to include additional properties with boolean values#3553

Merged
nogates merged 3 commits into
masterfrom
nogates/add-entity-v3-api-spec-interface
Jul 7, 2026
Merged

Fix generator to include additional properties with boolean values#3553
nogates merged 3 commits into
masterfrom
nogates/add-entity-v3-api-spec-interface

Conversation

@nogates

@nogates nogates commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a bug in .generator/src/generator/openapi.py where child_models() incorrectly skipped oneOf schemas that declare additionalProperties: false.

Root cause: The guard that excludes pure-map schemas (e.g. Hash<String, T>) checked "additionalProperties" in schema, which matched both real map schemas and schemas with additionalProperties: false — a completely different JSON Schema keyword meaning "no extra properties beyond those in properties". As a result, EntityV3APISpecInterface (a oneOf with additionalProperties: false and no properties) was silently dropped from the model list and never generated.

EntityV3APISpec.openapi_types already maps interface to :'EntityV3APISpecInterface', so the missing file caused a NameError at deserialization time whenever that field appeared in a response.

Fix: Replace "additionalProperties" in schema with schema.get("additionalProperties") not in (None, False) — the same pattern already used in type_to_ruby() in the same file. Only treat additionalProperties as a map type when its value is an actual schema object, not a boolean.

This also adds the previously missing entity_v3_api_spec_interface.rb model file and its Zeitwerk inflector entry, both now produced correctly by the fixed generator.

Additional Notes

The pre-commit fixes commit in this branch is from CI running the old (buggy) generator on the first attempt, which deleted the manually added file. The final commit contains the generator fix plus the correctly generated output.

Review checklist

  • This PR includes all newly recorded cassettes for any modified tests.

  • This PR does not rely on API client schema changes.

    • The CI should be fully passing.

nogates and others added 3 commits July 6, 2026 16:04
The EntityV3APISpec.interface property references EntityV3APISpecInterface
as its type, but the model file was never committed. This caused a NameError
at deserialization time for any response using that field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…odels

The child_models() guard skipping pure-map schemas checked only whether
additionalProperties was present in the schema, not whether its value was
a real schema object. This caused schemas with additionalProperties: false
(e.g. EntityV3APISpecInterface, a oneOf with strict no-extra-props) to be
incorrectly skipped — same as a pure Hash<String, T> map — which is why
entity_v3_api_spec_interface.rb was never generated.

Fix mirrors the pattern already used in type_to_ruby(): only treat
additionalProperties as a map type when its value is not in (None, False).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nogates nogates requested review from a team as code owners July 7, 2026 07:04
@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Jul 7, 2026

Copy link
Copy Markdown

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Ensure labels | changelog   View in Datadog   GitHub Actions

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: f33ea56 | Docs | Datadog PR Page | Give us feedback!

@nogates nogates merged commit 357fcfa into master Jul 7, 2026
19 of 20 checks passed
@nogates nogates deleted the nogates/add-entity-v3-api-spec-interface branch July 7, 2026 10:45
github-actions Bot pushed a commit that referenced this pull request Jul 7, 2026
…3553)

* fix: add missing EntityV3APISpecInterface model and inflector entry

The EntityV3APISpec.interface property references EntityV3APISpecInterface
as its type, but the model file was never committed. This caused a NameError
at deserialization time for any response using that field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* pre-commit fixes

* fix: treat additionalProperties: false as a regular object in child_models

The child_models() guard skipping pure-map schemas checked only whether
additionalProperties was present in the schema, not whether its value was
a real schema object. This caused schemas with additionalProperties: false
(e.g. EntityV3APISpecInterface, a oneOf with strict no-extra-props) to be
incorrectly skipped — same as a pure Hash<String, T> map — which is why
entity_v3_api_spec_interface.rb was never generated.

Fix mirrors the pattern already used in type_to_ruby(): only treat
additionalProperties as a map type when its value is not in (None, False).

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> 357fcfa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants