Skip to content
This repository was archived by the owner on Mar 15, 2026. It is now read-only.

Add output_format discriminator to preview responses#32

Merged
bokelley merged 2 commits into
mainfrom
output-format-discriminator
Nov 7, 2025
Merged

Add output_format discriminator to preview responses#32
bokelley merged 2 commits into
mainfrom
output-format-discriminator

Conversation

@bokelley

@bokelley bokelley commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Summary

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 with values: url (iframe-embeddable), html (direct embedding), or both (both formats provided).

bokelley and others added 2 commits November 7, 2025 10:40
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>
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>
@bokelley bokelley merged commit cc83efd into main Nov 7, 2025
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant