swagger icon indicating copy to clipboard operation
swagger copied to clipboard

@Success/@Failure response_type should be optional

Open tesujimath opened this issue 9 years ago • 4 comments

According to the Swagger 1.2 spec, section 5.2.5, the responseModel is not required. https://github.com/swagger-api/swagger-spec/blob/master/versions/1.2.md#525-response-message-object However, here the markup is required to be {object} or {array}. Similarly for the response_data_type.

Currently for an operation which returns no data, I have to do something like this:

// @Success 204 {object} bool "OK (no content)"

which is clearly a lie.

What I really ought to be able to do is something like this:

// @Success 204 - - "OK (no content)"

Currently trying to do this generates the error message:

Can not parse comment for function: MyOperation, package: mypackage, got error: Can not parse response comment "204 - - "OK (no content)"", skipped.

A similar argument could be made for various other status codes, e.g. 404, surely nothing to return. In general, I would like complete flexibility to omit a response.

tesujimath avatar Oct 30 '15 02:10 tesujimath

@tesujimath I've nothing against it. If you will send pull request, I will gladly accept it

yvasiyarov avatar Nov 01 '15 13:11 yvasiyarov

@yvasiyarov OK, I will get something together. I already found that #87 will block any effective testing of my changes, though. That one needs fixing urgently! (I already tried a trivial fix to the signature, but many parser tests continue to fail, and I'm not in a position to fix those.)

tesujimath avatar Nov 01 '15 20:11 tesujimath

Just to be clear, I won't be making a start on this until the parser tests are fixed. (It's not much fun working in a repo with broken tests.)

tesujimath avatar Nov 01 '15 20:11 tesujimath

OK, I've decided not to pursue this, sorry. I'm just going to use the native swagger tools directly, and not try to put the swagger markup in my Go source code.

tesujimath avatar Nov 18 '15 03:11 tesujimath