Skip to content

Conversation

samchon
Copy link
Owner

@samchon samchon commented Jul 4, 2025

This pull request introduces enhancements to schema composition and validation logic, focusing on improving the handling of discriminator properties in JSON schemas. The changes ensure better support for mapping values and add comprehensive validation checks for schema integrity.

Schema Composition Enhancements:

  • Improved discriminator handling in ChatGptSchemaComposer: Added support for mapping values in the discriminator property, ensuring mappings are transformed into appropriate schema references (#/components/schemas/...).
  • Enhanced discriminator logic in LlmSchemaV3_1Composer: Extended the discriminator handling to include validation of mappings and filtering of schema references, ensuring compatibility with the union structure. [1] [2]

Validation Logic Improvements:

  • Validation updates in test_chatgpt_schema_discriminator: Added checks for the presence and correctness of discriminator.mapping, verifying that all mapping values start with #/$defs/ or #/components/schemas/. [1] [2]
  • Expanded test coverage in validate_llm_schema_discriminator: Introduced new tests for additional vendors (claude, deepseek, and 3.1) and enhanced validation of discriminator.mapping for schema integrity. [1] [2] [3]

@samchon samchon requested a review from Copilot July 4, 2025 08:06
@samchon samchon self-assigned this Jul 4, 2025
@samchon samchon added bug Something isn't working enhancement New feature or request labels Jul 4, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves handling and validation of discriminator mappings in both LLM and ChatGPT schema composers, and bolsters test coverage for various vendors.

  • Transform discriminator.mapping entries into proper component schema references in LlmSchemaV3_1Composer and ChatGptSchemaComposer
  • Add new tests for claude and deepseek vendors and extend validation logic to assert mapping paths
  • Update existing ChatGPT and LLM tests to verify both original and inverted discriminator.mapping prefixes

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/composers/llm/LlmSchemaV3_1Composer.ts Enhance discriminator.mapping transformation to #/components/schemas/
src/composers/llm/ChatGptSchemaComposer.ts Add mapping conversion and wrap x-discriminator into a structured object
test/src/features/llm/schema/validate_llm_schema_discriminator.ts Introduce tests for claude and deepseek, check mapping presence
test/src/features/llm/chatgpt/test_chatgpt_schema_discriminator.ts Extend ChatGPT schema validation to include mapping assertions
Comments suppressed due to low confidence (1)

src/composers/llm/ChatGptSchemaComposer.ts:608

  • The discriminator object should use the standard propertyName field (not property) to align with the OpenAPI specification. Rename property to propertyName for correctness.
                      property: props.schema["x-discriminator"],

@samchon samchon merged commit fecc832 into master Jul 4, 2025
4 checks passed
@samchon samchon deleted the feat/discriminator branch July 4, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant