jmcarp / jmcarp/flask-apispec

Swagger creates every http method for each urls of resource

Open
#231 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
652
Forks
151
PR merge metrics
No merged PRs in 30d

Description

I have a resource 'Students' which should have a
- GET method and url for that will have a path variable email
- PATCH method and url for that will have a path variable id

App.py
`api.add_resource(Students,api_version + '/student/','/student/')`

Students Resource
```
class Students(MethodResource,Resource):

@doc(description='Get student information',tags=['Student'])
@marshal_with(StudentResponseSchema,code='200',description='Returns active student json')
def get(self,email,id=None):
..

@doc(description='Update student nick name and avatar url provided in request body',tags=['Student'])
@use_kwargs(UpdateStudentClassAvatarRequestSchema,location=('json'))
@marshal_with(ResponseSchema,code='200')
def patch(self,id,avatar_url,nick_name,email=None):
..

```
My issue is Swagger is displaying both get and patch method for every url
![Screenshot from 2022-03-12 08-48-52](https://user-images.githubusercontent.com/42563130/158001860-4a2b1742-d6e3-4dc6-a46d-23018e2520af.png)
Please ignore PATCH /v1/student/last_login/{id}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the App.py api.add_resource call and the Students resource definition shown in the issue. Reproduce the Swagger output and trace how the two URL patterns and the get and patch methods are registered. Done means Swagger lists only GET for the email path and only PATCH for the id path, while the excluded last_login route remains ignored.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.