Skip to content

Include class docstrings as description in OpenAPI schema#52

Merged
drhagen merged 2 commits into
drhagen:masterfrom
renan-r-santos:docstring-in-openapi-schema
Apr 8, 2026
Merged

Include class docstrings as description in OpenAPI schema#52
drhagen merged 2 commits into
drhagen:masterfrom
renan-r-santos:docstring-in-openapi-schema

Conversation

@renan-r-santos

Copy link
Copy Markdown
Contributor

Class docstrings were not showing up as "description" in the OpenAPI schema. This is because Pydantic v2 delegates schema generation entirely to __get_pydantic_json_schema__, which we override, and we weren't injecting cls.__doc__ into the result.

@drhagen

drhagen commented Apr 8, 2026

Copy link
Copy Markdown
Owner

I moved the automatic __doc__ implementation to the mixins, because that felt like a more appropriate place to do this. Let me know whether or not that meets your need.

@renan-r-santos

Copy link
Copy Markdown
Contributor Author

I moved the automatic __doc__ implementation to the mixins, because that felt like a more appropriate place to do this. Let me know whether or not that meets your need.

That's way better, thanks! And I confirmed it works fine too.

@drhagen drhagen merged commit ece53c5 into drhagen:master Apr 8, 2026
6 checks passed
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.

2 participants