Skip to content
Open
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
1 change: 1 addition & 0 deletions bin/configs/java-jersey2-8-oas2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ library: jersey2
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
withXml: true
artifactId: petstore-jersey2-java8
hideGenerationTimestamp: true
serverPort: "8082"
Expand Down
1 change: 1 addition & 0 deletions bin/configs/java-jersey2-8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ library: jersey2
inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
withXml: true
artifactId: petstore-openapi3-jersey2-java8
hideGenerationTimestamp: true
serverPort: "8082"
Expand Down
1 change: 1 addition & 0 deletions bin/configs/java-jersey3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ library: jersey3
inputSpec: modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
withXml: true
useBeanValidation: true
artifactId: petstore-jersey3
hideGenerationTimestamp: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -922,8 +923,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {

/**
* Select the Accept header's value from the given accepts array:
* if JSON exists in the given array, use it;
* otherwise use all of them (joining into a string)
* if JSON exists in the given array, makes sure there is only one entry of it.
*
* @param accepts The accepts array to select from
* @return The Accept header to use. If the given array is empty,
Expand All @@ -933,12 +933,19 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
if (accepts == null || accepts.length == 0) {
return null;
}
Set<String> acceptHeaders = new LinkedHashSet<>();
boolean foundJsonMime = false;
for (String accept : accepts) {
if (isJsonMime(accept)) {
return accept;
if (foundJsonMime) {
continue;
} else {
foundJsonMime = true;
}
}
acceptHeaders.add(accept);
}
return StringUtil.join(accepts, ",");
return StringUtil.join(acceptHeaders, ",");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ ext {
{{#useReflectionEqualsHashCode}}
commons_lang3_version = "3.17.0"
{{/useReflectionEqualsHashCode}}
{{#withXml}}
{{#useJakartaEe}}
jaxb_version = "4.0.6"
{{/useJakartaEe}}
{{^useJakartaEe}}
jaxb_version = "2.3.9"
{{/useJakartaEe}}
{{/withXml}}
}

dependencies {
Expand All @@ -142,6 +150,13 @@ dependencies {
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
{{#withXml}}
implementation "org.glassfish.jersey.media:jersey-media-jaxb:$jersey_version"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_databind_version"
if (JavaVersion.current().isJava11Compatible()) {
implementation "org.glassfish.jaxb:jaxb-runtime:$jaxb_version"
}
{{/withXml}}
{{#openApiNullable}}
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
{{/openApiNullable}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@
</plugins>
</build>
</profile>
{{#withXml}}
<profile>
<id>jaxb-runtime</id>
<activation>
<jdk>
[11,)
</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-version}</version>
</dependency>
</dependencies>
</profile>
{{/withXml}}
</profiles>

<dependencies>
Expand Down Expand Up @@ -332,6 +349,13 @@
<artifactId>jersey-media-jaxb</artifactId>
<version>${jersey-version}</version>
</dependency>
<!-- Also requires Jackson XML dataformat due to @JacksonXml*-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<!-- Jackson's databind and dataformat libraries seem to be released synchronously -->
<version>${jackson-databind-version}</version>
</dependency>
{{/withXml}}
{{#joda}}
<dependency>
Expand Down Expand Up @@ -411,10 +435,16 @@
{{#useJakartaEe}}
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
<beanvalidation-version>3.0.2</beanvalidation-version>
{{#withXml}}
<jaxb-version>4.0.6</jaxb-version>
{{/withXml}}
{{/useJakartaEe}}
{{^useJakartaEe}}
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<beanvalidation-version>2.0.2</beanvalidation-version>
{{#withXml}}
<jaxb-version>2.3.9</jaxb-version>
{{/withXml}}
{{/useJakartaEe}}
<junit-version>5.10.0</junit-version>
{{#hasHttpSignatureMethods}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -922,8 +923,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {

/**
* Select the Accept header's value from the given accepts array:
* if JSON exists in the given array, use it;
* otherwise use all of them (joining into a string)
* if JSON exists in the given array, makes sure there is only one entry of it.
*
* @param accepts The accepts array to select from
* @return The Accept header to use. If the given array is empty,
Expand All @@ -933,12 +933,19 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
if (accepts == null || accepts.length == 0) {
return null;
}
Set<String> acceptHeaders = new LinkedHashSet<>();
boolean foundJsonMime = false;
for (String accept : accepts) {
if (isJsonMime(accept)) {
return accept;
if (foundJsonMime) {
continue;
} else {
foundJsonMime = true;
}
}
acceptHeaders.add(accept);
}
return StringUtil.join(accepts, ",");
return StringUtil.join(acceptHeaders, ",");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ ext {
{{#useReflectionEqualsHashCode}}
commons_lang3_version = "3.17.0"
{{/useReflectionEqualsHashCode}}
{{#withXml}}
{{#useJakartaEe}}
jaxb_version = "4.0.6"
{{/useJakartaEe}}
{{^useJakartaEe}}
jaxb_version = "2.3.9"
{{/useJakartaEe}}
{{/withXml}}
}

dependencies {
Expand All @@ -132,6 +140,13 @@ dependencies {
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_databind_version"
{{#withXml}}
implementation "org.glassfish.jersey.media:jersey-media-jaxb:$jersey_version"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_databind_version"
if (JavaVersion.current().isJava11Compatible()) {
implementation "org.glassfish.jaxb:jaxb-runtime:$jaxb_version"
}
{{/withXml}}
{{#openApiNullable}}
implementation "org.openapitools:jackson-databind-nullable:$jackson_databind_nullable_version"
{{/openApiNullable}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,23 @@
</plugins>
</build>
</profile>
{{#withXml}}
<profile>
<id>jaxb-runtime</id>
<activation>
<jdk>
[11,)
</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb-version}</version>
</dependency>
</dependencies>
</profile>
{{/withXml}}
</profiles>

<dependencies>
Expand Down Expand Up @@ -332,6 +349,13 @@
<artifactId>jersey-media-jaxb</artifactId>
<version>${jersey-version}</version>
</dependency>
<!-- Also requires Jackson XML dataformat due to @JacksonXml*-annotations -->
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<!-- Jackson's databind and dataformat libraries seem to be released synchronously -->
<version>${jackson-databind-version}</version>
</dependency>
{{/withXml}}
{{#joda}}
<dependency>
Expand Down Expand Up @@ -411,10 +435,16 @@
{{#useJakartaEe}}
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
<beanvalidation-version>3.0.2</beanvalidation-version>
{{#withXml}}
<jaxb-version>4.0.6</jaxb-version>
{{/withXml}}
{{/useJakartaEe}}
{{^useJakartaEe}}
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<beanvalidation-version>2.0.2</beanvalidation-version>
{{#withXml}}
<jaxb-version>2.3.9</jaxb-version>
{{/withXml}}
{{/useJakartaEe}}
<junit-version>5.10.0</junit-version>
{{#hasHttpSignatureMethods}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -700,8 +701,7 @@ public boolean isJsonMime(String mime) {

/**
* Select the Accept header's value from the given accepts array:
* if JSON exists in the given array, use it;
* otherwise use all of them (joining into a string)
* if JSON exists in the given array, makes sure there is only one entry of it.
*
* @param accepts The accepts array to select from
* @return The Accept header to use. If the given array is empty,
Expand All @@ -711,12 +711,19 @@ public String selectHeaderAccept(String... accepts) {
if (accepts == null || accepts.length == 0) {
return null;
}
Set<String> acceptHeaders = new LinkedHashSet<>();
boolean foundJsonMime = false;
for (String accept : accepts) {
if (isJsonMime(accept)) {
return accept;
if (foundJsonMime) {
continue;
} else {
foundJsonMime = true;
}
}
acceptHeaders.add(accept);
}
return StringUtil.join(accepts, ",");
return StringUtil.join(acceptHeaders, ",");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -700,8 +701,7 @@ public boolean isJsonMime(String mime) {

/**
* Select the Accept header's value from the given accepts array:
* if JSON exists in the given array, use it;
* otherwise use all of them (joining into a string)
* if JSON exists in the given array, makes sure there is only one entry of it.
*
* @param accepts The accepts array to select from
* @return The Accept header to use. If the given array is empty,
Expand All @@ -711,12 +711,19 @@ public String selectHeaderAccept(String... accepts) {
if (accepts == null || accepts.length == 0) {
return null;
}
Set<String> acceptHeaders = new LinkedHashSet<>();
boolean foundJsonMime = false;
for (String accept : accepts) {
if (isJsonMime(accept)) {
return accept;
if (foundJsonMime) {
continue;
} else {
foundJsonMime = true;
}
}
acceptHeaders.add(accept);
}
return StringUtil.join(accepts, ",");
return StringUtil.join(acceptHeaders, ",");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
Expand Down Expand Up @@ -841,8 +842,7 @@ public boolean isJsonMime(String mime) {

/**
* Select the Accept header's value from the given accepts array:
* if JSON exists in the given array, use it;
* otherwise use all of them (joining into a string)
* if JSON exists in the given array, makes sure there is only one entry of it.
*
* @param accepts The accepts array to select from
* @return The Accept header to use. If the given array is empty,
Expand All @@ -852,12 +852,19 @@ public String selectHeaderAccept(String... accepts) {
if (accepts == null || accepts.length == 0) {
return null;
}
Set<String> acceptHeaders = new LinkedHashSet<>();
boolean foundJsonMime = false;
for (String accept : accepts) {
if (isJsonMime(accept)) {
return accept;
if (foundJsonMime) {
continue;
} else {
foundJsonMime = true;
}
}
acceptHeaders.add(accept);
}
return StringUtil.join(accepts, ",");
return StringUtil.join(acceptHeaders, ",");
}

/**
Expand Down
Loading
Loading