Skip to content

Commit 8f1d59f

Browse files
authored
Support Helidon SE 4 generation (clients and servers) (#19150)
* Save work-in-progress * Incoming param handling generating well exc. for file upload * Revise generated test for v3 vs v4 differences * Leave details of multi-part handling to the user for now * change default version to use the highest version known * SE client changes for Helidon 4 * A few fixes; add new v4 SE samples * Fix v3/v4 routing prep * Improve version handling if web site is inaccessible; add test * Reworking parameter conversion and required and validation handling * Add generation of a return value record per response for each operation * Improvements to the result record generation * More changes * Remove change in whitespace in v3 output * More progress on parameter handling * WIP - refactor parameter-returning methods to inner class along with return records * Reorg of op helpers * Use no-op for handling map in path, query, header, cookie - need to revise later * Binary form param handling * Clean-up and consistency check bt useAbstractClass and not * Improve result builders * Add new samples files * Fix a few issues * Update samples after rebase; add build steps for v3 and v4 uac github actions * Remove v3 se useAbstractClass test - creates some bad code * Generated doc updates * Fix missing newline * Improve Javadoc for generated Result; add convenience Result.send method * Add bean val. for body param if needed * Restructure generated records for declared responses; add Generated annotation selectively * Fix typo * In sample generation, force a stable generatorVersion value to avoid confusing builds and up-to-date samples checking * Fix up white space in older generation * Generate PartsUtils only with useAbstractClass = true * Adopt some review comments; more to come * Review comments; notably, switch to using the first path segment to group operations rather than the tags items * Improve status handling a bit * Add new generated sample files * Add missing new samples files * Quite a few updates, esp. to generated samples * New config file for sample * Updates samples * Add updates to .openapi-generator/FILES contents
1 parent af94bde commit 8f1d59f

File tree

685 files changed

+75033
-202
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

685 files changed

+75033
-202
lines changed

.github/workflows/samples-java-helidon-v4.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ jobs:
1818
matrix:
1919
sample:
2020
- samples/client/petstore/java-helidon-client/v4/mp
21+
- samples/client/petstore/java-helidon-client/v4/se
2122
- samples/server/petstore/java-helidon-server/v4/mp
23+
- samples/server/petstore/java-helidon-server/v4/se
24+
- samples/server/petstore/java-helidon-server/v4/se-uac
2225
version: [21]
2326
steps:
2427
- uses: actions/checkout@v4

.github/workflows/samples-jdk21.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ on:
44
paths:
55
# clients
66
- samples/client/petstore/java-helidon-client/v4/mp/**
7+
- samples/client/petstore/java-helidon-client/v4/se/**
78
# servers
89
- samples/server/petstore/java-helidon-server/v4/mp/**
10+
- samples/server/petstore/java-helidon-server/v4/se/**
911
pull_request:
1012
paths:
1113
# clients
1214
- samples/client/petstore/java-helidon-client/v4/mp/**
15+
- samples/client/petstore/java-helidon-client/v4/se/**
1316
# servers
1417
- samples/server/petstore/java-helidon-server/v4/mp/**
18+
- samples/server/petstore/java-helidon-server/v4/se/**
1519
jobs:
1620
build:
1721
name: Build with JDK21
@@ -22,8 +26,10 @@ jobs:
2226
sample:
2327
# clients
2428
- samples/client/petstore/java-helidon-client/v4/mp/
29+
- samples/client/petstore/java-helidon-client/v4/se/
2530
# servers
2631
- samples/server/petstore/java-helidon-server/v4/mp/
32+
- samples/server/petstore/java-helidon-server/v4/se/
2733
steps:
2834
- uses: actions/checkout@v4
2935
- uses: actions/setup-java@v4

bin/configs/java-helidon-client-mp_4.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ library: mp
33
outputDir: samples/client/petstore/java-helidon-client/v4/mp
44
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
55
additionalProperties:
6-
helidonVersion: 4.0.8
6+
helidonVersion: 4.0.11
77
artifactId: petstore-helidon-client-mp
88
hideGenerationTimestamp: "true"
99
configureAuth: "false"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
generatorName: java-helidon-client
2+
library: se
3+
outputDir: samples/client/petstore/java-helidon-client/v4/se
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
5+
additionalProperties:
6+
helidonVersion: 4.0.11
7+
artifactId: petstore-helidon-client-se
8+
hideGenerationTimestamp: "true"
9+
configureAuth: "false"
10+
build: "all"
11+
test: "spock"
12+
requiredPropertiesInConstructor: "false"
13+
visitable: "true"
14+
fullProject: "true"

bin/configs/java-helidon-server-mp_4.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ outputDir: samples/server/petstore/java-helidon-server/v4/mp
44
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
55
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
66
additionalProperties:
7-
helidonVersion: 4.0.8
7+
helidonVersion: 4.0.11
88
artifactId: petstore-helidon-server-mp
99
hideGenerationTimestamp: "true"
1010
build: "all"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
generatorName: java-helidon-server
2+
library: se
3+
outputDir: samples/server/petstore/java-helidon-server/v4/se-uac-group-by-file-path
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
6+
additionalProperties:
7+
helidonVersion: 4.0.11
8+
artifactId: petstore-helidon-server-se
9+
hideGenerationTimestamp: "true"
10+
fullProject: "true"
11+
useAbstractClass: "true"
12+
generatorVersion: "stable"
13+
x-helidon-groupBy: first-path-segment
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
generatorName: java-helidon-server
2+
library: se
3+
outputDir: samples/server/petstore/java-helidon-server/v4/se-uac
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
6+
additionalProperties:
7+
helidonVersion: 4.0.11
8+
artifactId: petstore-helidon-server-se
9+
hideGenerationTimestamp: "true"
10+
fullProject: "true"
11+
useAbstractClass: "true"
12+
generatorVersion: "stable"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
generatorName: java-helidon-server
2+
library: se
3+
outputDir: samples/server/petstore/java-helidon-server/v4/se
4+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
5+
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
6+
additionalProperties:
7+
helidonVersion: 4.0.11
8+
artifactId: petstore-helidon-server-se
9+
hideGenerationTimestamp: "true"
10+
fullProject: "true"
11+
x-helidon-useOptional: "true"
12+
generatorVersion: "stable"

docs/generators/java-helidon-client.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
6565
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
6666
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
6767
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
68+
|x-helidon-groupBy|Selects how to group operations into APIs|<dl><dt>**tags**</dt><dd>Use the 'tags' settings on each operation</dd><dt>**first-path-segment**</dt><dd>Use the first segment of the path</dd></dl>|tags|
69+
|x-helidon-useOptional|Wrap optional parameters in an Optional (Helidon 4 and later)| |true|
6870

6971
## SUPPORTED VENDOR EXTENSIONS
7072

docs/generators/java-helidon-server.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
6868
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
6969
|useOneOfInterfaces|whether to use a java interface to describe a set of oneOf options, where each option is a class that implements the interface| |false|
7070
|withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false|
71+
|x-helidon-groupBy|Selects how to group operations into APIs|<dl><dt>**tags**</dt><dd>Use the 'tags' settings on each operation</dd><dt>**first-path-segment**</dt><dd>Use the first segment of the path</dd></dl>|tags|
72+
|x-helidon-useOptional|Wrap optional parameters in an Optional (Helidon 4 and later)| |true|
7173

7274
## SUPPORTED VENDOR EXTENSIONS
7375

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaHelidonClientCodegen.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public class JavaHelidonClientCodegen extends JavaHelidonCommonCodegen {
6565

6666
private static final String X_HELIDON_REQUIRED_IMPL_IMPORTS = "x-helidon-requiredImplImports";
6767
private static final String X_HELIDON_IMPL_IMPORTS = "x-helidon-implImports";
68+
private static final String X_CLIENT_STYLE_V3 = "x-helidon-client-style-v3";
6869
public static final String CONFIG_KEY = "configKey";
6970

7071
@Setter protected String configKey = null;
@@ -173,6 +174,8 @@ public String apiFilename(String templateName, String tag) {
173174
public void processOpts() {
174175
super.processOpts();
175176

177+
// Not intended for users to set; we compute this based on the major version.
178+
additionalProperties.put(X_CLIENT_STYLE_V3, helidonMajorVersion == 3);
176179
convertPropertyToStringAndWriteBack(SERIALIZATION_LIBRARY, this::setSerializationLibrary);
177180

178181
convertPropertyToStringAndWriteBack(CONFIG_KEY, this::setConfigKey);
@@ -199,7 +202,12 @@ public void processOpts() {
199202
} else if (isLibrary(HELIDON_SE)) {
200203
apiTemplateFiles.put("api_impl.mustache", ".java");
201204
importMapping.put("StringJoiner", "java.util.StringJoiner");
202-
importMapping.put("WebClientRequestHeaders", "io.helidon.webclient.WebClientRequestHeaders");
205+
if (helidonMajorVersion == 3) {
206+
importMapping.put("WebClientRequestHeaders", "io.helidon.webclient.WebClientRequestHeaders");
207+
} else {
208+
importMapping.put("ClientRequestHeaders", "io.helidon.http.ClientRequestHeaders");
209+
importMapping.put("HeaderNames", "io.helidon.http.HeaderNames");
210+
}
203211
importMapping.put("Pair", invokerPackage + ".Pair");
204212

205213

@@ -309,7 +317,10 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
309317
requiredImplImports.add("Pair");
310318
}
311319
if (op.getHasHeaderParams()) {
312-
requiredImplImports.add("WebClientRequestHeaders");
320+
requiredImplImports.add(helidonMajorVersion == 3 ? "WebClientRequestHeaders" : "ClientRequestHeaders");
321+
if (helidonMajorVersion > 3) {
322+
requiredImplImports.add("HeaderNames");
323+
}
313324
}
314325
if (op.getHasFormParams()) {
315326
requiredImplImports.add("StringJoiner");

0 commit comments

Comments
 (0)