-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Annotations on Getters and Setters #125
Comments
Hello. Surely, it sounds do-able. To ease my comprehension / the development : could you provide a sample class representative of what you have on your project? |
Thanks for your quick response. I created a sample file that results in the said issue. I will paste it here down below. As I explained earlier, those files are auto-generated, namely with the help of This file also shows another issue I found: A List field always leads to @JsonPropertyOrder({
SampleModel.JSON_PROPERTY_NAME,
SampleModel.JSON_PROPERTY_DESCRIPTION,
SampleModel.JSON_PROPERTY_TODOS
})
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class SampleModel {
public static final String JSON_PROPERTY_NAME = "name";
private String name;
public static final String JSON_PROPERTY_DESCRIPTION = "description";
private String description;
public static final String JSON_PROPERTY_TODOS = "todos";
private List<String> todos;
public SampleModel() {
}
public SampleModel name(String name) {
this.name = name;
return this;
}
/**
* Get name
* @return name
**/
@jakarta.annotation.Nonnull
@NotNull
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getName() {
return name;
}
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public void setName(String name) {
this.name = name;
}
public SampleModel description(String description) {
this.description = description;
return this;
}
/**
* Get description
* @return description
**/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DESCRIPTION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getDescription() {
return description;
}
@JsonProperty(JSON_PROPERTY_DESCRIPTION)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setDescription(String description) {
this.description = description;
}
public SampleModel todos(List<String> todos) {
this.todos = todos;
return this;
}
public SampleModel addTodosItem(String todosItem) {
if (this.todos == null) {
this.todos = new ArrayList<>();
}
this.todos.add(todosItem);
return this;
}
/**
* Get todos
* @return todos
**/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_TODOS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<String> getTodos() {
return todos;
}
@JsonProperty(JSON_PROPERTY_TODOS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setTodos(List<String> todos) {
this.todos = todos;
} |
Thank you ! I'll be able to have a look on it next week. |
Hi, I started an attempt to work on this issue. Could you probably give me some early feedback on it or tell me if this is going into the right direction? Then I will ofc give some unit tests a shot. |
Hello. Thank you @gerhardj for your contribution. :) Kind regards, |
@gerhardj Thank you for the PR, I just read it. I need to think a bit about it, mainly the |
Reacting also to this part : do you still have the issue with v0.0.19? |
no, |
Hi, I added a unit test for my changes. Feedback is very welcome, we would be very happy, if this functionality was available in the openapi-maven-plugin, since we really need to migrate from swagger-maven-plugin. |
Hello @gerhardj. I merged your PR and released the v0.0.20 a couple of days ago. 😊 |
works perfectly!! many thanks @kbuntrock! 😊 |
Hi,
in our case, the models have Annotations - like
@NotNull
- only on the getters and setters, which are public.Since some of the code is auto-generated, we also cannot change that behaviour easily.
Is it possible to take such Annotations into account - specifically when determining the required fields of a model?
The text was updated successfully, but these errors were encountered: