diff --git a/.github/workflows/samples-java-helidon-v3.yaml b/.github/workflows/samples-java-helidon-v3.yaml index 976c7f59cb7..8dd7e35a88d 100644 --- a/.github/workflows/samples-java-helidon-v3.yaml +++ b/.github/workflows/samples-java-helidon-v3.yaml @@ -5,10 +5,12 @@ on: paths: - samples/client/petstore/java-helidon-client/v3/** - samples/server/petstore/java-helidon-server/v3/** + - samples/server/others/java-helidon-server/v3/** pull_request: paths: - samples/client/petstore/java-helidon-client/v3/** - samples/server/petstore/java-helidon-server/v3/** + - samples/server/others/java-helidon-server/v3/** jobs: build: name: Build Java Helidon @@ -21,6 +23,7 @@ jobs: - samples/client/petstore/java-helidon-client/v3/se - samples/server/petstore/java-helidon-server/v3/mp - samples/server/petstore/java-helidon-server/v3/se + - samples/server/others/java-helidon-server/v3/mp-format-test version: [17] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/samples-java-helidon-v4.yaml b/.github/workflows/samples-java-helidon-v4.yaml index 2922c81247d..bb1b4c3f051 100644 --- a/.github/workflows/samples-java-helidon-v4.yaml +++ b/.github/workflows/samples-java-helidon-v4.yaml @@ -5,10 +5,12 @@ on: paths: - samples/client/petstore/java-helidon-client/v4/** - samples/server/petstore/java-helidon-server/v4/** + - samples/server/others/java-helidon-server/v4/** pull_request: paths: - samples/client/petstore/java-helidon-client/v4/** - samples/server/petstore/java-helidon-server/v4/** + - samples/server/others/java-helidon-server/v4/** jobs: build: name: Build Java Helidon @@ -22,6 +24,7 @@ jobs: - 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 + - samples/server/others/java-helidon-server/v4/mp-format-test version: [21] steps: - uses: actions/checkout@v4 diff --git a/bin/configs/java-helidon-server-mp_3_format_test.yaml b/bin/configs/java-helidon-server-mp_3_format_test.yaml new file mode 100644 index 00000000000..e2e1582569c --- /dev/null +++ b/bin/configs/java-helidon-server-mp_3_format_test.yaml @@ -0,0 +1,10 @@ +generatorName: java-helidon-server +library: mp +outputDir: samples/server/others/java-helidon-server/v3/mp-format-test +inputSpec: modules/openapi-generator/src/test/resources/3_0/helidon/format-test.yaml +templateDir: modules/openapi-generator/src/main/resources/java-helidon/server +additionalProperties: + helidonVersion: 3.2.7 + artifactId: format-helidon-server-mp + hideGenerationTimestamp: "true" + fullProject: "true" \ No newline at end of file diff --git a/bin/configs/java-helidon-server-mp_4_format_test.yaml b/bin/configs/java-helidon-server-mp_4_format_test.yaml new file mode 100644 index 00000000000..c1198577271 --- /dev/null +++ b/bin/configs/java-helidon-server-mp_4_format_test.yaml @@ -0,0 +1,10 @@ +generatorName: java-helidon-server +library: mp +outputDir: samples/server/others/java-helidon-server/v4/mp-format-test +inputSpec: modules/openapi-generator/src/test/resources/3_0/helidon/format-test.yaml +templateDir: modules/openapi-generator/src/main/resources/java-helidon/server +additionalProperties: + helidonVersion: 4.0.11 + artifactId: format-helidon-server-mp + hideGenerationTimestamp: "true" + fullProject: "true" \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/java-helidon/server/libraries/mp/beanValidationCore.mustache b/modules/openapi-generator/src/main/resources/java-helidon/server/libraries/mp/beanValidationCore.mustache index d6e2f13b457..f4522800806 100644 --- a/modules/openapi-generator/src/main/resources/java-helidon/server/libraries/mp/beanValidationCore.mustache +++ b/modules/openapi-generator/src/main/resources/java-helidon/server/libraries/mp/beanValidationCore.mustache @@ -1,4 +1,4 @@ -{{#pattern}} @Pattern(regexp="{{{.}}}"){{/pattern}}{{! +{{#pattern}}{{^isByteArray}} @Pattern(regexp="{{{.}}}"){{/isByteArray}}{{/pattern}}{{! minLength && maxLength set }}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{! minLength set, maxLength not diff --git a/modules/openapi-generator/src/test/resources/3_0/helidon/format-test.yaml b/modules/openapi-generator/src/test/resources/3_0/helidon/format-test.yaml new file mode 100644 index 00000000000..c5e9150f2a9 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/helidon/format-test.yaml @@ -0,0 +1,36 @@ +openapi: 3.0.0 +servers: + - url: 'http://petstore.helidon.io:8080/format' +info: + description: >- + This spec is mainly for testing Petstore server and contains fake endpoints, + models. Please do not use this for any other purpose. For this sample, you can use the api key + `special-key` to test the authorization filters. Special characters: " + \ + version: 1.0.0 + title: OpenAPI Petstore + license: + name: Apache-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0.html' +tags: + - name: format + description: Format tester +paths: + /format: + get: + operationId: simple + responses: + "200": + content: {} + description: success + tags: + - format + +components: + schemas: + format_test: + properties: + byte: + format: byte + pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" + type: string diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator-ignore b/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator/FILES b/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator/FILES new file mode 100644 index 00000000000..916fb021c31 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator/FILES @@ -0,0 +1,13 @@ +README.md +pom.xml +src/main/java/org/openapitools/server/JavaTimeFormatter.java +src/main/java/org/openapitools/server/RFC3339DateFormat.java +src/main/java/org/openapitools/server/RestApplication.java +src/main/java/org/openapitools/server/api/FormatService.java +src/main/java/org/openapitools/server/api/FormatServiceImpl.java +src/main/java/org/openapitools/server/model/FormatTest.java +src/main/java/org/openapitools/server/package-info.java +src/main/resources/META-INF/beans.xml +src/main/resources/META-INF/microprofile-config.properties +src/main/resources/META-INF/openapi.yml +src/main/resources/logging.properties diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator/VERSION b/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/README.md b/samples/server/others/java-helidon-server/v3/mp-format-test/README.md new file mode 100644 index 00000000000..8abe5cd7b94 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/README.md @@ -0,0 +1,34 @@ +# Helidon Server with OpenAPI + +## Build and run + +With JDK11+ +```bash +mvn package +java -jar target/format-helidon-server-mp.jar +``` + +## Exercise the application + +``` +curl -X GET http://petstore.helidon.io:8080/format + +``` + +## Try health and metrics + +``` +curl -s -X GET http://petstore.helidon.io:8080/format/health +{"outcome":"UP",... +. . . + +# Prometheus Format +curl -s -X GET http://petstore.helidon.io:8080/format/metrics +# TYPE base:gc_g1_young_generation_count gauge +. . . + +# JSON Format +curl -H 'Accept: application/json' -X GET http://petstore.helidon.io:8080/format/metrics +{"base":... +. . . +``` \ No newline at end of file diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/pom.xml b/samples/server/others/java-helidon-server/v3/mp-format-test/pom.xml new file mode 100644 index 00000000000..720351fe7ef --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + org.openapitools + + io.helidon.applications + helidon-mp + 3.2.7 + + + format-helidon-server-mp + format-helidon-server-mp + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. Special characters: \" \\ + 1.0.0 + jar + + + 0.2.6 + + + + + io.helidon.microprofile.bundles + helidon-microprofile-core + + + io.helidon.microprofile.cdi + helidon-microprofile-cdi + + + jakarta.enterprise + jakarta.enterprise.cdi-api + + + jakarta.ws.rs + jakarta.ws.rs-api + + + org.openapitools + jackson-databind-nullable + ${version.jackson.databind.nullable} + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + org.junit.jupiter + junit-jupiter-api + test + + + io.helidon.microprofile.tests + helidon-microprofile-tests-junit5 + test + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-libs + + + + + org.jboss.jandex + jandex-maven-plugin + + + make-index + + + + + + diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/JavaTimeFormatter.java b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/JavaTimeFormatter.java new file mode 100644 index 00000000000..b37465c2495 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/JavaTimeFormatter.java @@ -0,0 +1,64 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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; + +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; + +/** + * Class that add parsing/formatting support for Java 8+ {@code OffsetDateTime} class. + * It's generated for java clients when {@code AbstractJavaCodegen#dateLibrary} specified as {@code java8}. + */ +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaHelidonServerCodegen", comments = "Generator version: 7.8.0-SNAPSHOT") +public class JavaTimeFormatter { + + private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; + + /** + * Get the date format used to parse/format {@code OffsetDateTime} parameters. + * @return DateTimeFormatter + */ + public DateTimeFormatter getOffsetDateTimeFormatter() { + return offsetDateTimeFormatter; + } + + /** + * Set the date format used to parse/format {@code OffsetDateTime} parameters. + * @param offsetDateTimeFormatter {@code DateTimeFormatter} + */ + public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) { + this.offsetDateTimeFormatter = offsetDateTimeFormatter; + } + + /** + * Parse the given string into {@code OffsetDateTime} object. + * @param str String + * @return {@code OffsetDateTime} + */ + public OffsetDateTime parseOffsetDateTime(String str) { + try { + return OffsetDateTime.parse(str, offsetDateTimeFormatter); + } catch (DateTimeParseException e) { + throw new RuntimeException(e); + } + } + /** + * Format the given {@code OffsetDateTime} object into string. + * @param offsetDateTime {@code OffsetDateTime} + * @return {@code OffsetDateTime} in string format + */ + public String formatOffsetDateTime(OffsetDateTime offsetDateTime) { + return offsetDateTimeFormatter.format(offsetDateTime); + } +} diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/RFC3339DateFormat.java b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/RFC3339DateFormat.java new file mode 100644 index 00000000000..87c3c37aedb --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/RFC3339DateFormat.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return this; + } +} \ No newline at end of file diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/RestApplication.java b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/RestApplication.java new file mode 100644 index 00000000000..ae16aa215b5 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/RestApplication.java @@ -0,0 +1,11 @@ +package org.openapitools.server; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +@ApplicationScoped +@ApplicationPath("/format") +public class RestApplication extends Application { + +} diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/api/FormatService.java b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/api/FormatService.java new file mode 100644 index 00000000000..7bff62d5d7a --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/api/FormatService.java @@ -0,0 +1,30 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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.api; + + +import jakarta.ws.rs.*; + +import java.io.InputStream; +import java.util.Map; +import java.util.List; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +@Path("/format") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaHelidonServerCodegen", comments = "Generator version: 7.8.0-SNAPSHOT") +public interface FormatService { + + @GET + void simple(); +} diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/api/FormatServiceImpl.java b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/api/FormatServiceImpl.java new file mode 100644 index 00000000000..cee63db7d17 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/api/FormatServiceImpl.java @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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.api; + + +import jakarta.ws.rs.*; + + +import java.io.InputStream; +import java.util.Map; +import java.util.List; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +@Path("/format") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaHelidonServerCodegen", comments = "Generator version: 7.8.0-SNAPSHOT") +public class FormatServiceImpl implements FormatService { + + @GET + public void simple() { + } +} diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/model/FormatTest.java b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/model/FormatTest.java new file mode 100644 index 00000000000..fe39d1787b1 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/model/FormatTest.java @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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 com.fasterxml.jackson.annotation.JsonTypeName; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + +public class FormatTest { + + private byte[] _byte; + + /** + * Get _byte + * @return _byte + **/ + public byte[] getByte() { + return _byte; + } + + /** + * Set _byte + **/ + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/package-info.java b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/package-info.java new file mode 100644 index 00000000000..1025e91aed8 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/java/org/openapitools/server/package-info.java @@ -0,0 +1 @@ +package org.openapitools.server; \ No newline at end of file diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/beans.xml b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000000..125ef995e5e --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/beans.xml @@ -0,0 +1,9 @@ + + + + diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/microprofile-config.properties b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/microprofile-config.properties new file mode 100644 index 00000000000..38988f20e5e --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/microprofile-config.properties @@ -0,0 +1,11 @@ +# Microprofile server properties + +# Application properties. This is the default greeting +app.greeting=Hello + +# Microprofile server properties +server.port=8080 +server.host=0.0.0.0 + +# Enable the optional MicroProfile Metrics REST.request metrics +metrics.rest-request.enabled=true diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/openapi.yml b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/openapi.yml new file mode 100644 index 00000000000..7b12d6890a4 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/META-INF/openapi.yml @@ -0,0 +1,36 @@ +openapi: 3.0.0 +info: + description: "This spec is mainly for testing Petstore server and contains fake\ + \ endpoints, models. Please do not use this for any other purpose. For this sample,\ + \ you can use the api key `special-key` to test the authorization filters. Special\ + \ characters: \" \\" + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- url: http://petstore.helidon.io:8080/format +tags: +- description: Format tester + name: format +paths: + /format: + get: + operationId: simple + responses: + "200": + content: {} + description: success + tags: + - format + x-accepts: + - application/json +components: + schemas: + format_test: + properties: + byte: + format: byte + pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" + type: string diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/logging.properties b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/logging.properties new file mode 100644 index 00000000000..cd238eb6615 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/main/resources/logging.properties @@ -0,0 +1,19 @@ + +# Example Logging Configuration File +# For more information see $JAVA_HOME/jre/lib/logging.properties + +# Send messages to the console +handlers=io.helidon.common.HelidonConsoleHandler + +# HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread +java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n + +# Global logging level. Can be overridden by specific loggers +.level=INFO + +# Component specific log levels +#io.helidon.webserver.level=INFO +#io.helidon.config.level=INFO +#io.helidon.security.level=INFO +#io.helidon.common.level=INFO +#io.netty.level=INFO diff --git a/samples/server/others/java-helidon-server/v3/mp-format-test/src/test/java/org/openapitools/server/model/FormatTestTest.java b/samples/server/others/java-helidon-server/v3/mp-format-test/src/test/java/org/openapitools/server/model/FormatTestTest.java new file mode 100644 index 00000000000..056d8bdb076 --- /dev/null +++ b/samples/server/others/java-helidon-server/v3/mp-format-test/src/test/java/org/openapitools/server/model/FormatTestTest.java @@ -0,0 +1,40 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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 com.fasterxml.jackson.annotation.JsonTypeName; +import org.junit.jupiter.api.Test; + +/** + * Model tests for FormatTest + */ +public class FormatTestTest { + private final FormatTest model = new FormatTest(); + + /** + * Model tests for FormatTest + */ + @Test + public void testFormatTest() { + // TODO: test FormatTest + } + + /** + * Test the property '_byte' + */ + @Test + public void _byteTest() { + // TODO: test _byte + } + +} diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator-ignore b/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator-ignore new file mode 100644 index 00000000000..7484ee590a3 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator/FILES b/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator/FILES new file mode 100644 index 00000000000..916fb021c31 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator/FILES @@ -0,0 +1,13 @@ +README.md +pom.xml +src/main/java/org/openapitools/server/JavaTimeFormatter.java +src/main/java/org/openapitools/server/RFC3339DateFormat.java +src/main/java/org/openapitools/server/RestApplication.java +src/main/java/org/openapitools/server/api/FormatService.java +src/main/java/org/openapitools/server/api/FormatServiceImpl.java +src/main/java/org/openapitools/server/model/FormatTest.java +src/main/java/org/openapitools/server/package-info.java +src/main/resources/META-INF/beans.xml +src/main/resources/META-INF/microprofile-config.properties +src/main/resources/META-INF/openapi.yml +src/main/resources/logging.properties diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator/VERSION b/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator/VERSION new file mode 100644 index 00000000000..6116b14d2c5 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.8.0-SNAPSHOT diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/README.md b/samples/server/others/java-helidon-server/v4/mp-format-test/README.md new file mode 100644 index 00000000000..8abe5cd7b94 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/README.md @@ -0,0 +1,34 @@ +# Helidon Server with OpenAPI + +## Build and run + +With JDK11+ +```bash +mvn package +java -jar target/format-helidon-server-mp.jar +``` + +## Exercise the application + +``` +curl -X GET http://petstore.helidon.io:8080/format + +``` + +## Try health and metrics + +``` +curl -s -X GET http://petstore.helidon.io:8080/format/health +{"outcome":"UP",... +. . . + +# Prometheus Format +curl -s -X GET http://petstore.helidon.io:8080/format/metrics +# TYPE base:gc_g1_young_generation_count gauge +. . . + +# JSON Format +curl -H 'Accept: application/json' -X GET http://petstore.helidon.io:8080/format/metrics +{"base":... +. . . +``` \ No newline at end of file diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/pom.xml b/samples/server/others/java-helidon-server/v4/mp-format-test/pom.xml new file mode 100644 index 00000000000..1ec3c8934b2 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/pom.xml @@ -0,0 +1,82 @@ + + 4.0.0 + org.openapitools + + io.helidon.applications + helidon-mp + 4.0.11 + + + format-helidon-server-mp + format-helidon-server-mp + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. Special characters: \" \\ + 1.0.0 + jar + + + 0.2.6 + + + + + io.helidon.microprofile.bundles + helidon-microprofile-core + + + io.helidon.microprofile.cdi + helidon-microprofile-cdi + + + jakarta.enterprise + jakarta.enterprise.cdi-api + + + jakarta.ws.rs + jakarta.ws.rs-api + + + org.openapitools + jackson-databind-nullable + ${version.jackson.databind.nullable} + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + org.junit.jupiter + junit-jupiter-api + test + + + io.helidon.microprofile.testing + helidon-microprofile-testing-junit5 + test + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-libs + + + + + io.smallrye + jandex-maven-plugin + + + make-index + + + + + + diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/JavaTimeFormatter.java b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/JavaTimeFormatter.java new file mode 100644 index 00000000000..b37465c2495 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/JavaTimeFormatter.java @@ -0,0 +1,64 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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; + +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; + +/** + * Class that add parsing/formatting support for Java 8+ {@code OffsetDateTime} class. + * It's generated for java clients when {@code AbstractJavaCodegen#dateLibrary} specified as {@code java8}. + */ +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaHelidonServerCodegen", comments = "Generator version: 7.8.0-SNAPSHOT") +public class JavaTimeFormatter { + + private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; + + /** + * Get the date format used to parse/format {@code OffsetDateTime} parameters. + * @return DateTimeFormatter + */ + public DateTimeFormatter getOffsetDateTimeFormatter() { + return offsetDateTimeFormatter; + } + + /** + * Set the date format used to parse/format {@code OffsetDateTime} parameters. + * @param offsetDateTimeFormatter {@code DateTimeFormatter} + */ + public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) { + this.offsetDateTimeFormatter = offsetDateTimeFormatter; + } + + /** + * Parse the given string into {@code OffsetDateTime} object. + * @param str String + * @return {@code OffsetDateTime} + */ + public OffsetDateTime parseOffsetDateTime(String str) { + try { + return OffsetDateTime.parse(str, offsetDateTimeFormatter); + } catch (DateTimeParseException e) { + throw new RuntimeException(e); + } + } + /** + * Format the given {@code OffsetDateTime} object into string. + * @param offsetDateTime {@code OffsetDateTime} + * @return {@code OffsetDateTime} in string format + */ + public String formatOffsetDateTime(OffsetDateTime offsetDateTime) { + return offsetDateTimeFormatter.format(offsetDateTime); + } +} diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/RFC3339DateFormat.java b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/RFC3339DateFormat.java new file mode 100644 index 00000000000..87c3c37aedb --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/RFC3339DateFormat.java @@ -0,0 +1,50 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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; + +import com.fasterxml.jackson.databind.util.StdDateFormat; + +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = new StdDateFormat() + .withTimeZone(TIMEZONE_Z) + .withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } + + @Override + public Object clone() { + return this; + } +} \ No newline at end of file diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/RestApplication.java b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/RestApplication.java new file mode 100644 index 00000000000..ae16aa215b5 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/RestApplication.java @@ -0,0 +1,11 @@ +package org.openapitools.server; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +@ApplicationScoped +@ApplicationPath("/format") +public class RestApplication extends Application { + +} diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/api/FormatService.java b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/api/FormatService.java new file mode 100644 index 00000000000..7bff62d5d7a --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/api/FormatService.java @@ -0,0 +1,30 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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.api; + + +import jakarta.ws.rs.*; + +import java.io.InputStream; +import java.util.Map; +import java.util.List; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +@Path("/format") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaHelidonServerCodegen", comments = "Generator version: 7.8.0-SNAPSHOT") +public interface FormatService { + + @GET + void simple(); +} diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/api/FormatServiceImpl.java b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/api/FormatServiceImpl.java new file mode 100644 index 00000000000..cee63db7d17 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/api/FormatServiceImpl.java @@ -0,0 +1,32 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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.api; + + +import jakarta.ws.rs.*; + + +import java.io.InputStream; +import java.util.Map; +import java.util.List; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +@Path("/format") +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaHelidonServerCodegen", comments = "Generator version: 7.8.0-SNAPSHOT") +public class FormatServiceImpl implements FormatService { + + @GET + public void simple() { + } +} diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/model/FormatTest.java b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/model/FormatTest.java new file mode 100644 index 00000000000..fe39d1787b1 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/model/FormatTest.java @@ -0,0 +1,74 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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 com.fasterxml.jackson.annotation.JsonTypeName; +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; + + +public class FormatTest { + + private byte[] _byte; + + /** + * Get _byte + * @return _byte + **/ + public byte[] getByte() { + return _byte; + } + + /** + * Set _byte + **/ + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + + /** + * Create a string representation of this pojo. + **/ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/package-info.java b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/package-info.java new file mode 100644 index 00000000000..1025e91aed8 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/java/org/openapitools/server/package-info.java @@ -0,0 +1 @@ +package org.openapitools.server; \ No newline at end of file diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/beans.xml b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/beans.xml new file mode 100644 index 00000000000..125ef995e5e --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/beans.xml @@ -0,0 +1,9 @@ + + + + diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/microprofile-config.properties b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/microprofile-config.properties new file mode 100644 index 00000000000..38988f20e5e --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/microprofile-config.properties @@ -0,0 +1,11 @@ +# Microprofile server properties + +# Application properties. This is the default greeting +app.greeting=Hello + +# Microprofile server properties +server.port=8080 +server.host=0.0.0.0 + +# Enable the optional MicroProfile Metrics REST.request metrics +metrics.rest-request.enabled=true diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/openapi.yml b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/openapi.yml new file mode 100644 index 00000000000..7b12d6890a4 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/META-INF/openapi.yml @@ -0,0 +1,36 @@ +openapi: 3.0.0 +info: + description: "This spec is mainly for testing Petstore server and contains fake\ + \ endpoints, models. Please do not use this for any other purpose. For this sample,\ + \ you can use the api key `special-key` to test the authorization filters. Special\ + \ characters: \" \\" + license: + name: Apache-2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore + version: 1.0.0 +servers: +- url: http://petstore.helidon.io:8080/format +tags: +- description: Format tester + name: format +paths: + /format: + get: + operationId: simple + responses: + "200": + content: {} + description: success + tags: + - format + x-accepts: + - application/json +components: + schemas: + format_test: + properties: + byte: + format: byte + pattern: "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$" + type: string diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/logging.properties b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/logging.properties new file mode 100644 index 00000000000..c9bc271dee7 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/main/resources/logging.properties @@ -0,0 +1,18 @@ + +# Example Logging Configuration File +# For more information see $JAVA_HOME/jre/lib/logging.properties + +# Send messages to the console +handlers=java.util.logging.ConsoleHandler + +java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n + +# Global logging level. Can be overridden by specific loggers +.level=INFO + +# Component specific log levels +#io.helidon.webserver.level=INFO +#io.helidon.config.level=INFO +#io.helidon.security.level=INFO +#io.helidon.common.level=INFO +#io.netty.level=INFO diff --git a/samples/server/others/java-helidon-server/v4/mp-format-test/src/test/java/org/openapitools/server/model/FormatTestTest.java b/samples/server/others/java-helidon-server/v4/mp-format-test/src/test/java/org/openapitools/server/model/FormatTestTest.java new file mode 100644 index 00000000000..056d8bdb076 --- /dev/null +++ b/samples/server/others/java-helidon-server/v4/mp-format-test/src/test/java/org/openapitools/server/model/FormatTestTest.java @@ -0,0 +1,40 @@ +/* + * OpenAPI Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. For this sample, you can use the api key `special-key` to test the authorization filters. 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 com.fasterxml.jackson.annotation.JsonTypeName; +import org.junit.jupiter.api.Test; + +/** + * Model tests for FormatTest + */ +public class FormatTestTest { + private final FormatTest model = new FormatTest(); + + /** + * Model tests for FormatTest + */ + @Test + public void testFormatTest() { + // TODO: test FormatTest + } + + /** + * Test the property '_byte' + */ + @Test + public void _byteTest() { + // TODO: test _byte + } + +}