practical-api-guidelines icon indicating copy to clipboard operation
practical-api-guidelines copied to clipboard

Add guidelines about content negotiation

Open MassimoC opened this issue 6 years ago • 4 comments

provide guidelines on content negotiation (accept / content-type).

MassimoC avatar Jan 28 '19 18:01 MassimoC

Introduce ConsumesAttribute and ProducesAttribute

Having the operations decorated with these attributes should also affect the Swagger documentation.

For example:

[SwaggerResponse((int)HttpStatusCode.OK, "Player data object")]
[SwaggerResponse((int)HttpStatusCode.NotFound, "Player not found")]	        
[SwaggerResponse((int)HttpStatusCode.InternalServerError, "API is not available")]
[Produces("application/json")]
public async Task<IActionResult> GetPlayer(int id) {}

What's the point to have application/json and text/json? We should remove text/json

MassimoC avatar Mar 09 '19 11:03 MassimoC

Regarding text/json, application/json: I just took that over from the code at hand. Also to show how multiple contenttypes can be specified. But for me, it is OK to drop text/json.

fgheysels avatar Mar 09 '19 19:03 fgheysels

Ref #102 and #103

MassimoC avatar Mar 18 '19 09:03 MassimoC

@filipvanraemdonck is working on this. Pending invite to assign to him.

tomkerkhove avatar Oct 08 '19 11:10 tomkerkhove