Add output_format discriminator to preview render schema#185
Merged
Conversation
Replace oneOf validation with discriminator-based conditional validation to improve schema performance. Validators can now check output_format directly instead of trying all combinations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
bokelley
added a commit
to adcontextprotocol/creative-agent
that referenced
this pull request
Nov 7, 2025
Implements the schema changes from adcontextprotocol/adcp#185 which adds a required output_format field to preview render responses. This discriminator field indicates whether preview_url, preview_html, or both are provided, improving validation performance by eliminating oneOf constraints. Changes: - Updated ADCP schemas from spec (preview-creative-response.json) - Regenerated Pydantic models with output_format enum (url/html/both) - Modified _generate_preview_variant() to set output_format based on which preview fields are provided - All 187 tests passing The output_format field is now required per spec: - "url": preview_url only (iframe-embeddable) - "html": preview_html only (direct embedding) - "both": both preview_url and preview_html provided 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
bokelley
added a commit
to adcontextprotocol/creative-agent
that referenced
this pull request
Nov 7, 2025
* Add output_format discriminator to preview responses Implements the schema changes from adcontextprotocol/adcp#185 which adds a required output_format field to preview render responses. This discriminator field indicates whether preview_url, preview_html, or both are provided, improving validation performance by eliminating oneOf constraints. Changes: - Updated ADCP schemas from spec (preview-creative-response.json) - Regenerated Pydantic models with output_format enum (url/html/both) - Modified _generate_preview_variant() to set output_format based on which preview fields are provided - All 187 tests passing The output_format field is now required per spec: - "url": preview_url only (iframe-embeddable) - "html": preview_html only (direct embedding) - "both": both preview_url and preview_html provided 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Improve output_format implementation and test coverage Address code review feedback: - Fix error handling: raise ValueError instead of defaulting when neither preview_url nor preview_html is provided (fail fast approach) - Reorder conditional logic for better readability (url/html/both) - Update docstring to document output_format field behavior - Add test assertions to verify output_format discriminator values - Verify that only appropriate preview fields are present per mode Tests verify: - output_format="html" sets field and excludes preview_url - output_format="url" sets field and excludes preview_html - Both single and batch modes correctly set discriminator All 187 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an
output_formatdiscriminator field to preview render responses to improve validation performance. Replaces inefficientoneOfconstraint with conditionalallOfvalidation based on discriminator value.Changes
output_formatfield with enum values: "url", "html", "both"Benefits
Validation performance improvement, especially for responses with multiple renders (companion ads, multi-placement formats).