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

Something equivalent to @ApiParam(allowableValues="one,two") #89

Closed xverges closed 9 years ago

xverges commented 9 years ago

http://docs.swagger.io/swagger-core/v1.3.12/apidocs/com/wordnik/swagger/annotations/ApiParam.html#allowableValues%28%29 results in a parameter defined with the enum attribute

{
    "name": "paramName",
    "required": false,
    "type": "string",
    "paramType": "path",
    "allowMultiple": false,
    "enum": [
        "one",
        "two"
    ]
}

that results in a nice swagger-ui dropdown.

Can something like this be built using javadoc tags?

conorroche commented 9 years ago

Currently only java enums are translated to allowable values, I will add support for javadoc tags that can do the same

xverges commented 9 years ago

Great news! Thanks!

conorroche commented 9 years ago

I have now added support for this using the tag @paramsAllowableValues

here is an example:

/* * @paramsAllowableValues p1 A p2 B p1 C * @paramsDefaultValue p1 C / @PUT @Path("/4") public void putEnum(@QueryParam("p1") String p1, @QueryParam("p2") String p2) { // noop }

conorroche commented 9 years ago

closing as fixed for 1.0.5 release