swagger-api / swagger-api/swagger-core

Jackson @JsonFormat doesn't support Enum type

Open
#4,506 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

Same Issue on: #3691

ModelResolve doesn't support @JsonFormat

@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum User {
    FOO(1, "Foo"),
    BAR(2, "Bar");

    User(int id, String name) {
        this.id = id;
        this.name = name;
    }

   @JsonProperty("id")
    public int id;

    @JsonProperty("name")
    public String name;
}
expect
"User" : {
    "properties" : {
        "id" : {
            "format" : "int32",
            "type" : "integer"
        },
        "name" : {
            "type" : "string"
        }
    },
    "type" : "object"
}
Serialize
"user" : {
    "enum" : [ "FOO", "BAR" ],
    "type" : "string"
}

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

Start at the ModelResolve path mentioned in the issue and reproduce the annotated enum example. Compare the generated model with the expected object schema and the serialized enum output. Done means @JsonFormat(shape = OBJECT) is reflected correctly for enum model resolution without regressing serialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Bug
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.