You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Having a field of type string with format byte marked as both nullable and required will result in the generator creating a model with a field of type JsonNullable<byte[]> (So far, so good). However, in the implementation of the equals method, the generated code will try to compare the values of this field using Arrays.equals, resulting in a compilation error.
openapi-generator version
7.4.0-SNAPSHOT
OpenAPI declaration file content or url
openapi: 3.0.3info:
title: Nullable string<byte> bugversion: 1.0.0paths: {}components:
schemas:
Foo:
type: objectproperties:
bar:
type: stringformat: bytenullable: truerequired:
- bar
Generation Details
spring generator.
Field string with format byte marked as nullable and required
Output
// ...privateJsonNullable<byte[]> bar = JsonNullable.<byte[]>undefined();
// ...@Overridepublicbooleanequals(Objecto) {
if (this == o) {
returntrue;
}
if (o == null || getClass() != o.getClass()) {
returnfalse;
}
Foofoo = (Foo) o;
returnArrays.equals(this.bar, foo.bar);
}
// ...
Steps to reproduce
Use above specification with filename api-docs.yml
Run the generator docker run --rm -v "$PWD:/local" openapitools/openapi-generator-cli:latest generate -i /local/api-docs.yml -g spring -o /local/output
Change to generated folder cd output
Attempt to compile project mvn compile
Related issues/PRs
Couldn't find any
Suggest a fix
When the field is not marked required, the generated code is correct.
// ...@Overridepublicbooleanequals(Objecto) {
if (this == o) {
returntrue;
}
if (o == null || getClass() != o.getClass()) {
returnfalse;
}
Foofoo = (Foo) o;
returnequalsNullable(this.bar, foo.bar);
}
privatestatic <T> booleanequalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
returna == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
}
// ...
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
Having a field of type
string
with formatbyte
marked as bothnullable
andrequired
will result in the generator creating a model with a field of typeJsonNullable<byte[]>
(So far, so good). However, in the implementation of theequals
method, the generated code will try to compare the values of this field usingArrays.equals
, resulting in a compilation error.openapi-generator version
7.4.0-SNAPSHOT
OpenAPI declaration file content or url
Generation Details
spring
generator.Field
string
with formatbyte
marked asnullable
andrequired
Output
Steps to reproduce
api-docs.yml
docker run --rm -v "$PWD:/local" openapitools/openapi-generator-cli:latest generate -i /local/api-docs.yml -g spring -o /local/output
cd output
mvn compile
Related issues/PRs
Couldn't find any
Suggest a fix
When the field is not marked
required
, the generated code is correct.The text was updated successfully, but these errors were encountered: