-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete Request not working from swagger UI #340
Comments
the problem is the UI is asking for JSON and you're sending back an invalid json. You'll need to figure tell swagger that the response type is text if it's not truly json. |
Hi fehguy, Thanks for responding!!!!!.the controller method which we are using is
entry in the Routes fileDELETE /Players/:id controllers.Application.deletePlayer(id: Long) we have another similar method which takes Id as input which works fine.Code of this method as shown below Thanks in Advance |
we have tried the following options also but we are getting the same issue |
Hi, |
Hi, |
For me the problem using Play 2.1.3 and Swagger UI is that Swagger UI sets the DELETE request content type to application/json, but since the body of the DELETE request is empty, Play considers that the request is not valid application/json and therefore sends a Bad Request response. |
Then it should be resolved by the @consumes(MediaType.MULTIPART_FORM_DATA) annotation at the DELETE method. |
@valdemon Good point. We are using a custom Swagger library for Play 2 instead of the Wordnik one, so we will probably need to develop a way to declare the request content type in our implementation. |
@ludovicofischer @valdemon it seems that most frameworks are OK with Application/XML as the content type being sent when there is no data. |
Would it hurt to change the requests from an empty body to "{}"? (I applied this in my swagger-ui installation) |
Yes, I think that'd cause some servers to throw-up. |
I think this issue is back with the latest version... Whenever I try to DELETE a resource I always get the following error [Bad request]: For request 'DELETE /auth/users/5392238c1e04001e04b384b4/avatar' [Invalid Json] I haven't modified my source code and if I rollback to the previous version of Swagger it works correctly. Am I missing something? |
Just for info... Here's my annotations (I use scala): @ApiOperation( |
@giuseppegreco please master a shot |
* upstream/master: fixed swagger-api#340 with empty body, updated swagger-js updated to support explicit keys
DELETE's still have no content. swagger.js:1119 does not allow DELETE to have a body. The fix that worked for me was to change line 1119 of swagger.js to: |
for delete methods, best to use : Action.async(parse.empty) |
@alphaadidas thanks that's super helpful! |
@alphaadidas tx, empty body parser worked for me |
@alphaadidas - This saved my precious time. thanks a lot 👍 |
While performing DELETE Operation from swagger UI in playframework,Delete operation is not working.It is expecting json but the delete method is defined for Long datatype as input parameter.we are using Play 2.1.3.When we enter id of the Entity to delete ,getting the error message as message": "400 Error Invalid Json
The text was updated successfully, but these errors were encountered: