Skip to content

Change getAdditionalProperties by getName and getValue.  #380

Closed
@fjtirado

Description

@fjtirado

What would you like to be added:
Currently, this yaml

 taskList:
    type: array
    items:
      type: object
      title: TaskItem
      minProperties: 1
      maxProperties: 1
      additionalProperties:
        $ref: '#/$defs/task'


is translated to

@Generated("jsonschema2pojo")
public class TaskItem implements Serializable
{

    @JsonIgnore
    @Valid
    private Map<String, Task> additionalProperties = new LinkedHashMap<String, Task>();
    private final static long serialVersionUID = 2309610577983775837L;

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

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

    public TaskItem withAdditionalProperty(String name, Task value) {
        this.additionalProperties.put(name, value);
        return this;
    }

}

which ideally should be


@Generated("jsonschema2pojo")
public class TaskItem implements Serializable
{

    @JsonIgnore
    @Valid
    private Map<String, Task> additionalProperties = new LinkedHashMap<String, Task>();
    private final static long serialVersionUID = 2309610577983775837L;

    private String name;
    private Task task;
	public Task getTask() {
		return task;
	}
	public void setTask(Task task) {
		this.task = task;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
    
}

Why is this needed:

To make API more usable

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions