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
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "DocRaptor Java",
"image": "mcr.microsoft.com/devcontainers/java:21",
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "21",
"jdkDistro": "tem",
"installGradle": "true",
"installMaven": "true",
"additionalVersions": "8"
},
"ghcr.io/devcontainers/features/git-lfs:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"vscjava.vscode-java-pack",
"vscjava.vscode-gradle",
"redhat.java"
],
"settings": {
"java.configuration.updateBuildConfiguration": "automatic",
"java.compile.nullAnalysis.mode": "automatic",
"java.configuration.runtimes": [
{
"name": "JavaSE-21",
"path": "/usr/lib/jvm/msopenjdk-21",
"default": true
},
{
"name": "JavaSE-1.8",
"path": "/usr/lib/jvm/msopenjdk-8"
}
]
}
}
},
"postCreateCommand": "echo 'Java 21:' && /usr/lib/jvm/msopenjdk-21/bin/java -version && echo 'Java 8:' && /usr/lib/jvm/msopenjdk-8/bin/java -version",
"remoteUser": "vscode"
}
10 changes: 7 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-J-Xss4m</arg><!-- Compiling the generated JSON.java file may require larger stack size. -->
</compilerArgs>
<release>21</release>
</configuration>
</plugin>

Expand Down Expand Up @@ -223,6 +222,11 @@
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>1.3.5</version>
</dependency>

<!-- @Nullable annotation -->
<dependency>
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/com/docraptor/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ public Authentication getAuthentication(String authName) {
*/
public void setUsername(String username) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setUsername(username);
if (auth instanceof HttpBasicAuth basicAuth) {
basicAuth.setUsername(username);
return;
}
}
Expand All @@ -252,8 +252,8 @@ public void setUsername(String username) {
*/
public void setPassword(String password) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setPassword(password);
if (auth instanceof HttpBasicAuth basicAuth) {
basicAuth.setPassword(password);
return;
}
}
Expand Down Expand Up @@ -391,11 +391,11 @@ public String formatDate(Date date) {
public String parameterToString(Object param) {
if (param == null) {
return "";
} else if (param instanceof Date) {
return formatDate((Date) param);
} else if (param instanceof Collection) {
} else if (param instanceof Date date) {
return formatDate(date);
} else if (param instanceof Collection<?> collection) {
StringBuilder b = new StringBuilder();
for(Object o : (Collection<?>)param) {
for(Object o : collection) {
if(b.length() > 0) {
b.append(',');
}
Expand Down Expand Up @@ -560,7 +560,7 @@ public Object serialize(Object obj, String contentType, Map<String, Object> form
FormDataMultiPart mp = new FormDataMultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if( param.getValue() instanceof List && !( ( List ) param.getValue() ).isEmpty()
&& ( ( List ) param.getValue() ).get( 0 ) instanceof File ) {
&& ( ( List ) param.getValue() ).getFirst() instanceof File ) {
@SuppressWarnings( "unchecked" )
List<File> files = ( List<File> ) param.getValue();
for( File file : files ) {
Expand Down Expand Up @@ -594,8 +594,7 @@ private String buildUrl(String path, List<Pair> queryParams, List<Pair> collecti
String baseURL;
if (serverIndex != null) {
if (serverIndex < 0 || serverIndex >= servers.size()) {
throw new ArrayIndexOutOfBoundsException(String.format(
"Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size()
throw new ArrayIndexOutOfBoundsException("Invalid index %d when selecting the host settings. Must be less than %d".formatted(serverIndex, servers.size()
));
}
baseURL = servers.get(serverIndex).URL(serverVariables);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/docraptor/RFC3339DateFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.fasterxml.jackson.databind.util.StdDateFormat;

import java.io.Serial;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
Expand All @@ -23,6 +24,7 @@
import java.util.TimeZone;

public class RFC3339DateFormat extends DateFormat {
@Serial
private static final long serialVersionUID = 1L;
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");

Expand Down