I'm attempting to decipher a Swagger specification document and use it to generate code. It contains the following endpoint definition:
/feature:
get:
summary: Returns all features
operationId: getAllFeatures
tags:
- feature
responses:
'200':
description: 'Features retrieved successfully'
'400':
$ref: '#/responses/BadRequest'
Based on the endpoint summary and the 200 response description, it's pretty clear to me that this endpoint was intended to return a response body that contains an array or collection of "feature", even though the response is not defined in the spec.
Let's suppose that I'm right, and the spec author just forgot to add it. What then should I make of this endpoint:
/features:
put:
summary: Updates an existing feature
operationId: updateFeature
parameters:
- name: body
in: body
description: 'Feature to be updated'
required: true
schema:
$ref: '#/definitions/Feature'
tags:
- feature
responses:
'200':
description: 'Feature updated'
This one is ambiguous to me. I've seen some implementations of update endpoints that return the updated object. Others I've seen return nothing in the body.
My questions are this:
- Does a HTTP 200 response imply there must be a response body? I can't tell whether the HTTP specification (https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) requires this or if it just states that it could be there.
- Would it be less confusing in this scenario for the spec author to have used HTTP 204 to expressly indicate that there is no response body? (I can answer this - yes - but are there reasons to use HTTP 200 instead of 204 in this case? Or was this just that the author didn't know about success response codes other than HTTP 200?)
- If the answer to #1 is no, and the answer to #2 is yes: why was HTTP defined in this manner?