Skip to content
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

Multiple operations return values that are not described correctly by the OpenAPI document #112

Open
nielthiart opened this issue Dec 22, 2023 · 0 comments · May be fixed by #113
Open

Multiple operations return values that are not described correctly by the OpenAPI document #112

nielthiart opened this issue Dec 22, 2023 · 0 comments · May be fixed by #113

Comments

@nielthiart
Copy link

Delete pet operation returns 200 response

Delete pet operation returns 200 response, but the spec only describes a 400 for invalid ID.

Example:

curl -X 'DELETE' \
  'https://petstore3.swagger.io/api/v3/pet/10' \
  -H 'accept: */*' \
  -H 'api_key: qqqq'

Returns:

< HTTP/2 200
< date: Fri, 22 Dec 2023 12:30:11 GMT
< content-type: application/json
< content-length: 11
< access-control-allow-origin: *
< access-control-allow-methods: GET, POST, DELETE, PUT
< access-control-allow-headers: Content-Type, api_key, Authorization
< access-control-expose-headers: Content-Disposition
< server: Jetty(9.4.9.v20180320)
<
* Connection #0 to host petstore3.swagger.io left intact
Pet deleted%

CleanShot 2023-12-22 at 14 22 07@2x

This is addressed in #109

Update pet with form returns a 200 response with a Pet object

The Pet object returned by updatePetWithForm is not described in the spec.

Example:

curl -X 'POST' --verbose \
  'https://petstore3.swagger.io/api/v3/pet/10?name=lizard&status=available' \
  -H 'accept: */*' \
  -d ''

Response:

< HTTP/2 200
< date: Fri, 22 Dec 2023 12:31:22 GMT
< content-type: application/json
< content-length: 137
< access-control-allow-origin: *
< access-control-allow-methods: GET, POST, DELETE, PUT
< access-control-allow-headers: Content-Type, api_key, Authorization
< access-control-expose-headers: Content-Disposition
< server: Jetty(9.4.9.v20180320)
<
* Connection #0 to host petstore3.swagger.io left intact
{"id":10,"category":{"id":1,"name":"Dogs"},"name":"lizard","photoUrls":["string"],"tags":[{"id":0,"name":"string"}],"status":"available"}%

CleanShot 2023-12-22 at 14 25 00@2x

nielthiart added a commit to nielthiart/swagger-petstore that referenced this issue Dec 22, 2023
This update adds at least one successful HTTP `Response Object` to each `Responses Object`.

According to OAS 3.0.3 Spec:

> The default MAY be used as a default response object for all HTTP codes that are not covered individually by the specification.
>
> The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call.

[Specification link](https://swagger.io/specification/v3/#:~:text=and%20it%20SHOULD%20be%20the%20response%20for%20a%20successful%20operation)

Providing at least one response for a successful operation is only a recommendation (SHOULD), but not returning a success response for these operations doesn't make sense from a practical point of view.

According to the current document, the `paths./pet/{petId}.delete` operation, for example, can only return an error, even if the operation was successful. The example server, however, returns a 200.

Fixes swagger-api#112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant