Skip to content

Commit

Permalink
add jakarta implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyro-Ing committed Dec 26, 2022
1 parent 701b295 commit 052511a
Show file tree
Hide file tree
Showing 72 changed files with 583 additions and 105 deletions.
5 changes: 5 additions & 0 deletions src/main/resources/handlebars/JavaInflector/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ package {{invokerPackage}};

import io.swagger.oas.inflector.models.RequestContext;
import io.swagger.oas.inflector.models.ResponseContext;
{{#jakarta}}
import jakarta.ws.rs.core.Response.Status;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.core.Response.Status;
{{/jakarta}}

import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}
{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}
4 changes: 2 additions & 2 deletions src/main/resources/handlebars/JavaInflector/web.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<servlet-name>swagger-inflector</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-name>{{#jakarta}}jakarta{{/jakarta}}javax{{^jakarta}}.ws.rs.Application</param-name>
<param-value>io.swagger.oas.inflector.OpenAPIInflector</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
Expand All @@ -21,4 +21,4 @@
<filter-name>CORSFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
</web-app>
10 changes: 8 additions & 2 deletions src/main/resources/handlebars/JavaJaxRS/ApiOriginFilter.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ package {{apiPackage}};

import java.io.IOException;

{{#jakarta}}
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletResponse;
{{/jakarta}}
{{^jakarta}}
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
{{/jakarta}}

{{>generatedAnnotation}}
public class ApiOriginFilter implements javax.servlet.Filter {
public class ApiOriginFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse res = (HttpServletResponse) response;
Expand All @@ -19,4 +25,4 @@ public class ApiOriginFilter implements javax.servlet.Filter {
public void destroy() {}

public void init(FilterConfig filterConfig) throws ServletException {}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package {{apiPackage}};

{{#jakarta}}
import jakarta.xml.bind.annotation.XmlTransient;

@jakarta.xml.bind.annotation.XmlRootElement
{{/jakarta}}
{{^jakarta}}
import javax.xml.bind.annotation.XmlTransient;

@javax.xml.bind.annotation.XmlRootElement
{{/jakarta}}
{{>generatedAnnotation}}
public class ApiResponseMessage {
public static final int ERROR = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;

{{#jakarta}}
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.UriInfo;
import jakarta.ws.rs.ext.Provider;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.Provider;
{{/jakarta}}
import org.joda.time.DateTime;
import java.util.List;

Expand Down Expand Up @@ -41,4 +52,4 @@ public class JodaDateTimeProvider extends PerRequestTypeInjectableProvider<Query
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ import com.sun.jersey.core.spi.component.ComponentContext;
import com.sun.jersey.spi.inject.Injectable;
import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider;

{{#jakarta}}
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.UriInfo;
import jakarta.ws.rs.ext.Provider;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.Provider;
{{/jakarta}}
import org.joda.time.LocalDate;
import java.util.List;

Expand Down Expand Up @@ -41,4 +52,4 @@ public class JodaLocalDateProvider extends PerRequestTypeInjectableProvider<Quer
}
};
}
}
}
14 changes: 14 additions & 0 deletions src/main/resources/handlebars/JavaJaxRS/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,27 @@ import java.io.InputStream;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;

{{#jakarta}}
import jakarta.servlet.ServletConfig;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
import jakarta.ws.rs.*;
{{/jakarta}}
{{^jakarta}}
import javax.servlet.ServletConfig;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*;
{{/jakarta}}
{{#useBeanValidation}}
{{#jakarta}}
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}

{{#apiBasePath}}@Path("/{{{apiBasePath}}}"){{/apiBasePath}}
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/handlebars/JavaJaxRS/apiService.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ import {{package}}.NotFoundException;

import java.io.InputStream;

{{#jakarta}}
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
{{/jakarta}}
{{#useBeanValidation}}
{{#jakarta}}
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
{{>generatedAnnotation}}
{{#operations}}
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/handlebars/JavaJaxRS/apiServiceImpl.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ import java.io.InputStream;

import org.glassfish.jersey.media.multipart.FormDataContentDisposition;

{{#jakarta}}
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
{{/jakarta}}
{{#useBeanValidation}}
{{#jakarta}}
import javax.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
{{>generatedAnnotation}}
{{#operations}}
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/handlebars/JavaJaxRS/bootstrap.mustache
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package {{apiPackage}};

{{#jakarta}}
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
{{/jakarta}}
{{^jakarta}}
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
{{/jakarta}}

{{#useOas2}}
import io.swagger.jaxrs.config.SwaggerContextService;
Expand Down Expand Up @@ -52,4 +60,4 @@ import io.swagger.v3.oas.annotations.info.License;
)
public class Bootstrap {
}
{{/useOas2}}
{{/useOas2}}
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package {{invokerPackage}};

{{#jakarta}}
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
{{/jakarta}}

@ApplicationPath("/")
public class RestApplication extends Application {
// Add implementation-specific details here
}
}
15 changes: 15 additions & 0 deletions src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@ package {{package}};
{{/imports}}
import {{package}}.{{classname}}Service;

{{#jakarta}}
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
{{/jakarta}}

{{#useOas2}}
import io.swagger.annotations.*;
Expand All @@ -32,7 +42,12 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.util.Map;
import java.util.List;
{{#useBeanValidation}}
{{#jakarta}}
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
@Path("/{{{baseName}}}")
@RequestScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ import java.util.List;

import java.io.InputStream;

{{#jakarta}}
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
{{/jakarta}}

{{>generatedAnnotation}}
{{#operations}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ import java.util.List;

import java.io.InputStream;

{{#jakarta}}
import jakarta.enterprise.context.RequestScoped;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
{{/jakarta}}
{{^jakarta}}
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
{{/jakarta}}

@RequestScoped
{{>generatedAnnotation}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}
{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ package {{package}};
{{#imports}}import {{import}};
{{/imports}}
{{#useBeanValidation}}
{{#jakarta}}
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
{{/x-is-composed-model}}
{{#models}}
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
{{/useOas2}}
import java.util.Objects;

{{#jakarta}}
import jakarta.xml.bind.annotation.*;
{{/jakarta}}
{{^jakarta}}
import javax.xml.bind.annotation.*;
{{/jakarta}}

{{#description}}{{#useOas2}}@ApiModel{{/useOas2}}{{^useOas2}}@Schema{{/useOas2}}(description = "{{{description}}}"){{/description}}

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@
{{#useBeanValidation}}
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>{{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}}</version>
<scope>provided</scope>
</dependency>
{{/useBeanValidation}}
Expand Down
Loading

0 comments on commit 052511a

Please sign in to comment.