Skip to content

Commit

Permalink
Fix import for spring boot 3 (#15949)
Browse files Browse the repository at this point in the history
* Fix import for spring boot 3 and add a test for optional generation

* Remove timestamp

* Add sample to github workflow
  • Loading branch information
MelleD committed Jul 1, 2023
1 parent 30c685e commit d6538e3
Show file tree
Hide file tree
Showing 29 changed files with 1,950 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/samples-spring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- samples/openapi3/client/petstore/spring-stubs-skip-default-interface
- samples/openapi3/client/petstore/spring-cloud-async
- samples/openapi3/client/petstore/spring-cloud-spring-pageable
- samples/openapi3/client/petstore/spring-cloud-3-with-optional.yaml
# servers
- samples/server/petstore/springboot
- samples/openapi3/server/petstore/springboot
Expand Down
14 changes: 14 additions & 0 deletions bin/configs/spring-cloud-3-with-optional.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
generatorName: spring
library: spring-cloud
outputDir: samples/openapi3/client/petstore/spring-cloud-3-with-optional
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
groupId: org.openapitools.openapi3
artifactId: spring-cloud-oas3
useSpringBoot3: "true"
dateLibrary: "java8"
useOptional: "true"
useSwaggerUI: "false"
hideGenerationTimestamp: "true"
documentationProvider: none
2 changes: 1 addition & 1 deletion bin/configs/spring-cloud-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ additionalProperties:
documentationProvider: springdoc
artifactId: spring-cloud-oas3
useSpringBoot3: "true"
interfaceOnly: "true"
interfaceOnly: "false"
singleContentTypes: "true"
hideGenerationTimestamp: "true"
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
{{#authMethods}}
{{#isOAuth}}
{{#useSpringBoot3}}
import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor;
{{/useSpringBoot3}}
{{^useSpringBoot3}}
import org.springframework.cloud.openfeign.security.OAuth2FeignRequestInterceptor;
{{/useSpringBoot3}}
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2ClientContext;
{{#isApplication}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
README.md
pom.xml
src/main/java/org/openapitools/api/PetApi.java
src/main/java/org/openapitools/api/PetApiClient.java
src/main/java/org/openapitools/api/StoreApi.java
src/main/java/org/openapitools/api/StoreApiClient.java
src/main/java/org/openapitools/api/UserApi.java
src/main/java/org/openapitools/api/UserApiClient.java
src/main/java/org/openapitools/configuration/ApiKeyRequestInterceptor.java
src/main/java/org/openapitools/configuration/ClientConfiguration.java
src/main/java/org/openapitools/model/Category.java
src/main/java/org/openapitools/model/ModelApiResponse.java
src/main/java/org/openapitools/model/Order.java
src/main/java/org/openapitools/model/Pet.java
src/main/java/org/openapitools/model/Tag.java
src/main/java/org/openapitools/model/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# spring-cloud-oas3

## Requirements

Building the API client library requires [Maven](https://maven.apache.org/) to be installed.

## Installation

To install the API client library to your local Maven repository, simply execute:

```shell
mvn install
```

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

```shell
mvn deploy
```

Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.

### Maven users

Add this dependency to your project's POM:

```xml
<dependency>
<groupId>org.openapitools.openapi3</groupId>
<artifactId>spring-cloud-oas3</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
```

### Gradle users

Add this dependency to your project's build file:

```groovy
compile "org.openapitools.openapi3:spring-cloud-oas3:1.0.0"
```

### Others

At first generate the JAR by executing:

mvn package

Then manually install the following JARs:

* target/spring-cloud-oas3-1.0.0.jar
* target/lib/*.jar
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools.openapi3</groupId>
<artifactId>spring-cloud-oas3</artifactId>
<packaging>jar</packaging>
<name>spring-cloud-oas3</name>
<version>1.0.0</version>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<repositories>
<repository>
<id>repository.spring.milestone</id>
<name>Spring Milestone Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>

<build>
<sourceDirectory>src/main/java</sourceDirectory>
</build>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>2022.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit d6538e3

Please sign in to comment.