Skip to content

[helidon-generator] Support avaje-jsonb version 3 #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
Expand Up @@ -8,14 +8,7 @@
import java.util.Map;
import java.util.Objects;

import io.avaje.http.generator.core.BaseControllerWriter;
import io.avaje.http.generator.core.Constants;
import io.avaje.http.generator.core.ControllerReader;
import io.avaje.http.generator.core.CoreWebMethod;
import io.avaje.http.generator.core.JsonBUtil;
import io.avaje.http.generator.core.MethodReader;
import io.avaje.http.generator.core.PrimitiveUtil;
import io.avaje.http.generator.core.UType;
import io.avaje.http.generator.core.*;

/**
* Write Helidon specific web route adapter (a Helidon Service).
Expand All @@ -25,6 +18,9 @@ class ControllerWriter extends BaseControllerWriter {
private static final String AT_GENERATED = "@Generated(\"avaje-helidon-generator\")";
private static final String IMPORT_HTTP_STATUS = "import static io.helidon.http.Status.*;";

private static final String JSON_JsonOutput = "io.avaje.json.stream.JsonOutput";
private static final String JSONB_JsonOutput = "io.avaje.jsonb.stream.JsonOutput";

private final boolean useJsonB;
private final Map<String, UType> jsonTypes;

Expand All @@ -35,7 +31,7 @@ class ControllerWriter extends BaseControllerWriter {
reader.addImportType("io.avaje.jsonb.Jsonb");
reader.addImportType("io.avaje.jsonb.JsonType");
reader.addImportType("io.avaje.jsonb.Types");
reader.addImportType("io.avaje.jsonb.stream.JsonOutput");
reader.addImportType(jsonOutputType());
this.jsonTypes = JsonBUtil.jsonTypes(reader);
jsonTypes.values().stream()
.map(UType::importTypes)
Expand Down Expand Up @@ -76,6 +72,12 @@ class ControllerWriter extends BaseControllerWriter {
}
}

private static String jsonOutputType() {
return ProcessingContext.typeElement(JSON_JsonOutput) != null
? JSON_JsonOutput
: JSONB_JsonOutput;
}

void write() {
writePackage();
writeImports();
Expand Down
4 changes: 2 additions & 2 deletions tests/test-jex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<version>2.4</version>
<version>3.0-RC2</version>
</dependency>

<!-- java annotation processors -->
Expand All @@ -96,7 +96,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb-generator</artifactId>
<version>2.4</version>
<version>3.0-RC2</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions tests/test-nima-jsonb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<version>2.4</version>
<version>3.0-RC2</version>
</dependency>
<dependency>
<groupId>io.helidon.webserver</groupId>
Expand Down Expand Up @@ -85,7 +85,7 @@
<path>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb-generator</artifactId>
<version>2.4</version>
<version>3.0-RC2</version>
</path>
<path>
<groupId>io.avaje</groupId>
Expand Down
Loading