Skip to content

Commit

Permalink
Fix JsonNullable issue for Helidon generators (#15423)
Browse files Browse the repository at this point in the history
* fix JsonNullable issue

Signed-off-by: aserkes <[email protected]>

* update samples

Signed-off-by: aserkes <[email protected]>

* update samples, refactoring

Signed-off-by: aserkes <[email protected]>

* update samples, refactoring

Signed-off-by: aserkes <[email protected]>

* update samples

Signed-off-by: aserkes <[email protected]>

---------

Signed-off-by: aserkes <[email protected]>
  • Loading branch information
aserkes committed May 16, 2023
1 parent 6d56a19 commit fbf42de
Show file tree
Hide file tree
Showing 162 changed files with 13,567 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Function;

import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
Expand Down Expand Up @@ -235,7 +234,8 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder.toString(), "RFC3339DateFormat.java"));
break;
case SERIALIZATION_LIBRARY_JSONB:
openApiNullable = false; // for Jackson only
openApiNullable = false;
additionalProperties.put(OPENAPI_NULLABLE, false);
additionalProperties.put(SERIALIZATION_LIBRARY_JSONB, "true");
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
break;
Expand Down Expand Up @@ -445,7 +445,6 @@ public ModelsMap postProcessModels(ModelsMap objs) {

if (addImports) {
Map<String, String> imports2Classnames = new HashMap<>();
imports2Classnames.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable");
imports2Classnames.put("NoSuchElementException", "java.util.NoSuchElementException");
imports2Classnames.put("JsonIgnore", "com.fasterxml.jackson.annotation.JsonIgnore");
for (Map.Entry<String, String> entry : imports2Classnames.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ public void processOpts() {
}
break;
case SERIALIZATION_LIBRARY_JSONB:
openApiNullable = false;
additionalProperties.put(OPENAPI_NULLABLE, false);
additionalProperties.put(SERIALIZATION_LIBRARY_JSONB, "true");
additionalProperties.remove(SERIALIZATION_LIBRARY_JACKSON);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<description>{{artifactDescription}}</description>
<packaging>jar</packaging>

<properties>
{{#openApiNullable}}
<version.jackson.databind.nullable>0.2.6</version.jackson.databind.nullable>
{{/openApiNullable}}
</properties>

<dependencies>
<dependency>
<groupId>io.helidon.microprofile.rest-client</groupId>
Expand All @@ -37,16 +43,18 @@
<groupId>{{x-helidon-rootJavaEEDepPrefix}}.json</groupId>
<artifactId>{{x-helidon-rootJavaEEDepPrefix}}.json-api</artifactId>
</dependency>
{{#openApiNullable}}
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${version.jackson.databind.nullable}</version>
</dependency>
{{/openApiNullable}}
{{#jackson}}
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>
{{/jackson}}
{{#jsonb}}
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<version>{{artifactVersion}}</version>
<packaging>jar</packaging>

<properties>
{{#openApiNullable}}
<version.jackson.databind.nullable>0.2.6</version.jackson.databind.nullable>
{{/openApiNullable}}
</properties>

<dependencies>
<dependency>
<groupId>io.helidon.webclient</groupId>
Expand All @@ -30,6 +36,13 @@
<groupId>{{x-helidon-rootJavaEEDepPrefix}}.json</groupId>
<artifactId>{{x-helidon-rootJavaEEDepPrefix}}.json-api</artifactId>
</dependency>
{{#openApiNullable}}
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${version.jackson.databind.nullable}</version>
</dependency>
{{/openApiNullable}}
{{#jackson}}
<dependency>
<groupId>io.helidon.media</groupId>
Expand All @@ -39,11 +52,6 @@
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>
{{/jackson}}
{{#jsonb}}
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<version>{{artifactVersion}}</version>
<packaging>jar</packaging>

{{#openApiNullable}}
<properties>
<version.jackson.databind.nullable>0.2.3</version.jackson.databind.nullable>
</properties>
{{#openApiNullable}}
<version.jackson.databind.nullable>0.2.6</version.jackson.databind.nullable>
{{/openApiNullable}}
</properties>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

<properties>
<mainClass>{{{invokerPackage}}}.Main</mainClass>
<version.jackson.databind.nullable>0.2.3</version.jackson.databind.nullable>
{{#openApiNullable}}
<version.jackson.databind.nullable>0.2.6</version.jackson.databind.nullable>
{{/openApiNullable}}
</properties>

<dependencies>
Expand Down
14 changes: 9 additions & 5 deletions samples/client/petstore/java-helidon-client/mp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<description>OpenAPI Java</description>
<packaging>jar</packaging>

<properties>
<version.jackson.databind.nullable>0.2.6</version.jackson.databind.nullable>
</properties>

<dependencies>
<dependency>
<groupId>io.helidon.microprofile.rest-client</groupId>
Expand All @@ -37,14 +41,14 @@
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
<version>${version.jackson.databind.nullable}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.openapitools.client.model.OuterEnumIntegerDefaultValue;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Map;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;


Expand Down
14 changes: 9 additions & 5 deletions samples/client/petstore/java-helidon-client/se/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<version>1.0.0</version>
<packaging>jar</packaging>

<properties>
<version.jackson.databind.nullable>0.2.6</version.jackson.databind.nullable>
</properties>

<dependencies>
<dependency>
<groupId>io.helidon.webclient</groupId>
Expand All @@ -28,6 +32,11 @@
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${version.jackson.databind.nullable}</version>
</dependency>
<dependency>
<groupId>io.helidon.media</groupId>
<artifactId>helidon-media-jackson</artifactId>
Expand All @@ -36,11 +45,6 @@
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.openapitools.client.model.OuterEnumIntegerDefaultValue;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.fasterxml.jackson.annotation.JsonValue;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Map;
import org.openapitools.jackson.nullable.JsonNullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.openapitools.jackson.nullable.JsonNullable;
import java.util.NoSuchElementException;


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

package org.openapitools.server.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;


/**
* Model tests for AdditionalPropertiesClass
*/
public class AdditionalPropertiesClassTest {
private final AdditionalPropertiesClass model = new AdditionalPropertiesClass();

/**
* Model tests for AdditionalPropertiesClass
*/
@Test
public void testAdditionalPropertiesClass() {
// TODO: test AdditionalPropertiesClass
}

/**
* Test the property 'mapProperty'
*/
@Test
public void mapPropertyTest() {
// TODO: test mapProperty
}

/**
* Test the property 'mapOfMapProperty'
*/
@Test
public void mapOfMapPropertyTest() {
// TODO: test mapOfMapProperty
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

package org.openapitools.server.model;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;


/**
* Model tests for ArrayOfArrayOfNumberOnly
*/
public class ArrayOfArrayOfNumberOnlyTest {
private final ArrayOfArrayOfNumberOnly model = new ArrayOfArrayOfNumberOnly();

/**
* Model tests for ArrayOfArrayOfNumberOnly
*/
@Test
public void testArrayOfArrayOfNumberOnly() {
// TODO: test ArrayOfArrayOfNumberOnly
}

/**
* Test the property 'arrayArrayNumber'
*/
@Test
public void arrayArrayNumberTest() {
// TODO: test arrayArrayNumber
}

}
Loading

0 comments on commit fbf42de

Please sign in to comment.