Skip to content

Commit

Permalink
fix: remove default version from Maven Mojo, resolve deprecations
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <michael@xlate.io>
  • Loading branch information
MikeEdgar committed Jan 10, 2025
1 parent 17e92a6 commit 57c5bd5
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
import java.util.Set;
import java.util.stream.Stream;

import javax.inject.Inject;

import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
Expand Down Expand Up @@ -190,7 +191,7 @@ public class GenerateSchemaMojo extends AbstractMojo {
/**
* To specify a custom OpenAPI version.
*/
@Parameter(defaultValue = SmallRyeOASConfig.Defaults.VERSION, property = "openApiVersion")
@Parameter(property = "openApiVersion")
private String openApiVersion;

@Parameter(property = "infoTitle")
Expand Down Expand Up @@ -272,15 +273,18 @@ enum OutputFileFilter {
@Parameter(property = "outputFileTypeFilter", defaultValue = "ALL")
private String outputFileTypeFilter;

@Component
private MavenDependencyIndexCreator mavenDependencyIndexCreator;

@Component
MavenProjectHelper mavenProjectHelper;
private MavenProjectHelper mavenProjectHelper;

@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject mavenProject;

@Inject
public GenerateSchemaMojo(MavenProjectHelper helper, MavenDependencyIndexCreator indexCreator) {
mavenDependencyIndexCreator = indexCreator;
mavenProjectHelper = helper;
}

@Override
public void execute() throws MojoExecutionException {
if (!skip) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ void outputFileTypeFilter_Json(MavenExecutionResult result) throws IOException {
deleteDirectory(OUTPUT_FILE_TYPE_FILTER_GENERATION_PATH);
}

@MavenTest
void versionFromProperties(MavenExecutionResult result) throws IOException {

assertThat(result).isSuccessful();

testSchema(result, (schema) -> {
assertEquals("3.1.1", schema.getOpenapi());
});
}

private static final Path OUTPUT_FILE_TYPE_FILTER_GENERATION_PATH = Paths.get(System.getProperty("java.io.tmpdir"),
"smallrye-openapi", "maven-plugin", "it");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.smallrye.openapi.mavenplugin</groupId>
<artifactId>versionFromProperties</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<properties>
<infoTitle>Smallrye OpenAPI</infoTitle>
<infoVersion>2.1.15</infoVersion>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<goals>
<goal>generate-schema</goal>
</goals>
<configuration>
<infoTitle>${infoTitle}</infoTitle>
<infoVersion>${infoVersion}</infoVersion>
<encoding>UTF-8</encoding>
<configProperties>${basedir}/src/main/resources/application.properties</configProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
openapi: "3.0.3"
info:
x-custom-extension: My Custom Extension
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mp.openapi.extensions.smallrye.openapi=3.1.1

0 comments on commit 57c5bd5

Please sign in to comment.