You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The openapi specs have more information then the TypedDict's in schemas.openapi allow. This results in type errors if we override some of the fields as described in the docs
For instance this code:
import typing
from rest_framework.request import Request
from rest_framework.schemas.openapi import SchemaGenerator
DRFOpenAPISchema = dict[str, typing.Any]
if typing.TYPE_CHECKING:
from rest_framework.schemas.openapi import DRFOpenAPISchema
class DataSchemaGenerator(SchemaGenerator):
def get_info(self):
info = super().get_info()
info["termsOfService"] = "https://example.com/tos.html"
return info
def get_schema(
self, request: Request | None = None, public: bool = False
) -> DRFOpenAPISchema:
schema = super().get_schema(request, public)
return schema
Results in this error:
Could not assign item in TypedDict "termsOfService" is not a defined key in "DRFOpenAPIInfo"
The text was updated successfully, but these errors were encountered:
The openapi specs have more information then the TypedDict's in
schemas.openapi
allow. This results in type errors if we override some of the fields as described in the docsFor instance this code:
Results in this error:
The text was updated successfully, but these errors were encountered: