Update tests for maven plugins (#16720)

* Fix swagger-annotations groupId in java examples

In Version 5.4.0 OpenApi-Generator has replaced the legacy library
which provided the `io.swagger.annotations.*` namespace (hosted at
https://mvnrepository.com/artifact/io.swagger/swagger-annotations)
with the updated project that provides `io.swagger.v3.oas.annotations.*`.

Hence, if you want to use OpenApi-Generator >= 5.4.0 you need this
package https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations
which is now reflected in these example files.

* Raise jackson-databind-nullable version in example to latest v0.2.6

* Update springfox dependency to v3.x in java examples

See https://github.com/springfox/springfox#migrating-from-existing-2x-version

* fix maven plugin spring tests

---------

Co-authored-by: Philzen <philzen@riseup.net>
This commit is contained in:
William Cheng 2023-10-04 15:59:12 +08:00 committed by GitHub
parent 11771a8ccf
commit f5f9a7e091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 130 additions and 125 deletions

View File

@ -94,7 +94,7 @@
<!-- dependencies are needed for the client being generated --> <!-- dependencies are needed for the client being generated -->
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version> <version>${swagger-annotations-version}</version>
</dependency> </dependency>
@ -191,11 +191,11 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-annotations-version>1.6.3</swagger-annotations-version> <swagger-annotations-version>2.2.16</swagger-annotations-version>
<jersey-version>2.35</jersey-version> <jersey-version>2.35</jersey-version>
<jackson-version>2.13.0</jackson-version> <jackson-version>2.13.0</jackson-version>
<jackson-databind-version>2.13.0</jackson-databind-version> <jackson-databind-version>2.13.0</jackson-databind-version>
<jackson-databind-nullable-version>0.2.1</jackson-databind-nullable-version> <jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version> <jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<junit-version>4.13.2</junit-version> <junit-version>4.13.2</junit-version>
<scribejava-apis-version>8.3.1</scribejava-apis-version> <scribejava-apis-version>8.3.1</scribejava-apis-version>

View File

@ -1,130 +1,135 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId> <groupId>org.openapitools</groupId>
<artifactId>sample-project</artifactId> <artifactId>sample-project</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<name>sample-project</name> <name>sample-project</name>
<url>https://maven.apache.org</url> <url>https://maven.apache.org</url>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.6</version> <version>2.7.6</version>
</parent> </parent>
<build> <build>
<plugins> <plugins>
<!-- activate the plugin --> <!-- activate the plugin -->
<plugin> <plugin>
<groupId>org.openapitools</groupId> <groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId> <artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION --> <!-- RELEASE_VERSION -->
<version>7.1.0-SNAPSHOT</version> <version>7.1.0-SNAPSHOT</version>
<!-- /RELEASE_VERSION --> <!-- /RELEASE_VERSION -->
<executions> <executions>
<execution> <execution>
<id>spring-server</id> <id>spring-server</id>
<goals> <goals>
<goal>generate</goal> <goal>generate</goal>
</goals> </goals>
<configuration> <configuration>
<!-- specify the swagger yaml --> <!-- specify the swagger yaml -->
<inputSpec>${project.basedir}/swagger.yaml</inputSpec> <inputSpec>${project.basedir}/swagger.yaml</inputSpec>
<!-- target to generate java server code --> <!-- target to generate java server code -->
<generatorName>spring</generatorName> <generatorName>spring</generatorName>
<!-- hint: if you want to generate java client code <!-- hint: if you want to generate java client code
you can use the following generator: <generatorName>java</generatorName> --> you can use the following generator: <generatorName>java</generatorName> -->
<!-- pass any necessary config options --> <!-- pass any necessary config options -->
<configOptions> <configOptions>
<documentationProvider>springfox</documentationProvider> <documentationProvider>springfox</documentationProvider>
<serializableModel>true</serializableModel> <serializableModel>true</serializableModel>
<snapshotVersion>true</snapshotVersion> <snapshotVersion>true</snapshotVersion>
</configOptions> </configOptions>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.11.0</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
<proc>none</proc> <proc>none</proc>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<pluginManagement> <pluginManagement>
</pluginManagement> </pluginManagement>
</build> </build>
<pluginRepositories> <pluginRepositories>
<pluginRepository> <pluginRepository>
<id>sonatype-snapshots</id> <id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url> <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository> </pluginRepository>
</pluginRepositories> </pluginRepositories>
<dependencies> <dependencies>
<!-- dependencies are needed for the client being generated --> <dependency>
<groupId>org.springframework.boot</groupId>
<dependency> <artifactId>spring-boot-starter-web</artifactId>
<groupId>io.swagger</groupId> </dependency>
<artifactId>swagger-annotations</artifactId> <dependency>
<version>${swagger-annotations-version}</version> <groupId>org.springframework.data</groupId>
</dependency> <artifactId>spring-data-commons</artifactId>
</dependency>
<!-- You can find the dependencies for the library configuration you chose by looking in JavaClientCodegen. <!--SpringFox dependencies -->
Then find the corresponding dependency on Maven Central, and set the versions in the property section below --> <dependency>
<groupId>io.springfox</groupId>
<dependency> <artifactId>springfox-swagger2</artifactId>
<groupId>org.springframework.boot</groupId> <version>${springfox.version}</version>
<artifactId>spring-boot-starter-web</artifactId> </dependency>
</dependency> <dependency>
<groupId>org.webjars</groupId>
<dependency> <artifactId>swagger-ui</artifactId>
<groupId>org.springframework.data</groupId> <version>${swagger-ui.version}</version>
<artifactId>spring-data-commons</artifactId> </dependency>
</dependency> <dependency>
<!--SpringFox dependencies --> <groupId>org.webjars</groupId>
<dependency> <artifactId>webjars-locator-core</artifactId>
<groupId>io.springfox</groupId> </dependency>
<artifactId>springfox-swagger2</artifactId> <!-- @Nullable annotation -->
<version>${springfox-version}</version> <dependency>
</dependency> <groupId>com.google.code.findbugs</groupId>
<dependency> <artifactId>jsr305</artifactId>
<groupId>io.springfox</groupId> <version>3.0.2</version>
<artifactId>springfox-swagger-ui</artifactId> </dependency>
<version>${springfox-version}</version> <dependency>
</dependency> <groupId>com.fasterxml.jackson.dataformat</groupId>
<dependency> <artifactId>jackson-dataformat-yaml</artifactId>
<groupId>javax.xml.bind</groupId> </dependency>
<artifactId>jaxb-api</artifactId> <dependency>
<version>2.2.11</version> <groupId>com.fasterxml.jackson.datatype</groupId>
</dependency> <artifactId>jackson-datatype-jsr310</artifactId>
<dependency> </dependency>
<groupId>com.fasterxml.jackson.datatype</groupId> <dependency>
<artifactId>jackson-datatype-jsr310</artifactId> <groupId>org.openapitools</groupId>
</dependency> <artifactId>jackson-databind-nullable</artifactId>
<dependency> <version>0.2.6</version>
<groupId>org.openapitools</groupId> </dependency>
<artifactId>jackson-databind-nullable</artifactId> <!-- Bean Validation API support -->
<version>0.1.0</version> <dependency>
</dependency> <groupId>org.springframework.boot</groupId>
<!-- Bean Validation API support --> <artifactId>spring-boot-starter-validation</artifactId>
<dependency> </dependency>
<groupId>javax.validation</groupId> <dependency>
<artifactId>validation-api</artifactId> <groupId>com.fasterxml.jackson.core</groupId>
</dependency> <artifactId>jackson-databind</artifactId>
</dependencies> </dependency>
<dependency>
<properties> <groupId>org.springframework.boot</groupId>
<swagger-annotations-version>1.5.8</swagger-annotations-version> <artifactId>spring-boot-starter-test</artifactId>
<springfox-version>2.8.0</springfox-version> <scope>test</scope>
</properties> </dependency>
</dependencies>
<properties>
<springfox.version>2.9.2</springfox.version>
<swagger-ui.version>4.15.5</swagger-ui.version>
</properties>
</project> </project>