-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
feat(jaxrs-jersey): add jersey3-spring-boot4 library for Spring Boot … #23687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
MatteoMolinari93
wants to merge
1
commit into
OpenAPITools:master
from
MatteoMolinari93:claude/jersey3-spring-boot-4-dYgI2
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ator/src/main/resources/JavaJaxRS/libraries/jersey3-spring-boot4/ApiOriginFilter.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package {{apiPackage}}; | ||
|
|
||
| import java.io.IOException; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import {{javaxPackage}}.servlet.*; | ||
| import {{javaxPackage}}.servlet.http.HttpServletResponse; | ||
|
|
||
| {{>generatedAnnotation}} | ||
| @Component | ||
| public class ApiOriginFilter implements {{javaxPackage}}.servlet.Filter { | ||
|
|
||
| public void doFilter(ServletRequest request, ServletResponse response, | ||
| FilterChain chain) throws IOException, ServletException { | ||
| HttpServletResponse res = (HttpServletResponse) response; | ||
| res.addHeader("Access-Control-Allow-Origin", "*"); | ||
| res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); | ||
| res.addHeader("Access-Control-Allow-Headers", "Content-Type"); | ||
| chain.doFilter(request, response); | ||
| } | ||
|
|
||
| public void destroy() {} | ||
|
|
||
| public void init(FilterConfig filterConfig) throws ServletException {} | ||
| } |
15 changes: 15 additions & 0 deletions
15
...nerator/src/main/resources/JavaJaxRS/libraries/jersey3-spring-boot4/JerseyConfig.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package {{apiPackage}}; | ||
|
|
||
| import org.glassfish.jersey.media.multipart.MultiPartFeature; | ||
| import org.glassfish.jersey.server.ResourceConfig; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| {{>generatedAnnotation}} | ||
| @Component | ||
| public class JerseyConfig extends ResourceConfig { | ||
|
|
||
| public JerseyConfig() { | ||
| packages("{{apiPackage}}"); | ||
| register(MultiPartFeature.class); | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
...api-generator/src/main/resources/JavaJaxRS/libraries/jersey3-spring-boot4/README.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # JAX-RS/Jersey 3 server with Spring Boot 4 | ||
|
|
||
| ## Overview | ||
| This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using an | ||
| [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. | ||
|
|
||
| This example uses [Jersey 3](https://eclipse-ee4j.github.io/jersey/) as JAX-RS implementation embedded in | ||
| [Spring Boot 4](https://spring.io/projects/spring-boot) via `spring-boot-starter-jersey`. | ||
|
|
||
| ## Requirements | ||
| - Java 17+ | ||
| - Maven 3.6+ | ||
|
|
||
| ## Running the server | ||
|
|
||
| ``` | ||
| mvn clean package spring-boot:run | ||
| ``` | ||
|
|
||
| Or build a runnable JAR and execute it: | ||
|
|
||
| ``` | ||
| mvn clean package | ||
| java -jar target/{{artifactId}}-{{artifactVersion}}.jar | ||
| ``` | ||
|
|
||
| The server will start on port `{{serverPort}}` and serve requests at `{{contextPath}}`. | ||
|
|
||
| ## Implementing the API | ||
|
|
||
| Business logic is provided by implementing the `*Service` interfaces in `src/main/java`. The factory class | ||
| `*ServiceFactory` controls which implementation is loaded at startup. | ||
|
|
||
| ## CORS | ||
|
|
||
| CORS headers are added by `ApiOriginFilter`, which is registered as a Spring `@Component` and automatically | ||
| picked up by Spring Boot. Customize the allowed origins, methods, and headers directly in that class. |
19 changes: 19 additions & 0 deletions
19
...rc/main/resources/JavaJaxRS/libraries/jersey3-spring-boot4/SpringBootApplication.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package {{invokerPackage}}; | ||
|
|
||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| import org.springframework.context.annotation.ComponentScan; | ||
| import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator; | ||
|
|
||
| {{>generatedAnnotation}} | ||
| @SpringBootApplication(nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class) | ||
| @ComponentScan( | ||
| basePackages = {"{{invokerPackage}}", "{{apiPackage}}", "{{modelPackage}}"}, | ||
| nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class | ||
| ) | ||
| public class OpenApiGeneratorApplication { | ||
|
|
||
| public static void main(String[] args) { | ||
| SpringApplication.run(OpenApiGeneratorApplication.class, args); | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletions
3
...enerator/src/main/resources/JavaJaxRS/libraries/jersey3-spring-boot4/application.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| server.port={{serverPort}} | ||
| spring.jackson.serialization.write-dates-as-timestamps=false | ||
| spring.jersey.application-path={{contextPath}} |
112 changes: 112 additions & 0 deletions
112
...penapi-generator/src/main/resources/JavaJaxRS/libraries/jersey3-spring-boot4/pom.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| <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>{{groupId}}</groupId> | ||
| <artifactId>{{artifactId}}</artifactId> | ||
| <packaging>jar</packaging> | ||
| <name>{{artifactId}}</name> | ||
| <version>{{artifactVersion}}</version> | ||
|
|
||
| {{#parentOverridden}} | ||
| <parent> | ||
| <groupId>{{parentGroupId}}</groupId> | ||
| <artifactId>{{parentArtifactId}}</artifactId> | ||
| <version>{{parentVersion}}</version> | ||
| </parent> | ||
| {{/parentOverridden}} | ||
| {{^parentOverridden}} | ||
| <parent> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-parent</artifactId> | ||
| <version>4.0.1</version> | ||
| <relativePath/> | ||
| </parent> | ||
| {{/parentOverridden}} | ||
|
|
||
| <licenses> | ||
| <license> | ||
| <name>{{licenseName}}</name> | ||
| <url>{{licenseUrl}}</url> | ||
| <distribution>repo</distribution> | ||
| </license> | ||
| </licenses> | ||
| <build> | ||
| <sourceDirectory>src/main/java</sourceDirectory> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-maven-plugin</artifactId> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>build-helper-maven-plugin</artifactId> | ||
| <version>1.9.1</version> | ||
| <executions> | ||
| <execution> | ||
| <id>add-source</id> | ||
| <phase>generate-sources</phase> | ||
| <goals> | ||
| <goal>add-source</goal> | ||
| </goals> | ||
| <configuration> | ||
| <sources> | ||
| <source>src/gen/java</source> | ||
| </sources> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-jersey</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.swagger.core.v3</groupId> | ||
| <artifactId>swagger-annotations-jakarta</artifactId> | ||
| <version>${swagger-core-version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.datatype</groupId> | ||
| <artifactId>jackson-datatype-jsr310</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>jakarta.xml.bind</groupId> | ||
| <artifactId>jakarta.xml.bind-api</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.sun.xml.bind</groupId> | ||
| <artifactId>jaxb-impl</artifactId> | ||
| <version>4.0.3</version> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
| {{#useBeanValidation}} | ||
| <!-- Bean Validation API support --> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-validation</artifactId> | ||
| </dependency> | ||
| {{/useBeanValidation}} | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-test</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| <repositories> | ||
| <repository> | ||
| <id>sonatype-snapshots</id> | ||
| <url>https://oss.sonatype.org/content/repositories/snapshots</url> | ||
| <snapshots> | ||
| <enabled>true</enabled> | ||
| </snapshots> | ||
| </repository> | ||
| </repositories> | ||
| <properties> | ||
| <java.version>17</java.version> | ||
| <maven.compiler.release>${java.version}</maven.compiler.release> | ||
| <swagger-core-version>2.2.25</swagger-core-version> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
| </project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Unconditionally registering MultiPartFeature introduces a missing hard dependency on jersey-media-multipart in the generated Spring Boot 4 Jersey project.
Prompt for AI agents