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.
来源:https://stackoverflow.com/questions/57448609/with-flask-restplus-how-to-create-a-post-api-without-making-the-url-same-with-ge