louis amoros
louis amoros

Reputation: 2546

swagger annotation content-type not set

I have this spring rest controller:

@RestController
@RequestMapping("/communications")
class CommunicationController(private val service: CommunicationService) {

    @ApiOperation(
        produces = APPLICATION_JSON_VALUE, 
        consumes = APPLICATION_JSON_VALUE
    )
    @GetMapping(
        consumes = [APPLICATION_JSON_VALUE], 
        produces = [APPLICATION_JSON_VALUE]
    )
    fun findAll(
        criterias: CommunicationCriterias, 
        page: Pageable
    ): List<CommunicationDTO> = service.findCommunications(criterias, page)

}

When I test this endpoint via the swagger-ui (springfox) interface, i got a 415: content type invalid error. It seems that content-type: application/json is not set in the header.

What is missing ?

Upvotes: 8

Views: 7227

Answers (1)

Tuomo Kestil&#228;
Tuomo Kestil&#228;

Reputation: 401

There is nothing to consume in HTTP GET request. I think you should remove the consumes from @GetMapping and @ApiOperation.

Upvotes: 1

Related Questions