Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ApiParam collectionFormat parameter not working #425

Closed
gkozyryatskyy opened this issue Feb 8, 2017 · 3 comments
Closed

@ApiParam collectionFormat parameter not working #425

gkozyryatskyy opened this issue Feb 8, 2017 · 3 comments

Comments

@gkozyryatskyy
Copy link

Seems like when you trying to generate swagger.json with swagger-maven-plugin from annotations, swagger-maven-plugin skip @ApiParam(collectionFormat = "csv") and set "collectionFormat" : "multi" by default.

Is there a way to make swagger-maven-plugin to read collectionFormat parameter from @ApiParam annotation?

collectionFormat added in swagger annotations version 1.5.11 swagger-api/swagger-core#1180

Also seem like it is something wrong here https://github.com/kongchen/swagger-maven-plugin/blob/master/src/main/java/com/github/kongchen/swagger/docgen/reader/AbstractReader.java#L441 csv is changed to multi. Do not sure it is really a problem, but maybe this link helps.

@kvasovan
Copy link

kvasovan commented Aug 3, 2017

I'm using version 1.5.11. I implicitly pointed "csv":

@ApiParam(value = SwaggerConstants.LOG_EVENT_TYPE_PARAM_DESCRIPTION, collectionFormat = "csv") @QueryParam("eventType") List<String> eventType,

But in swagger document I can see "multi", I'm wondering why is it happening?

@AlysG
Copy link

AlysG commented Feb 6, 2018

Same issue when I used @ApiImplicitParam (1.5.16 and 1.5.18). The generated swagger always used "multi"
@ApiImplicitParam(name = "code", value = "code list", required = false, dataType="integer", collectionFormat="csv", allowMultiple=true, paramType = "query")

@elder-cb
Copy link

I'm having the same issue with version 1.5.20.
@ApiImplicitParam(name="samples", value="sample query param", paramType="query" required=false, dataType="string", collectionFormat="csv", allowMultiple=true, allowedValues="one,two,three")
Stepping through the code, I realised that having dataType!="array" overrides the collectionFormat to null, and that later is set back to the default "multi"; unfortunately, if I set dataType to null or to array the items property doesn't get filled properly, as its type property would be set to "array".

Probably removing this line would allow us to use csv as collectionFormat in query params, but I haven't tried rebuilding the jar (yet):
AbstractSerializableParameter.java:257 setCollectionFormat(null);

    public void setType(String type) {
        this.type = type;
        if(ArrayProperty.isType(type)) {
            if(getCollectionFormat() == null){
                setCollectionFormat(getDefaultCollectionFormat());
            }
        } else {
            setCollectionFormat(null);
        }
    }

@gkozyryatskyy gkozyryatskyy closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants