I am creating documents for swagger using Swashbuckle in my WebApi 2 project.
I have the following method definition:
[HttpPost] [ResponseType(typeof(Reservation))] [Route("reservations")] [SwaggerResponse(HttpStatusCode.Created, Type = typeof(Reservation))] [SwaggerResponse(HttpStatusCode.BadRequest) ] [SwaggerResponse(HttpStatusCode.Conflict)] [SwaggerResponse(HttpStatusCode.NotFound)] [SwaggerResponse(HttpStatusCode.InternalServerError)] public async Task<HttpResponseMessage> ReserveTickets([FromBody] ReserveTicketsRequest reserveTicketRequest) {
However, the generated Swagger file contains HTTP 200 OK, although it is not specified anywhere.
/reservations: post: tags: - "Booking" operationId: "Booking_ReserveTickets" consumes: - "application/json" - "text/json" produces: - "application/json" - "text/json" parameters: - name: "reserveTicketRequest" in: "body" required: true schema: $ref: "#/definitions/ReserveTicketsRequest" responses: 200: description: "OK" schema: $ref: "#/definitions/Reservation" 201: description: "Created" schema: $ref: "#/definitions/Reservation" 400: description: "BadRequest" 404: description: "NotFound" 409: description: "Conflict" 500: description: "InternalServerError" deprecated: false
Is there any way to get rid of this 200 OK? This is confusing as it is not a valid answer.
Thanks for the suggestions.
c # swagger swashbuckle
Vรกclav holuลกa
source share