Skip to content

Conversation

@KanchiShimono
Copy link
Contributor

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Fixes #2024

This PR updates the _ensure_strict_json_schema function so that when a $ref is expanded inline (due to the presence of other fields like description), we recursively re-run the function on the resulting inline object. This ensures additionalProperties: false is correctly applied even if the schema is expanded.

Additionally, new test code has been added to confirm that models with nested references and annotated fields (e.g., Field(description="...")) correctly produce additionalProperties=False for the inline-expanded objects.

Additional context & links

  • This addresses scenarios where $ref plus extra properties leads to inline expansion, causing the prior implementation to skip setting additionalProperties: false.
  • The newly introduced unit test verifies that models with description fields do not lose their strict schema configuration after the inline expansion.
@KanchiShimono KanchiShimono requested a review from a team as a code owner January 16, 2025 23:39
@RobertCraigie RobertCraigie changed the base branch from main to next January 17, 2025 09:21
@RobertCraigie RobertCraigie changed the title Fix inline ref expansion in _ensure_strict_json_schema to consistently set additionalProperties: false fix(structured outputs): correct schema coercion for inline ref expansion Jan 17, 2025
Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@RobertCraigie RobertCraigie merged commit 2f4f0b3 into openai:next Jan 17, 2025
2 checks passed
@stainless-app stainless-app bot mentioned this pull request Jan 17, 2025
@KanchiShimono KanchiShimono deleted the fix-inline-ref-addprops branch January 19, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants