Swagger-core: can ApiImplicitParam's dataType be an Enum?

Created on 30 Sep 2015  路  2Comments  路  Source: swagger-api/swagger-core

I have the following setup with v1.5.3 and jaxrs 2:

@ApiModel (description = "The environment")
public enum Environment {
    QA("qa"),
    PRODUCTION("prod");

   private final String name;
   private Environment(String period) {
        this.name = period;
    }

   @JsonValue
    public String toString() {
        return name;
    }
}

I define an implicit param who's value should be defined in the enum above like so:

@ApiImplicitParam (dataType = "string", name = "env", value = "Narrow query by specifying an existing Environment", paramType = "query", required = false, allowableValues = "qa, prod")

I would like a more automated way of defining this param. More specifically, I would like to define the dataType of the param to be Environment and have the allowableValues be deduced from that. E.g:

@ApiImplicitParam (dataType = "Environment", name = "env", value = "Narrow query by specifying an existing Environment", paramType = "query", required = false)

Is there any functionality that can produce this behavior?

All 2 comments

The logic of @ApiImplicitParam is very simple and it's pretty much as if you were writing that part of the definition yourself, so no, there's no functionality to produce that behavior.

I believe the answer is no.

Was this page helpful?
0 / 5 - 0 ratings