teamcarma / swagger-jaxrs-doclet

This fork is no longer actively maintained, please switch to https://github.com/conorroche/swagger-doclet
Apache License 2.0
81 stars 38 forks source link

merge java-methods only differing by mimetypes into one swagger-operation #101

Open MarkusKull opened 9 years ago

MarkusKull commented 9 years ago

Since some time ago, swagger-ui no longer displays methods having multiple differing return types. Only different produces-mimetypes with same return-type are supported. See https://github.com/swagger-api/swagger-spec/issues/146 or https://github.com/swagger-api/swagger-core/issues/521 .

Doclet can still support multiple java-methods (one java-method per mimetype) by combining them into one Swagger-Operation, which this PR does. Unfortunately some doclet-unittests declare multiple methods with same parameters and mimetypes (invalid according to JAX-RS). As quick workaround any methods without mimetypes are omitted by the merge.

BTW, it would be nice to get rid of the (unused?) hashcode and equals-methods in the models. Hashing doesnt work well for changeable objects. I would also prefer immutable objects and empty collections instead of null collections.

conorroche commented 9 years ago

thanks markus looks good, there are some people still using java 7 so im thinking about doing a version of this fix that doesnt use lamdas etc, the equals is used in the unit tests for checking expected vs actual, agree re immutable models though there is some hackiness where some fields needed to be updated post creation but il look to address that properly at some stage, i would rather fix the unit tests that have the multiple methods with same path and mimetypes than have the workaround.

MarkusKull commented 9 years ago

I'll probably have time in some days to look into the unittests and get rid of the workaround.

BTW, due to settings of maven-compiler in parentpom (source=target=1.8) the generated classfiles can no longer be run under java7. If you still want java7, this should be changed.

MarkusKull commented 9 years ago

Did now fix the invalid UnitTest-Resources by assigning distinct paths. Removed the workaround.

mageddo commented 8 years ago

Ohh no, now the content-type is only one, if you have application/json and application/+1.json only one will be show

MarkusKull commented 8 years ago

@mageddo Could you explain some more, e.g. with a complete example?

application/json and application/+1.json sounds like different versions or structurally different models. Such different structures are neither supported by swagger-spec or newest swagger-ui.