Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{{#required}}
{{^isReadOnly}}
{{^isDiscriminator}}
@NotNull
{{/isDiscriminator}}
{{#isDiscriminator}}
{{#disableDiscriminatorJsonIgnoreProperties}}
@NotNull
{{/disableDiscriminatorJsonIgnoreProperties}}
{{/isDiscriminator}}
Comment thread
LeosBitto marked this conversation as resolved.
Resolved
{{/isReadOnly}}
{{/required}}
{{^isContainer}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{{#required}}
{{^isReadOnly}}
{{^isDiscriminator}}
@NotNull
{{/isDiscriminator}}
{{#isDiscriminator}}
{{#disableDiscriminatorJsonIgnoreProperties}}
@NotNull
{{/disableDiscriminatorJsonIgnoreProperties}}
{{/isDiscriminator}}
{{/isReadOnly}}
{{/required}}
{{>beanValidationCore}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#required}}{{^isReadOnly}}@NotNull {{/isReadOnly}}{{/required}}{{^isContainer}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime}}{{^isString}}{{^isFile}}{{^isEnumOrRef}}@Valid {{/isEnumOrRef}}{{/isFile}}{{/isString}}{{/isDateTime}}{{/isDate}}{{/isPrimitiveType}}{{/isContainer}}{{>beanValidationCore}}
{{#required}}{{^isReadOnly}}{{^isDiscriminator}}@NotNull {{/isDiscriminator}}{{#isDiscriminator}}{{#disableDiscriminatorJsonIgnoreProperties}}@NotNull {{/disableDiscriminatorJsonIgnoreProperties}}{{/isDiscriminator}}{{/isReadOnly}}{{/required}}{{^isContainer}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime}}{{^isString}}{{^isFile}}{{^isEnumOrRef}}@Valid {{/isEnumOrRef}}{{/isFile}}{{/isString}}{{/isDateTime}}{{/isDate}}{{/isPrimitiveType}}{{/isContainer}}{{>beanValidationCore}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#required}}{{^isReadOnly}}{{#isNullable}}{{#openApiNullableUsePresent}}{{#useBeanValidation}}@Present(payload = Unwrapping.Skip.class){{/useBeanValidation}}{{/openApiNullableUsePresent}}{{/isNullable}}{{^isNullable}}@NotNull {{/isNullable}}{{/isReadOnly}}{{/required}}
{{#required}}{{^isReadOnly}}{{#isNullable}}{{#openApiNullableUsePresent}}{{#useBeanValidation}}@Present(payload = Unwrapping.Skip.class){{/useBeanValidation}}{{/openApiNullableUsePresent}}{{/isNullable}}{{^isNullable}}{{^isDiscriminator}}@NotNull {{/isDiscriminator}}{{#isDiscriminator}}{{#disableDiscriminatorJsonIgnoreProperties}}@NotNull {{/disableDiscriminatorJsonIgnoreProperties}}{{/isDiscriminator}}{{/isNullable}}{{/isReadOnly}}{{/required}}
Original file line number Diff line number Diff line change
Expand Up @@ -5654,17 +5654,21 @@ public void testOneOfInterfaceWithAnnotation() {
@Test
public void disableDiscriminatorJsonIgnorePropertiesIsTrueThenJsonIgnorePropertiesShouldBeNotAdded() {
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/issue12777.yaml", RESTCLIENT,
Map.of(DISABLE_DISCRIMINATOR_JSON_IGNORE_PROPERTIES, "true"));
Map.of(DISABLE_DISCRIMINATOR_JSON_IGNORE_PROPERTIES, "true", BeanValidationFeatures.USE_BEANVALIDATION, "true"));
JavaFileAssert.assertThat(files.get("BaseConfiguration.java"))
.assertTypeAnnotations().doesNotContainWithName("JsonIgnoreProperties");
JavaFileAssert.assertThat(files.get("BaseConfiguration.java"))
.assertMethod("getType").hasAnnotation("NotNull");
}

@Test
public void disableDiscriminatorJsonIgnorePropertiesIsTrueThenJsonIgnorePropertiesShouldBeAdded() {
public void disableDiscriminatorJsonIgnorePropertiesIsFalseThenJsonIgnorePropertiesShouldBeAdded() {
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/issue12777.yaml", RESTCLIENT,
Map.of(DISABLE_DISCRIMINATOR_JSON_IGNORE_PROPERTIES, "false"));
Map.of(DISABLE_DISCRIMINATOR_JSON_IGNORE_PROPERTIES, "false", BeanValidationFeatures.USE_BEANVALIDATION, "true"));
JavaFileAssert.assertThat(files.get("BaseConfiguration.java"))
.assertTypeAnnotations().containsWithName("JsonIgnoreProperties");
JavaFileAssert.assertThat(files.get("BaseConfiguration.java"))
.assertMethod("getType").doesNotHaveAnnotation("NotNull");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1419,6 +1419,7 @@ public void disableDiscriminatorJsonIgnorePropertiesIsFalseThenJsonIgnorePropert
Map<String, Object> properties = new HashMap<>();
properties.put("legacyDiscriminatorBehavior", "false");
properties.put(DISABLE_DISCRIMINATOR_JSON_IGNORE_PROPERTIES, "false");
properties.put("useBeanValidation", true);

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("jaxrs-spec")
Expand All @@ -1436,7 +1437,8 @@ public void disableDiscriminatorJsonIgnorePropertiesIsFalseThenJsonIgnorePropert
"value = \"petType\"",
"allowSetters = true",
"include = JsonTypeInfo.As.PROPERTY")
.fileDoesNotContain("include = JsonTypeInfo.As.EXISTING_PROPERTY");
.fileDoesNotContain("include = JsonTypeInfo.As.EXISTING_PROPERTY")
.assertMethod("getPetType").doesNotHaveAnnotation("NotNull");
}

/**
Expand All @@ -1454,6 +1456,7 @@ public void disableDiscriminatorJsonIgnorePropertiesIsTrueThenJsonIgnoreProperti
Map<String, Object> properties = new HashMap<>();
properties.put("legacyDiscriminatorBehavior", "false");
properties.put(DISABLE_DISCRIMINATOR_JSON_IGNORE_PROPERTIES, "true");
properties.put("useBeanValidation", true);

final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName("jaxrs-spec")
Expand All @@ -1468,7 +1471,8 @@ public void disableDiscriminatorJsonIgnorePropertiesIsTrueThenJsonIgnoreProperti
JavaFileAssert.assertThat(files.get("PetResponse.java"))
.fileDoesNotContain("@JsonIgnoreProperties(")
.fileContains("include = JsonTypeInfo.As.EXISTING_PROPERTY")
.fileDoesNotContain("include = JsonTypeInfo.As.PROPERTY");
.fileDoesNotContain("include = JsonTypeInfo.As.PROPERTY")
.assertMethod("getPetType").hasAnnotation("NotNull");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9725,14 +9725,18 @@ void disableDiscriminatorJsonIgnorePropertiesIsTrueThenJsonIgnorePropertiesShoul
Map.of(DISABLE_DISCRIMINATOR_JSON_IGNORE_PROPERTIES, "true"));
JavaFileAssert.assertThat(files.get("BaseConfiguration.java"))
.assertTypeAnnotations().doesNotContainWithName("JsonIgnoreProperties");
JavaFileAssert.assertThat(files.get("BaseConfiguration.java"))
.assertMethod("getType").hasAnnotation("NotNull");
}

@Test
void disableDiscriminatorJsonIgnorePropertiesIsTrueThenJsonIgnorePropertiesShouldBeAdded() throws IOException {
void disableDiscriminatorJsonIgnorePropertiesIsFalseThenJsonIgnorePropertiesShouldBeAdded() throws IOException {
final Map<String, File> files = generateFromContract("src/test/resources/3_0/java/issue12777.yaml", SPRING_BOOT,
Map.of(DISABLE_DISCRIMINATOR_JSON_IGNORE_PROPERTIES, "false"));
JavaFileAssert.assertThat(files.get("BaseConfiguration.java"))
.assertTypeAnnotations().containsWithName("JsonIgnoreProperties");
JavaFileAssert.assertThat(files.get("BaseConfiguration.java"))
.assertMethod("getType").doesNotHaveAnnotation("NotNull");
}

// useEnumValueInterface tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public Animal className(@jakarta.annotation.Nonnull String className) {
* @return className
*/
@jakarta.annotation.Nonnull
@NotNull

@JsonProperty(value = JSON_PROPERTY_CLASS_NAME, required = true)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public GrandparentAnimal petType(@jakarta.annotation.Nonnull String petType) {
* @return petType
*/
@jakarta.annotation.Nonnull
@NotNull

@JsonProperty(value = JSON_PROPERTY_PET_TYPE, required = true)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public Animal className(@javax.annotation.Nonnull String className) {
* @return className
*/
@javax.annotation.Nonnull
@NotNull

@JsonProperty(value = JSON_PROPERTY_CLASS_NAME, required = true)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public Animal className(@javax.annotation.Nonnull String className) {
* @return className
*/
@javax.annotation.Nonnull
@NotNull


public String getClassName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public Animal className(@jakarta.annotation.Nonnull String className) {
* @return className
*/
@jakarta.annotation.Nonnull
@NotNull

@JsonProperty(value = JSON_PROPERTY_CLASS_NAME, required = true)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public AnimalDto className(String className) {
* Get className
* @return className
*/
@NotNull

@JsonProperty("className")
public String getClassName() {
return className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Animal className(String className) {
* Get className
* @return className
*/
@NotNull

@JsonProperty("className")
public String getClassName() {
return className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public AnimalDto className(String className) {
* Get className
* @return className
*/
@NotNull

@JsonProperty("className")
public String getClassName() {
return className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Animal className(String className) {
* Get className
* @return className
*/
@NotNull

@JsonProperty("className")
public String getClassName() {
return className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Animal className(String className) {
* Get className
* @return className
*/
@NotNull

@Schema(name = "className", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("className")
public String getClassName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Base kind(String kind) {
* Get kind
* @return kind
*/
@NotNull

@Schema(name = "kind", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("kind")
public String getKind() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Apple fruitType(FruitType fruitType) {
* Get fruitType
* @return fruitType
*/
@NotNull @Valid
@Valid
@Schema(name = "fruitType", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("fruitType")
public FruitType getFruitType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Banana fruitType(FruitType fruitType) {
* Get fruitType
* @return fruitType
*/
@NotNull @Valid
@Valid
@Schema(name = "fruitType", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("fruitType")
public FruitType getFruitType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Entity atType(String atType) {
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull

@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public EntityRef atType(String atType) {
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull

@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Apple fruitType(FruitType fruitType) {
* Get fruitType
* @return fruitType
*/
@NotNull @Valid
@Valid
@Schema(name = "fruitType", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("fruitType")
public FruitType getFruitType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Banana fruitType(FruitType fruitType) {
* Get fruitType
* @return fruitType
*/
@NotNull @Valid
@Valid
@Schema(name = "fruitType", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("fruitType")
public FruitType getFruitType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Entity atType(String atType) {
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull

@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public EntityRef atType(String atType) {
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull

@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Apple fruitType(FruitType fruitType) {
* Get fruitType
* @return fruitType
*/
@NotNull @Valid
@Valid
@Schema(name = "fruitType", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("fruitType")
public FruitType getFruitType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Banana fruitType(FruitType fruitType) {
* Get fruitType
* @return fruitType
*/
@NotNull @Valid
@Valid
@Schema(name = "fruitType", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("fruitType")
public FruitType getFruitType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Entity atType(String atType) {
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull

@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public EntityRef atType(String atType) {
* When sub-classing, this defines the sub-class Extensible name
* @return atType
*/
@NotNull

@Schema(name = "@type", description = "When sub-classing, this defines the sub-class Extensible name", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("@type")
public String getAtType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public Vehicle type(String type) {
* Get type
* @return type
*/
@NotNull

@Schema(name = "type", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("type")
public String getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Animal className(String className) {
* Get className
* @return className
*/
@NotNull

@Schema(name = "className", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("className")
public String getClassName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Animal className(String className) {
* Get className
* @return className
*/
@NotNull

@Schema(name = "className", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("className")
public String getClassName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Animal className(String className) {

@ApiModelProperty(required = true, value = "")
@JsonProperty(required = true, value = "className")
@NotNull public String getClassName() {
public String getClassName() {
return className;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Animal className(String className) {

@ApiModelProperty(required = true, value = "")
@JsonProperty(required = true, value = "className")
@NotNull public String getClassName() {
public String getClassName() {
return className;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Animal className(String className) {

@ApiModelProperty(required = true, value = "")
@JsonbProperty("className")
@NotNull public String getClassName() {
public String getClassName() {
return className;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Animal className(String className) {

@org.eclipse.microprofile.openapi.annotations.media.Schema(required = true, description = "")
@JsonProperty(required = true, value = "className")
@NotNull public String getClassName() {
public String getClassName() {
return className;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Animal className(String className) {

@ApiModelProperty(required = true, value = "")
@JsonProperty(required = true, value = "className")
@NotNull public String getClassName() {
public String getClassName() {
return className;
}

Expand Down
Loading
Loading