Closed jsonvot closed 8 months ago
The RESTful API of the post method should not have the last path argument appear
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 UserView(HTTPMethodView): middleware = [] async def get(self, request: Request): return json({'code': 200}) async def post(self, request: Request): return json({'code': 200}) async def put(self, request: Request): return json({'code': 200}) async def delete(self, request: Request): return json({'code': 200}) user_bp = Blueprint('user_bp') user_bp.add_route(UserView.as_view(), '/api/user/<user_id:int>') app.blueprint(user_bp)
No response
Sanic CLI
Linux
23.12.1
Just out of curiosity - why it is redundant?
POST method may have a path argument when we want to explicitly name a resource or to assign a specific id, in some cases it could be even mandatory.
POST
Is there an existing issue for this?
Describe the bug
The RESTful API of the post method should not have the last path argument appear
Code snippet
Expected Behavior
No response
How do you run Sanic?
Sanic CLI
Operating System
Linux
Sanic Version
23.12.1
Additional context
No response