-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[Spring-java] required readonly attribute generate not null field #5026
Comments
Hi, I've encountered this same problem. The fix is simple, just change the beanValidation.mustache template slightly - I will attach a pull request in a minute. However, it seems to me that it is likely not only the Spring generator that suffers from this problem, but every Java generator that uses bean validation:
I didn't look at these files in detail, but it seems likely that all or at least many of these files should receive the same or a similiar fix. |
Pretty similar to #9654 |
Hi All,
regard required, readOnly and writeOnly open api specification report:
If a readOnly or writeOnly property is included in the required list, required affects just the relevant scope – responses only or requests only. That is, read-only required properties apply to responses only, and write-only required properties – to requests only.
so if i declare a field required and read-only means that in the request that field should be empty.
example with this yam:
openapigenerator generate the class with id not null
@JsonProperty("id")
private Long id;
@NotNull
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
What happen if i run my code and i perform a post with an empty id ? Spring raise bad request but it is not correct. For openapi specification read-only required properties apply to responses only and not for the request.
I think that openapi generator should generate @NotNull only for writeOnly property
The text was updated successfully, but these errors were encountered: