2

I'm new to Flask and Flask-RestPlus. I'm creating a web api where I want keep my POST urls different from the GET urls which are visible in Swagger. For example in Flask-Restplus

@api.route('/my_api/<int:id>')
class SavingsModeAction(Resource):
    @api.expect(MyApiModel)
    def post(self):
        pass #my code goes here

    def get(self, id):
        pass #my code goes here

So in swagger for the both apis url would look like

GET: /my_api/{id}

POST: /my_api/{id}

But so far I have absolutely no use of {id} part in my post api and it perhaps creates a bit of confusion for an user whether to update an existing record or to create a new, however the purpose of the api is just to create.

The other problem is id now a mandatory field al lest from swagger.

Community
  • 1
  • 1
Rahul Chakrabarty
  • 2,149
  • 7
  • 39
  • 70

0 Answers0