Skip to content

Commit cef1bec

Browse files
authored
fix null payload in java jersey2 (#6933)
1 parent 38368c9 commit cef1bec

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

  • modules/openapi-generator/src/main/resources/Java/libraries/jersey2
  • samples
    • client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client
    • openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client

modules/openapi-generator/src/main/resources/Java/libraries/jersey2/ApiClient.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,9 +874,9 @@ public class ApiClient {
874874
} else {
875875
// We let jersey handle the serialization
876876
if (isBodyNullable) { // payload is nullable
877-
entity = Entity.entity(obj == null ? Entity.text("null") : obj, contentType);
877+
entity = Entity.entity(obj == null ? "null" : obj, contentType);
878878
} else {
879-
entity = Entity.entity(obj == null ? Entity.text("") : obj, contentType);
879+
entity = Entity.entity(obj == null ? "" : obj, contentType);
880880
}
881881
}
882882
return entity;

samples/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,9 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
791791
} else {
792792
// We let jersey handle the serialization
793793
if (isBodyNullable) { // payload is nullable
794-
entity = Entity.entity(obj == null ? Entity.text("null") : obj, contentType);
794+
entity = Entity.entity(obj == null ? "null" : obj, contentType);
795795
} else {
796-
entity = Entity.entity(obj == null ? Entity.text("") : obj, contentType);
796+
entity = Entity.entity(obj == null ? "" : obj, contentType);
797797
}
798798
}
799799
return entity;

samples/openapi3/client/petstore/java/jersey2-java8/src/main/java/org/openapitools/client/ApiClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,9 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
870870
} else {
871871
// We let jersey handle the serialization
872872
if (isBodyNullable) { // payload is nullable
873-
entity = Entity.entity(obj == null ? Entity.text("null") : obj, contentType);
873+
entity = Entity.entity(obj == null ? "null" : obj, contentType);
874874
} else {
875-
entity = Entity.entity(obj == null ? Entity.text("") : obj, contentType);
875+
entity = Entity.entity(obj == null ? "" : obj, contentType);
876876
}
877877
}
878878
return entity;

0 commit comments

Comments
 (0)