Skip to content

Generate ObjectMapΒ #1338

@kerner1000

Description

@kerner1000

Tell us the extension you're using

Server

I tried this:

Following the official OpenAPI docs1, I am trying to generate a Map 'fields' inside 'MyRequest', using this code:

MyRequest:
  type: object
  properties:
    fields:
      type: object
      additionalProperties:
        type: string

This happened:

Instead, I got

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
    "fields"
})
@Generated("jsonschema2pojo")
public class MyRequest {

    @JsonProperty("fields")
    private Fields fields;

    @JsonProperty("fields")
    public Fields getFields() {
        return fields;
    }

    @JsonProperty("fields")
    public void setFields(Fields fields) {
        this.fields = fields;
    }

}

and

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({

})
@Generated("jsonschema2pojo")
public class Fields {

    @JsonIgnore
    private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();

    @JsonAnyGetter
    public Map<String, Object> getAdditionalProperties() {
        return this.additionalProperties;
    }

    @JsonAnySetter
    public void setAdditionalProperty(String name, Object value) {
        this.additionalProperties.put(name, value);
    }

}

I expected this:

I am expecting this to translate to

MyRequest {
private Map<String, Object> fields = new HashMap<>();
}

Is there a workaround?

No response

How can we try to reproduce the issue?

No response

Anything else?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus OpenApi version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

Community Notes

  • Please vote by adding a πŸ‘ reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.name: Bug Report 🐞

Metadata

Metadata

Assignees

Labels

area:serverThis item is related to the server extensionbugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions