Skip to content

Conversation

@zzstoatzz
Copy link
Collaborator

Summary

  • Removes the -> Any return type annotation from the ser_model() method in PrefectBaseSettings
  • Regenerates UI schema with correct type definitions
  • Updates UI type references to use non-suffixed schema types

Problem

The @model_serializer(mode='wrap') decorator with a return type annotation (e.g., -> Any) causes Pydantic to generate an empty serialization schema ({}). FastAPI 0.120+ uses serialization mode for response models, which causes types like APISettings to become unknown in the generated TypeScript schema.

Solution

Removing the return type annotation allows Pydantic to fall back to the model schema, producing correct OpenAPI definitions for all settings types. This also removes the need for separate -Input/-Output schema variants.

References

Test plan

  • UI lint passes
  • UI type validation passes
  • Pre-commit hooks pass
  • CI passes

🤖 Generated with Claude Code

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 3, 2025

CodSpeed Performance Report

Merging #19616 will not alter performance

Comparing fix/settings-serializer-openapi-schema (4103fcb) with main (63d071d)

Summary

✅ 2 untouched

…enAPI schema

The `@model_serializer(mode='wrap')` decorator with a return type annotation
(e.g., `-> Any`) causes Pydantic to generate an empty serialization schema.
This breaks OpenAPI schema generation in FastAPI 0.120+, which uses
serialization mode for response models.

Removing the return type annotation allows Pydantic to fall back to the
model schema, producing correct OpenAPI definitions for all settings types.

Also updated UI type references to use the non-suffixed schema types
(e.g., `HistoryResponse` instead of `HistoryResponse-Output`) since the
fix removes the need for separate Input/Output schema variants.

See: pydantic/pydantic#8791

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@zzstoatzz zzstoatzz force-pushed the fix/settings-serializer-openapi-schema branch from e596d29 to 4103fcb Compare December 3, 2025 23:18
@zzstoatzz zzstoatzz marked this pull request as ready for review December 4, 2025 20:45
@zzstoatzz zzstoatzz merged commit e430058 into main Dec 4, 2025
60 checks passed
@zzstoatzz zzstoatzz deleted the fix/settings-serializer-openapi-schema branch December 4, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants