Swagger-codegen: [JAVA] Suggestion: Add option to generate arrays with "uniqueItems" true as Sets rather than Lists

Created on 17 Apr 2019  路  1Comment  路  Source: swagger-api/swagger-codegen

Description


Is there a way to generate fields declared as "array" in JSON, but with "uniqueItems": true as a Set rather than a List? JsonSchema2Pojo does this by default.

Swagger-codegen version


2.4.4

Suggest a fix/enhancement


Either change the default behavior to generate Sets automatically in this case or add an option e.g. uniqueItemsArraysAsSets that will cause the generator to create Sets in these places.

Most helpful comment

Hi Chessray,

I use openapi-codegen and swagger-codegen.

Your suggest is nice. Because Set type is usually used in java.

If the suggest adopted that saved my life. ><

Could I ask do you have the alternative option to fix this problem?

I also ask this question on stackoverflow:
https://stackoverflow.com/questions/56899939/how-to-define-listmapinteger-setstring-property-in-openapi-generator

>All comments

Hi Chessray,

I use openapi-codegen and swagger-codegen.

Your suggest is nice. Because Set type is usually used in java.

If the suggest adopted that saved my life. ><

Could I ask do you have the alternative option to fix this problem?

I also ask this question on stackoverflow:
https://stackoverflow.com/questions/56899939/how-to-define-listmapinteger-setstring-property-in-openapi-generator

Was this page helpful?
0 / 5 - 0 ratings