Bug Report Checklist
OpenAPI declaration file content or url
openapi: 3.0.0
components:
schemas:
Item:
type: object
properties:
foo:
type: string
Description
Assume we have a very minimal specification (see above) and use Java Spring Boot generator.
With useOptional:true everything is fine i.e.
public class Item {
private Optional<String> foo = Optional.empty();
public Item foo(String foo) {
this.foo = Optional.ofNullable(foo);
return this;
}
@JsonProperty("foo")
public Optional<String> getFoo() {
return foo;
}
public void setFoo(Optional<String> foo) {
this.foo = foo;
}
}
... but Optional wrappers are applied only if openApiNullable:true.
Luckily, it is a default behavior. Still, if I explicitly turn it off openApiNullable:false then useOptional:true doesn't have any effect
public class Item {
private String foo;
public Item foo(String foo) {
this.foo = foo;
return this;
}
@JsonProperty("foo")
public String getFoo() {
return foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
}
I guess it is a bug. The output should be the very same as above.
Or am I missing an idea behind it? Is it written somewhere in documentation that useOptional makes sense only together with openApiNullable?
@MelleD as you seem to be an expert of using Optional, what are your thoughts of it?
Should I provide a PR to fix?
openapi-generator version
7.10.0
Bug Report Checklist
OpenAPI declaration file content or url
Description
Assume we have a very minimal specification (see above) and use Java Spring Boot generator.
With
useOptional:trueeverything is fine i.e.... but
Optionalwrappers are applied only ifopenApiNullable:true.Luckily, it is a default behavior. Still, if I explicitly turn it off
openApiNullable:falsethenuseOptional:truedoesn't have any effectI guess it is a bug. The output should be the very same as above.
Or am I missing an idea behind it? Is it written somewhere in documentation that
useOptionalmakes sense only together withopenApiNullable?@MelleD as you seem to be an expert of using
Optional, what are your thoughts of it?Should I provide a PR to fix?
openapi-generator version
7.10.0