mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-10-13 16:03:43 +00:00
[Java] [Spring-client] Exclude discriminator from nullable annotation (#21981)
* Exclude the discriminator from getting a nullable-annotation * Update samples
This commit is contained in:
parent
ac3c37095d
commit
73c8728343
@ -67,7 +67,12 @@ public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#v
|
||||
{{#gson}}
|
||||
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
|
||||
{{/gson}}
|
||||
{{^isDiscriminator}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{/isDiscriminator}}
|
||||
{{#isDiscriminator}}
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
{{/isDiscriminator}}
|
||||
{{#vendorExtensions.x-field-extra-annotation}}
|
||||
{{{vendorExtensions.x-field-extra-annotation}}}
|
||||
{{/vendorExtensions.x-field-extra-annotation}}
|
||||
|
@ -67,7 +67,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
|
||||
{{#gson}}
|
||||
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
|
||||
{{/gson}}
|
||||
{{^isDiscriminator}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{/isDiscriminator}}
|
||||
{{#isDiscriminator}}
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
{{/isDiscriminator}}
|
||||
{{#vendorExtensions.x-field-extra-annotation}}
|
||||
{{{vendorExtensions.x-field-extra-annotation}}}
|
||||
{{/vendorExtensions.x-field-extra-annotation}}
|
||||
|
@ -67,7 +67,12 @@ public {{>sealed}}class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#v
|
||||
{{#gson}}
|
||||
@SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}})
|
||||
{{/gson}}
|
||||
{{^isDiscriminator}}
|
||||
{{>nullable_var_annotations}}{{! prevent indent}}
|
||||
{{/isDiscriminator}}
|
||||
{{#isDiscriminator}}
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
{{/isDiscriminator}}
|
||||
{{#vendorExtensions.x-field-extra-annotation}}
|
||||
{{{vendorExtensions.x-field-extra-annotation}}}
|
||||
{{/vendorExtensions.x-field-extra-annotation}}
|
||||
|
@ -41,7 +41,7 @@ public final class Apple implements Fruit {
|
||||
private Integer seeds;
|
||||
|
||||
public static final String JSON_PROPERTY_FRUIT_TYPE = "fruitType";
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
private FruitType fruitType;
|
||||
|
||||
public Apple() {
|
||||
|
@ -41,7 +41,7 @@ public final class Banana implements Fruit {
|
||||
private Integer length;
|
||||
|
||||
public static final String JSON_PROPERTY_FRUIT_TYPE = "fruitType";
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
private FruitType fruitType;
|
||||
|
||||
public Banana() {
|
||||
|
@ -70,7 +70,7 @@ public class Entity {
|
||||
protected String atBaseType;
|
||||
|
||||
public static final String JSON_PROPERTY_AT_TYPE = "@type";
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String atType;
|
||||
|
||||
public Entity() {
|
||||
|
@ -76,7 +76,7 @@ public class EntityRef {
|
||||
protected String atBaseType;
|
||||
|
||||
public static final String JSON_PROPERTY_AT_TYPE = "@type";
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String atType;
|
||||
|
||||
public EntityRef() {
|
||||
|
@ -48,7 +48,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@jakarta.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -84,7 +84,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@jakarta.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -47,7 +47,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@jakarta.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -83,7 +83,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@jakarta.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -47,7 +47,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@jakarta.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -83,7 +83,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@jakarta.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -47,7 +47,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@jakarta.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -83,7 +83,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@jakarta.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -55,7 +55,7 @@ import io.github.threetenjaxb.core.*;
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@XmlElement(name = "className")
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -94,7 +94,7 @@ public class ParentWithNullable {
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@XmlElement(name = "type")
|
||||
@javax.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -47,7 +47,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -83,7 +83,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@javax.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -47,7 +47,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@jakarta.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -83,7 +83,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@jakarta.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -48,7 +48,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -84,7 +84,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@javax.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -47,7 +47,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -83,7 +83,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@javax.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
@ -47,7 +47,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
public class Animal {
|
||||
public static final String JSON_PROPERTY_CLASS_NAME = "className";
|
||||
@javax.annotation.Nonnull
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected String className;
|
||||
|
||||
public static final String JSON_PROPERTY_COLOR = "color";
|
||||
|
@ -83,7 +83,7 @@ public class ParentWithNullable {
|
||||
}
|
||||
|
||||
public static final String JSON_PROPERTY_TYPE = "type";
|
||||
@javax.annotation.Nullable
|
||||
// The discriminator does not have Nullability-annotation since it is added during serialization by the @JsonTypeName annotation
|
||||
protected TypeEnum type;
|
||||
|
||||
public static final String JSON_PROPERTY_NULLABLE_PROPERTY = "nullableProperty";
|
||||
|
Loading…
x
Reference in New Issue
Block a user