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
30 changes: 20 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.3</version>
<version>3.5.11</version>
<relativePath />
</parent>

<groupId>io.github.raduking</groupId>
<artifactId>openapi-offline-generator-plugin</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
<packaging>maven-plugin</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down Expand Up @@ -57,18 +57,21 @@

<swagger.jaxrs2.jakarta.version>2.2.41</swagger.jaxrs2.jakarta.version>
<springdoc.openapi.starter.webmvc.api.version>2.8.13</springdoc.openapi.starter.webmvc.api.version>
<apiphany.version>1.0.20</apiphany.version>
<apiphany.version>1.1.8</apiphany.version>
<therapi.runtime.javadoc.version>0.15.0</therapi.runtime.javadoc.version>

<!-- Here are vulnerable versions in parent updated to non-vulnerable ones -->

<!-- Publishing dependencies versions -->
<maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>
<central.publishing.maven.plugin.version>0.9.0</central.publishing.maven.plugin.version>

<!-- Other plugin versions -->
<maven.plugin.plugin.version>3.15.2</maven.plugin.plugin.version>
<spotless.maven.plugin.version>2.46.1</spotless.maven.plugin.version>
<org.eclipse.jdt.core.version>3.42.0</org.eclipse.jdt.core.version>
<eclipse.formatter.version>4.36</eclipse.formatter.version>
<spotless.maven.plugin.version>3.3.0</spotless.maven.plugin.version>
<org.eclipse.jdt.core.version>3.44.0</org.eclipse.jdt.core.version>
<eclipse.formatter.version>4.38</eclipse.formatter.version>
<code.format.version>1.0.0</code.format.version>

<!-- Jacoco arguments empty by default -->
<jacocoArgLine></jacocoArgLine>
Expand Down Expand Up @@ -369,15 +372,22 @@
<artifactId>org.eclipse.jdt.core</artifactId>
<version>${org.eclipse.jdt.core.version}</version>
</dependency>
<dependency>
<groupId>io.github.raduking</groupId>
<artifactId>code-format</artifactId>
<version>${code.format.version}</version>
</dependency>
</dependencies>
<configuration>
<java>
<eclipse>
<file>${project.basedir}/formatter/java-formatter.xml</file>
<file>java-code-style.xml</file>
<version>${eclipse.formatter.version}</version>
</eclipse>
<removeUnusedImports/>
<trimTrailingWhitespace/>
<removeUnusedImports />
<forbidWildcardImports />
<trimTrailingWhitespace />
<endWithNewline />
</java>
</configuration>
<executions>
Expand Down Expand Up @@ -480,7 +490,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.plugin.version}</version>
<version>${jacoco.maven.plugin.version}</version>
<reportSets>
<reportSet>
<reports>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/oogp/GeneratorException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.oogp;

import java.io.Serial;

/**
* Exception class for generator-related errors.
*
Expand All @@ -10,6 +12,7 @@ public class GeneratorException extends RuntimeException {
/**
* Serial version UID.
*/
@Serial
private static final long serialVersionUID = -4336559629781875288L;

/**
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/oogp/OpenApiGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.morphix.reflection.Constructors;
import org.oogp.jakarta.OpenApiSpecJakartaGenerator;
import org.oogp.spring.OpenApiSpecSpringDocGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Main class for OpenAPI generation used in the CLI mode.
Expand All @@ -16,11 +18,15 @@
*/
public class OpenApiGenerator {

/**
* Logger instance.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(OpenApiGenerator.class);

/**
* Main method.
*
* @param args the command line arguments
* @throws Exception in case of errors
*/
static void main(final String[] args) {
if (args.length != 1) {
Expand All @@ -36,7 +42,7 @@ static void main(final String[] args) {

generate(properties);
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("Error while generating OpenAPI specification", e);
System.exit(3);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ public static void generate(final GeneratorProperties properties) throws IOExcep

String outputFile = properties.getOutputFile();
File out = new File(outputFile);
out.getParentFile().mkdirs();
boolean created = out.getParentFile().mkdirs();
if (!created) {
// could not create directories, but maybe they already exist, log a warning just in case
LOGGER.warn("Could not create directories for output file: {}", out.getAbsolutePath());
}

ObjectMapper mapper = switch (outputFile) {
case String s when s.endsWith(".json") -> Json.mapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ public static void generate(final GeneratorProperties properties) throws IOExcep
addExtensions(openAPI, properties.getExtensions());

File out = new File(outputFile);
out.getParentFile().mkdirs();
boolean created = out.getParentFile().mkdirs();
if (!created) {
// could not create directories, but maybe they already exist, log a warning just in case
LOGGER.warn("Could not create directories for output file: {}", out.getAbsolutePath());
}

boolean isOpenapi31 = openApiResource.getSpringDocConfigProperties().isOpenapi31();
ObjectMapper mapper = switch (outputFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class OffsetDateTimeController implements OffsetDateTimeApi {

private static final Logger LOGGER = LoggerFactory.getLogger(OffsetDateTimeController.class);

private ObjectMapper objectMapper = new ObjectMapper();
private final ObjectMapper objectMapper = new ObjectMapper();

@Override
public ResponseEntity<Object> getObjectWithOffsetDateTime(final OffsetDateTime dateTime) {
Expand Down
Loading