sanic-org / sanic

Accelerate your web app development | Build fast. Run fast.
https://sanic.dev
MIT License
18.02k stars 1.55k forks source link

openapi json exception #2909

Closed jsonvot closed 6 months ago

jsonvot commented 8 months ago

Is there an existing issue for this?

Describe the bug

When using class view, the generated openapi json mapping is out of order。

image

Code snippet

from sanic import Sanic
from sanic.blueprints import Blueprint
from sanic.request import Request
from sanic.response import json
from sanic.views import HTTPMethodView

app = Sanic(__name__)
app.config.update({
    'OAS_UI_DEFAULT': 'swagger'
})

class DeleteMixin:
    async def delete(self, request: Request):
        pass

class PutMixin:
    async def put(self, request: Request):
        pass

class TestView(HTTPMethodView, DeleteMixin, PutMixin):
    middleware = []

    async def get(self, request: Request):
        return json({'code': 200})

class UserView(HTTPMethodView, DeleteMixin, PutMixin):
    middleware = []

    async def get(self, request: Request):
        return json({'code': 200})

test_bp = Blueprint('test_bp')
test_bp.add_route(TestView.as_view(), '/test-api/test')

user_bp = Blueprint('user_bp')
user_bp.add_route(UserView.as_view(), '/api/user')

app.blueprint(Blueprint.group(*[test_bp, user_bp]))

Expected Behavior

No response

How do you run Sanic?

Sanic CLI

Operating System

Linux

Sanic Version

23.12.0

Additional context

No response