Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make error handling for non serializable objects configureable #8

Closed
mansenfranzen opened this issue Apr 25, 2021 · 1 comment
Closed
Assignees
Labels
enhancement New feature or request

Comments

@mansenfranzen
Copy link
Owner

One may show the nodel JSON schema within class doc string as a collapsable code block via :model-show-json:. This depends on the model to be completely JSON serializable. However, users may provide custom fields that are not serializable by default. This breaks the schema generation.

Currently, this is handled by intercepting such non serializable fields and replacing their types and default values to indicate an error. This is rather implicit even though there is an explicit remark in the documentation.

To improve, let's make the error handling configureable, like autodoc_pydantic_model_show_json_error_handling to be one of:

  • raise: Do not handle the error. Propagate it.
  • ignore: Drop all fields from the schema that are not JSON serializable and provide warning in the sphinx output.
  • coerce: Keep violating field names (and types?) but replace default (None?) and provide warning in the sphinx output.
@mansenfranzen mansenfranzen added the enhancement New feature or request label Apr 25, 2021
@mansenfranzen mansenfranzen self-assigned this Apr 25, 2021
@mansenfranzen
Copy link
Owner Author

Closed via #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant