swagger-api / swagger-api/swagger-codegen

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

Open
#9,380 2 comments 17 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No file, test, or entry point is named in the issue; begin by locating the Java generator logic and templates that map uniqueItems arrays to collection types. Done means uniqueItems true arrays can be generated as Sets, either by the default behavior or a clearly defined option, with coverage for the selected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.