Skip to content
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

Support Helidon SE 4 generation (clients and servers) #19150

Merged
merged 43 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
308882e
Save work-in-progress
tjquinno Jun 8, 2024
dffe716
Incoming param handling generating well exc. for file upload
tjquinno Jun 11, 2024
e817187
Revise generated test for v3 vs v4 differences
tjquinno Jun 12, 2024
7520175
Leave details of multi-part handling to the user for now
tjquinno Jun 12, 2024
3b9270d
change default version to use the highest version known
tjquinno Jun 12, 2024
a7429e9
SE client changes for Helidon 4
tjquinno Jun 15, 2024
191ba3c
A few fixes; add new v4 SE samples
tjquinno Jun 16, 2024
d494f0d
Fix v3/v4 routing prep
tjquinno Jun 17, 2024
107ef6c
Improve version handling if web site is inaccessible; add test
tjquinno Jun 21, 2024
edc90f9
Reworking parameter conversion and required and validation handling
tjquinno Jun 24, 2024
cb1137d
Add generation of a return value record per response for each operation
tjquinno Jun 27, 2024
8456a20
Improvements to the result record generation
tjquinno Jun 27, 2024
5704745
More changes
tjquinno Jun 28, 2024
89abbde
Remove change in whitespace in v3 output
tjquinno Jun 28, 2024
a6c793f
More progress on parameter handling
tjquinno Jul 5, 2024
bba6e41
WIP - refactor parameter-returning methods to inner class along with …
tjquinno Jul 8, 2024
fbefde8
Reorg of op helpers
tjquinno Jul 9, 2024
172383d
Use no-op for handling map in path, query, header, cookie - need to r…
tjquinno Jul 9, 2024
835540e
Binary form param handling
tjquinno Jul 10, 2024
0313f54
Clean-up and consistency check bt useAbstractClass and not
tjquinno Jul 10, 2024
a9ee14a
Improve result builders
tjquinno Jul 10, 2024
0856fe6
Add new samples files
tjquinno Jul 11, 2024
d78119c
Fix a few issues
tjquinno Jul 11, 2024
7ad0ad5
Update samples after rebase; add build steps for v3 and v4 uac github…
tjquinno Jul 11, 2024
9655efa
Remove v3 se useAbstractClass test - creates some bad code
tjquinno Jul 11, 2024
6f88bfd
Generated doc updates
tjquinno Jul 11, 2024
5e4e1e5
Fix missing newline
tjquinno Jul 11, 2024
7a8e42b
Improve Javadoc for generated Result; add convenience Result.send method
tjquinno Jul 12, 2024
80d47e7
Add bean val. for body param if needed
tjquinno Jul 12, 2024
ba3ae31
Restructure generated records for declared responses; add Generated a…
tjquinno Jul 12, 2024
19aad83
Fix typo
tjquinno Jul 12, 2024
9f3f5d2
In sample generation, force a stable generatorVersion value to avoid …
tjquinno Jul 12, 2024
f1cff83
Fix up white space in older generation
tjquinno Jul 12, 2024
640e7dc
Generate PartsUtils only with useAbstractClass = true
tjquinno Jul 16, 2024
dbb64c5
Adopt some review comments; more to come
tjquinno Jul 23, 2024
edca75b
Review comments; notably, switch to using the first path segment to g…
tjquinno Jul 25, 2024
47c3d54
Improve status handling a bit
tjquinno Jul 25, 2024
15b3a38
Add new generated sample files
tjquinno Jul 25, 2024
19af5dd
Add missing new samples files
tjquinno Jul 25, 2024
18d2727
Quite a few updates, esp. to generated samples
tjquinno Jul 28, 2024
e6a9b3c
New config file for sample
tjquinno Jul 28, 2024
da2dcec
Updates samples
tjquinno Aug 3, 2024
c7b00df
Add updates to .openapi-generator/FILES contents
tjquinno Aug 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/workflows/samples-java-helidon-v4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ jobs:
matrix:
sample:
- samples/client/petstore/java-helidon-client/v4/mp
- samples/client/petstore/java-helidon-client/v4/se
- samples/server/petstore/java-helidon-server/v4/mp
- samples/server/petstore/java-helidon-server/v4/se
- samples/server/petstore/java-helidon-server/v4/se-uac
version: [21]
steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/samples-jdk21.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ on:
paths:
# clients
- samples/client/petstore/java-helidon-client/v4/mp/**
- samples/client/petstore/java-helidon-client/v4/se/**
# servers
- samples/server/petstore/java-helidon-server/v4/mp/**
- samples/server/petstore/java-helidon-server/v4/se/**
pull_request:
paths:
# clients
- samples/client/petstore/java-helidon-client/v4/mp/**
- samples/client/petstore/java-helidon-client/v4/se/**
# servers
- samples/server/petstore/java-helidon-server/v4/mp/**
- samples/server/petstore/java-helidon-server/v4/se/**
jobs:
build:
name: Build with JDK21
Expand All @@ -22,8 +26,10 @@ jobs:
sample:
# clients
- samples/client/petstore/java-helidon-client/v4/mp/
- samples/client/petstore/java-helidon-client/v4/se/
# servers
- samples/server/petstore/java-helidon-server/v4/mp/
- samples/server/petstore/java-helidon-server/v4/se/
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
2 changes: 1 addition & 1 deletion bin/configs/java-helidon-client-mp_4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library: mp
outputDir: samples/client/petstore/java-helidon-client/v4/mp
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
additionalProperties:
helidonVersion: 4.0.8
helidonVersion: 4.0.11
artifactId: petstore-helidon-client-mp
hideGenerationTimestamp: "true"
configureAuth: "false"
Expand Down
14 changes: 14 additions & 0 deletions bin/configs/java-helidon-client-se_4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
generatorName: java-helidon-client
library: se
outputDir: samples/client/petstore/java-helidon-client/v4/se
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
additionalProperties:
helidonVersion: 4.0.11
artifactId: petstore-helidon-client-se
hideGenerationTimestamp: "true"
configureAuth: "false"
build: "all"
test: "spock"
requiredPropertiesInConstructor: "false"
visitable: "true"
fullProject: "true"
2 changes: 1 addition & 1 deletion bin/configs/java-helidon-server-mp_4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ outputDir: samples/server/petstore/java-helidon-server/v4/mp
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
additionalProperties:
helidonVersion: 4.0.8
helidonVersion: 4.0.11
artifactId: petstore-helidon-server-mp
hideGenerationTimestamp: "true"
build: "all"
Expand Down
13 changes: 13 additions & 0 deletions bin/configs/java-helidon-server-se_4-uac-group-by-file-path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
generatorName: java-helidon-server
library: se
outputDir: samples/server/petstore/java-helidon-server/v4/se-uac-group-by-file-path
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
additionalProperties:
helidonVersion: 4.0.11
artifactId: petstore-helidon-server-se
hideGenerationTimestamp: "true"
fullProject: "true"
useAbstractClass: "true"
generatorVersion: "stable"
x-helidon-groupBy: first-path-segment
12 changes: 12 additions & 0 deletions bin/configs/java-helidon-server-se_4-uac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
generatorName: java-helidon-server
library: se
outputDir: samples/server/petstore/java-helidon-server/v4/se-uac
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
additionalProperties:
helidonVersion: 4.0.11
artifactId: petstore-helidon-server-se
hideGenerationTimestamp: "true"
fullProject: "true"
useAbstractClass: "true"
generatorVersion: "stable"
12 changes: 12 additions & 0 deletions bin/configs/java-helidon-server-se_4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
generatorName: java-helidon-server
library: se
outputDir: samples/server/petstore/java-helidon-server/v4/se
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/java-helidon/server
additionalProperties:
helidonVersion: 4.0.11
artifactId: petstore-helidon-server-se
hideGenerationTimestamp: "true"
fullProject: "true"
x-helidon-useOptional: "true"
generatorVersion: "stable"
2 changes: 2 additions & 0 deletions docs/generators/java-helidon-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|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|
|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|
|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|
|x-helidon-useOptional|Wrap optional parameters in an Optional (Helidon 4 and later)| |true|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
2 changes: 2 additions & 0 deletions docs/generators/java-helidon-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useJakartaEe|whether to use Jakarta EE namespace instead of javax| |false|
|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|
|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|
|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|
|x-helidon-useOptional|Wrap optional parameters in an Optional (Helidon 4 and later)| |true|

## SUPPORTED VENDOR EXTENSIONS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class JavaHelidonClientCodegen extends JavaHelidonCommonCodegen {

private static final String X_HELIDON_REQUIRED_IMPL_IMPORTS = "x-helidon-requiredImplImports";
private static final String X_HELIDON_IMPL_IMPORTS = "x-helidon-implImports";
private static final String X_CLIENT_STYLE_V3 = "x-helidon-client-style-v3";
public static final String CONFIG_KEY = "configKey";

@Setter protected String configKey = null;
Expand Down Expand Up @@ -173,6 +174,8 @@ public String apiFilename(String templateName, String tag) {
public void processOpts() {
super.processOpts();

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

convertPropertyToStringAndWriteBack(CONFIG_KEY, this::setConfigKey);
Expand All @@ -199,7 +202,12 @@ public void processOpts() {
} else if (isLibrary(HELIDON_SE)) {
apiTemplateFiles.put("api_impl.mustache", ".java");
importMapping.put("StringJoiner", "java.util.StringJoiner");
importMapping.put("WebClientRequestHeaders", "io.helidon.webclient.WebClientRequestHeaders");
if (helidonMajorVersion == 3) {
importMapping.put("WebClientRequestHeaders", "io.helidon.webclient.WebClientRequestHeaders");
} else {
importMapping.put("ClientRequestHeaders", "io.helidon.http.ClientRequestHeaders");
importMapping.put("HeaderNames", "io.helidon.http.HeaderNames");
}
importMapping.put("Pair", invokerPackage + ".Pair");


Expand Down Expand Up @@ -309,7 +317,10 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
requiredImplImports.add("Pair");
}
if (op.getHasHeaderParams()) {
requiredImplImports.add("WebClientRequestHeaders");
requiredImplImports.add(helidonMajorVersion == 3 ? "WebClientRequestHeaders" : "ClientRequestHeaders");
if (helidonMajorVersion > 3) {
requiredImplImports.add("HeaderNames");
}
}
if (op.getHasFormParams()) {
requiredImplImports.add("StringJoiner");
Expand Down
Loading
Loading