Closed Bishwas-py closed 4 months ago
Currently,
class SimpleCommentSchema(TypedDict): comment_count: int | None last_comment: CommentSchema | None @computed_field def comments(self, *args, **kwargs) -> SimpleCommentSchema: comments = PolymorphicComments.objects.filter( parent_id=self._source_obj.id, parent_type=ContentType.objects.get_for_model(self._source_obj)).alive() print(comments.count()) return { 'comment_count': comments.count(), 'last_comment': comments.last() if comments.exists() else None, }
like fields' schema is not being address in Swagger.
FIx: https://github.com/pydantic/pydantic/discussions/6298
Fix: openapi/openapi_path.py, line 152 be replaced with:
openapi/openapi_path.py, line 152
prepared_schema = response_model.model_json_schema(ref_template=REF_MODAL_TEMPLATE, mode='serialization')
Currently,
like fields' schema is not being address in Swagger.
FIx: https://github.com/pydantic/pydantic/discussions/6298