diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index 604bce325eb..a95e21cb0cf 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
@@ -3506,7 +3506,10 @@ public class DefaultCodegen implements CodegenConfig {
if (Boolean.FALSE.equals(p.getNullable())) {
LOGGER.warn("Schema '{}' is any type, which includes the 'null' value. 'nullable' cannot be set to 'false'", p.getName());
}
- property.isNullable = true;
+ ComposedSchema composedSchema = p instanceof ComposedSchema
+ ? (ComposedSchema) p
+ : null;
+ property.isNullable = property.isNullable || composedSchema == null || composedSchema.getAllOf() == null || composedSchema.getAllOf().size() == 0;
if (languageSpecificPrimitives.contains(property.dataType)) {
property.isPrimitiveType = true;
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/AllOfWithSingleRef.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/AllOfWithSingleRef.cs
index dcd135e949d..1cce653b433 100644
--- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/AllOfWithSingleRef.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/AllOfWithSingleRef.cs
@@ -33,7 +33,7 @@ namespace Org.OpenAPITools.Model
///
/// Gets or Sets SingleRefType
///
- [DataMember(Name="SingleRefType", EmitDefaultValue=true)]
+ [DataMember(Name="SingleRefType", EmitDefaultValue=false)]
public SingleRefType? SingleRefType { get; set; }
///
/// Initializes a new instance of the class.
@@ -42,7 +42,6 @@ namespace Org.OpenAPITools.Model
/// singleRefType.
public AllOfWithSingleRef(string username = default(string), SingleRefType? singleRefType = default(SingleRefType?))
{
- this.SingleRefType = singleRefType;
this.Username = username;
this.SingleRefType = singleRefType;
}
diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java
index da5ebd59abd..485e4517736 100644
--- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java
+++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java
@@ -23,10 +23,6 @@ import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.openapitools.client.model.SingleRefType;
-import org.openapitools.jackson.nullable.JsonNullable;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import org.openapitools.jackson.nullable.JsonNullable;
-import java.util.NoSuchElementException;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
@@ -43,7 +39,7 @@ public class AllOfWithSingleRef {
private String username;
public static final String JSON_PROPERTY_SINGLE_REF_TYPE = "SingleRefType";
- private JsonNullable singleRefType = JsonNullable.undefined();
+ private SingleRefType singleRefType;
public AllOfWithSingleRef() {
}
@@ -76,8 +72,8 @@ public class AllOfWithSingleRef {
public AllOfWithSingleRef singleRefType(SingleRefType singleRefType) {
- this.singleRefType = JsonNullable.of(singleRefType);
+ this.singleRefType = singleRefType;
return this;
}
@@ -87,26 +83,18 @@ public class AllOfWithSingleRef {
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
- @JsonIgnore
-
- public SingleRefType getSingleRefType() {
- return singleRefType.orElse(null);
- }
-
@JsonProperty(JSON_PROPERTY_SINGLE_REF_TYPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
- public JsonNullable getSingleRefType_JsonNullable() {
+ public SingleRefType getSingleRefType() {
return singleRefType;
}
-
- @JsonProperty(JSON_PROPERTY_SINGLE_REF_TYPE)
- public void setSingleRefType_JsonNullable(JsonNullable singleRefType) {
- this.singleRefType = singleRefType;
- }
+
+ @JsonProperty(JSON_PROPERTY_SINGLE_REF_TYPE)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSingleRefType(SingleRefType singleRefType) {
- this.singleRefType = JsonNullable.of(singleRefType);
+ this.singleRefType = singleRefType;
}
@@ -120,23 +108,12 @@ public class AllOfWithSingleRef {
}
AllOfWithSingleRef allOfWithSingleRef = (AllOfWithSingleRef) o;
return Objects.equals(this.username, allOfWithSingleRef.username) &&
- equalsNullable(this.singleRefType, allOfWithSingleRef.singleRefType);
- }
-
- private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
- return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
+ Objects.equals(this.singleRefType, allOfWithSingleRef.singleRefType);
}
@Override
public int hashCode() {
- return Objects.hash(username, hashCodeNullable(singleRefType));
- }
-
- private static int hashCodeNullable(JsonNullable a) {
- if (a == null) {
- return 1;
- }
- return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
+ return Objects.hash(username, singleRefType);
}
@Override
diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java
index da5ebd59abd..485e4517736 100644
--- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java
+++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java
@@ -23,10 +23,6 @@ import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.openapitools.client.model.SingleRefType;
-import org.openapitools.jackson.nullable.JsonNullable;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import org.openapitools.jackson.nullable.JsonNullable;
-import java.util.NoSuchElementException;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
@@ -43,7 +39,7 @@ public class AllOfWithSingleRef {
private String username;
public static final String JSON_PROPERTY_SINGLE_REF_TYPE = "SingleRefType";
- private JsonNullable singleRefType = JsonNullable.undefined();
+ private SingleRefType singleRefType;
public AllOfWithSingleRef() {
}
@@ -76,8 +72,8 @@ public class AllOfWithSingleRef {
public AllOfWithSingleRef singleRefType(SingleRefType singleRefType) {
- this.singleRefType = JsonNullable.of(singleRefType);
+ this.singleRefType = singleRefType;
return this;
}
@@ -87,26 +83,18 @@ public class AllOfWithSingleRef {
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
- @JsonIgnore
-
- public SingleRefType getSingleRefType() {
- return singleRefType.orElse(null);
- }
-
@JsonProperty(JSON_PROPERTY_SINGLE_REF_TYPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
- public JsonNullable getSingleRefType_JsonNullable() {
+ public SingleRefType getSingleRefType() {
return singleRefType;
}
-
- @JsonProperty(JSON_PROPERTY_SINGLE_REF_TYPE)
- public void setSingleRefType_JsonNullable(JsonNullable singleRefType) {
- this.singleRefType = singleRefType;
- }
+
+ @JsonProperty(JSON_PROPERTY_SINGLE_REF_TYPE)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public void setSingleRefType(SingleRefType singleRefType) {
- this.singleRefType = JsonNullable.of(singleRefType);
+ this.singleRefType = singleRefType;
}
@@ -120,23 +108,12 @@ public class AllOfWithSingleRef {
}
AllOfWithSingleRef allOfWithSingleRef = (AllOfWithSingleRef) o;
return Objects.equals(this.username, allOfWithSingleRef.username) &&
- equalsNullable(this.singleRefType, allOfWithSingleRef.singleRefType);
- }
-
- private static boolean equalsNullable(JsonNullable a, JsonNullable b) {
- return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
+ Objects.equals(this.singleRefType, allOfWithSingleRef.singleRefType);
}
@Override
public int hashCode() {
- return Objects.hash(username, hashCodeNullable(singleRefType));
- }
-
- private static int hashCodeNullable(JsonNullable a) {
- if (a == null) {
- return 1;
- }
- return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
+ return Objects.hash(username, singleRefType);
}
@Override
diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AllOfWithSingleRef.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AllOfWithSingleRef.php
index 3c6fa68e2bf..3c7e762495f 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AllOfWithSingleRef.php
+++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Model/AllOfWithSingleRef.php
@@ -80,7 +80,7 @@ class AllOfWithSingleRef implements ModelInterface, ArrayAccess, \JsonSerializab
*/
protected static array $openAPINullables = [
'username' => false,
- 'single_ref_type' => true
+ 'single_ref_type' => false
];
/**
@@ -336,14 +336,7 @@ class AllOfWithSingleRef implements ModelInterface, ArrayAccess, \JsonSerializab
{
if (is_null($single_ref_type)) {
- array_push($this->openAPINullablesSetToNull, 'single_ref_type');
- } else {
- $nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
- $index = array_search('single_ref_type', $nullablesSetToNull);
- if ($index !== FALSE) {
- unset($nullablesSetToNull[$index]);
- $this->setOpenAPINullablesSetToNull($nullablesSetToNull);
- }
+ throw new \InvalidArgumentException('non-nullable single_ref_type cannot be null');
}
$this->container['single_ref_type'] = $single_ref_type;
diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb
index 4efc82eac4a..89884ca12b0 100644
--- a/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb
+++ b/samples/client/petstore/ruby-faraday/lib/petstore/models/all_of_with_single_ref.rb
@@ -43,7 +43,6 @@ module Petstore
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
- :'single_ref_type'
])
end
diff --git a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb
index 4efc82eac4a..89884ca12b0 100644
--- a/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb
+++ b/samples/client/petstore/ruby/lib/petstore/models/all_of_with_single_ref.rb
@@ -43,7 +43,6 @@ module Petstore
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
- :'single_ref_type'
])
end
diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts
index 61f2a287c80..13958e2ab77 100644
--- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts
+++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/AllOfWithSingleRef.ts
@@ -37,7 +37,7 @@ export interface AllOfWithSingleRef {
* @type {SingleRefType}
* @memberof AllOfWithSingleRef
*/
- singleRefType?: SingleRefType | null;
+ singleRefType?: SingleRefType;
}
/**
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart
index 460aec9a9c8..7ee9944f7f0 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart
@@ -55,7 +55,7 @@ class AllOfWithSingleRef {
@override
int get hashCode =>
username.hashCode +
- (singleRefType == null ? 0 : singleRefType.hashCode);
+ singleRefType.hashCode;
factory AllOfWithSingleRef.fromJson(Map json) => _$AllOfWithSingleRefFromJson(json);
diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/all_of_with_single_ref.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/all_of_with_single_ref.dart
index 3319d53814d..a6955be4a92 100644
--- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/all_of_with_single_ref.dart
+++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/all_of_with_single_ref.dart
@@ -52,7 +52,7 @@ class _$AllOfWithSingleRefSerializer implements StructuredSerializer