swagger-api / swagger-api/swagger-codegen

swagger server should return 204 when it has an empty response body

Open
#2,089 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Swift Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Currently when running the swift tests, we do an add/get/delete of orders and pets, but some of these calls return a 200 with an empty response body, which on the Swift client causes a failure because it tries to parse out an empty body. The Swift/Alamofire implementation looks specifically for 204 return codes to avoid parsing in these cases - can we modify the backend to do this as well to make the test program not have an error in this situation?

Here is a sample that creates/gets/then deletes an order, the delete returning no data:

curl -i \

-X POST
-H "Content-Type: application/json"
-H "Accept-Language: en-US;q=1.0"
-H "Accept-Encoding: gzip;q=1.0, compress;q=0.5"
-H "User-Agent: SwaggerClient/com.swagger.SwaggerClient (1; OS Version 9.3 (Build 13E5200d))"
-d "{"petId":1000,"shipDate":"2016-02-09","id":1000,"quantity":10,"status":"placed","complete":false}"
"http://petstore.swagger.io/v2/store/order"

HTTP/1.1 200 OK
Date: Tue, 09 Feb 2016 20:46:21 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
Content-Type: application/json
Connection: close
Server: Jetty(9.2.9.v20150224)

{"id":1000,"petId":1000,"quantity":10,"shipDate":"2016-02-09T00:00:00.000+0000","status":"placed","complete":false}Josephs-MacBook-Pro:swagger-codegen-jaz jaz$
Josephs-MacBook-Pro:swagger-codegen-jaz jaz$
Josephs-MacBook-Pro:swagger-codegen-jaz jaz$ curl -i \

-H "Accept-Language: en-US;q=1.0"
-H "Accept-Encoding: gzip;q=1.0, compress;q=0.5"
-H "User-Agent: SwaggerClient/com.swagger.SwaggerClient (1; OS Version 9.3 (Build 13E5200d))"
"http://petstore.swagger.io/v2/store/order/1000"

HTTP/1.1 200 OK
Date: Tue, 09 Feb 2016 20:46:27 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
Content-Type: application/json
Connection: close
Server: Jetty(9.2.9.v20150224)

{"id":1000,"petId":1000,"quantity":10,"shipDate":"2016-02-09T00:00:00.000+0000","status":"placed","complete":false}Josephs-MacBook-Pro:swagger-codegen-jaz jaz$
Josephs-MacBook-Pro:swagger-codegen-jaz jaz$ curl -i \

-X DELETE
-H "Accept-Language: en-US;q=1.0"
-H "Accept-Encoding: gzip;q=1.0, compress;q=0.5"
-H "User-Agent: SwaggerClient/com.swagger.SwaggerClient (1; OS Version 9.3 (Build 13E5200d))"
"http://petstore.swagger.io/v2/store/order/1000"
HTTP/1.1 200 OK
Date: Tue, 09 Feb 2016 20:46:32 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, DELETE, PUT
Access-Control-Allow-Headers: Content-Type, api_key, Authorization
Content-Type: application/json
Connection: close
Server: Jetty(9.2.9.v20150224)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the DELETE /v2/store/order/{orderId} entry point and the supplied curl exchange, then review the Swift tests that add, get, and delete orders and pets. No source file or test path is named in the issue. Done means empty-body responses use HTTP 204 so the Swift client does not try to parse them and the test flow completes without an error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.