From drf-yasg to OpenAPI 3ΒΆ

drf-yasg is an excellent library and the most popular choice for generating OpenAPI 2.0 / Swagger schemas with DRF. Unfortunately, it currently does not provide OpenAPI 3 support. Migration from drf-yasg to drf-spectacular requires only minor modifications.

  • @swagger_auto_schema is largely equivalent to @extend_schema.

  • manual_parameters is called parameters

  • openapi.Parameter is roughly equivalent to OpenApiParameter.

  • @swagger_serializer_method is equivalent to @extend_schema_field.

  • ref_name on Serializer Meta classes is supported (excluding inlining with ref_name=None)