diff --git a/README.md b/README.md index 381f0cd..46db442 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,8 @@ By defining the `type` as `object` and using `allOf`, you achieve the same resul allOf: - $ref: '#/components/schemas/Skill' ``` - * `x-java-getter-annotations`: Can be used on any property of a Schema Type which is not just a reference to another type - * `x-java-setter-annotations`: Can be used on any property of a Schema Type which is not just a reference to another type + * `x-extra-annotation`: is built into the upstream and can be used on any property of a Schema Type which is not just a reference to another type + * `x-setter-extra-annotation`: is built into the upstream and can be used on any property of a Schema Type which is not just a reference to another type ## Usage diff --git a/additionalModelTypeAnnotations.mustache b/additionalModelTypeAnnotations.mustache deleted file mode 100644 index f4871c0..0000000 --- a/additionalModelTypeAnnotations.mustache +++ /dev/null @@ -1,2 +0,0 @@ -{{#additionalModelTypeAnnotations}}{{{.}}} -{{/additionalModelTypeAnnotations}} \ No newline at end of file diff --git a/api.mustache b/api.mustache deleted file mode 100644 index ffcfc87..0000000 --- a/api.mustache +++ /dev/null @@ -1,146 +0,0 @@ -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) ({{{generatorVersion}}}). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -import io.swagger.annotations.*; -{{#jdk8-no-delegate}} -{{#virtualService}} -import io.virtualan.annotation.ApiVirtual; -import io.virtualan.annotation.VirtualService; -{{/virtualService}} -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -{{/jdk8-no-delegate}} -import org.springframework.http.ResponseEntity; -{{#useBeanValidation}} -import org.springframework.validation.annotation.Validated; -{{/useBeanValidation}} -import org.springframework.data.domain.Pageable; -import org.springframework.web.bind.annotation.*; -{{#jdk8-no-delegate}} - {{^reactive}} -import org.springframework.web.context.request.NativeWebRequest; - {{/reactive}} -{{/jdk8-no-delegate}} -import org.springframework.web.multipart.MultipartFile; -{{#reactive}} -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import org.springframework.http.codec.multipart.Part; -{{/reactive}} -import springfox.documentation.annotations.ApiIgnore; - -{{#useBeanValidation}} -import javax.validation.Valid; -import javax.validation.constraints.*; -{{/useBeanValidation}} -import java.util.List; -import java.util.Map; -{{#jdk8-no-delegate}} -import java.util.Optional; -{{/jdk8-no-delegate}} -{{^jdk8-no-delegate}} - {{#useOptional}} -import java.util.Optional; - {{/useOptional}} -{{/jdk8-no-delegate}} -{{#async}} -import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; -{{/async}} -{{>generatedAnnotation}} -{{#useBeanValidation}} -@Validated -{{/useBeanValidation}} -@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") -{{#operations}} -{{#virtualService}} -@VirtualService -{{/virtualService}} -public interface {{classname}} { -{{#jdk8-default-interface}} - {{^isDelegate}} - {{^reactive}} - - default Optional getRequest() { - return Optional.empty(); - } - {{/reactive}} - {{/isDelegate}} - {{#isDelegate}} - - default {{classname}}Delegate getDelegate() { - return new {{classname}}Delegate() {}; - } - {{/isDelegate}} -{{/jdk8-default-interface}} -{{#operation}} - - /** - * {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}} - {{#notes}} - * {{.}} - {{/notes}} - * - {{#allParams}} - * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} - {{/allParams}} - * @return {{#responses}}{{message}} (status code {{code}}){{^-last}} - * or {{/-last}}{{/responses}} - {{#isDeprecated}} - * @deprecated - {{/isDeprecated}} - {{#externalDocs}} - * {{description}} - * @see {{summary}} Documentation - {{/externalDocs}} - */ - {{#virtualService}} - @ApiVirtual - {{/virtualService}} - @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { - {{#authMethods}}{{#isOAuth}}@Authorization(value = "{{name}}", scopes = { - {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}}, - {{/-last}}{{/scopes}} }){{^-last}},{{/-last}}{{/isOAuth}} - {{^isOAuth}}@Authorization(value = "{{name}}"){{^-last}},{{/-last}} - {{/isOAuth}}{{/authMethods}} }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) - @ApiResponses(value = { {{#responses}} - @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}} }) - {{#implicitHeaders}} - @ApiImplicitParams({ - {{#headerParams}} - {{>implicitHeader}} - {{/headerParams}} - }) - {{/implicitHeaders}} - @{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Mapping( - value = "{{{path}}}"{{#singleContentTypes}}{{#hasProduces}}, - produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}}, - consumes = "{{{vendorExtensions.x-contentType}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}, - produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}}, - consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}} - ) - {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},{{/-last}}{{#-last}}{{#reactive}}, {{/reactive}}{{/-last}}{{/allParams}}{{#reactive}}@ApiIgnore final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}}{{#unhandledException}} throws Exception{{/unhandledException}} { - {{#delegate-method}} - return {{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); - } - - // Override this method - {{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}@ApiIgnore final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} { - {{/delegate-method}} - {{^isDelegate}} - {{>methodBody}} - {{/isDelegate}} - {{#isDelegate}} - return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); - {{/isDelegate}} - }{{/jdk8-default-interface}} - -{{/operation}} -} -{{/operations}} diff --git a/apiController.mustache b/apiController.mustache deleted file mode 100644 index 0b9e652..0000000 --- a/apiController.mustache +++ /dev/null @@ -1,137 +0,0 @@ -package {{package}}; - -{{^jdk8}} -{{#imports}}import {{import}}; -{{/imports}} -import io.swagger.annotations.*; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -{{/jdk8}} -import org.springframework.stereotype.Controller; -{{^jdk8}} -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -{{/jdk8}} -import org.springframework.web.bind.annotation.RequestMapping; -{{^jdk8}} -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -{{/jdk8}} -{{^isDelegate}} -import org.springframework.web.context.request.NativeWebRequest; -{{/isDelegate}} -{{^jdk8}} -import org.springframework.web.multipart.MultipartFile; -import org.springframework.data.domain.Pageable; -import springfox.documentation.annotations.ApiIgnore; - - {{#useBeanValidation}} -import javax.validation.constraints.*; -import javax.validation.Valid; - {{/useBeanValidation}} -{{/jdk8}} -{{#jdk8}} -import java.util.Optional; -{{/jdk8}} -{{^jdk8}} -import java.util.List; -import java.util.Map; - {{#async}} -import java.util.concurrent.Callable; - {{/async}} -{{/jdk8}} -{{>generatedAnnotation}} -@Controller -{{=<% %>=}} -@RequestMapping("${openapi.<%title%>.base-path:<%>defaultBasePath%>}") -<%={{ }}=%> -{{#operations}} -public class {{classname}}Controller implements {{classname}} { -{{#isDelegate}} - - private final {{classname}}Delegate delegate; - - public {{classname}}Controller(@org.springframework.beans.factory.annotation.Autowired(required = false) {{classname}}Delegate delegate) { - {{#jdk8}} - this.delegate = Optional.ofNullable(delegate).orElse(new {{classname}}Delegate() {}); - } - - @Override - public {{classname}}Delegate getDelegate() { - return delegate; - } - {{/jdk8}} - {{^jdk8}} - this.delegate = delegate; - } - {{/jdk8}} -{{/isDelegate}} -{{^isDelegate}} - {{^reactive}} - - {{^jdk8}} - {{/jdk8}} - private final NativeWebRequest request; - - @org.springframework.beans.factory.annotation.Autowired - public {{classname}}Controller(NativeWebRequest request) { - this.request = request; - } - {{#jdk8}} - - @Override - public Optional getRequest() { - return Optional.ofNullable(request); - } - {{/jdk8}} - {{/reactive}} -{{/isDelegate}} - -{{^jdk8}} -{{#operation}} - /** - * {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}} - {{#notes}} - * {{.}} - {{/notes}} - * - {{#allParams}} - * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} - {{/allParams}} - * @return {{#responses}}{{message}} (status code {{code}}){{^-last}} - * or {{/-last}}{{/responses}} - {{#isDeprecated}} - * @deprecated - {{/isDeprecated}} - {{#externalDocs}} - * {{description}} - * @see {{summary}} Documentation - {{/externalDocs}} - * @see {{classname}}#{{operationId}} - */ - public {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},{{/-last}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}, @ApiIgnore final Pageable pageable{{/vendorExtensions.x-spring-paginated}}) { - {{^isDelegate}} - {{^async}} - {{>methodBody}} - {{/async}} - {{#async}} - return new CallablereturnTypes}}>>() { - @Override - public ResponseEntity<{{>returnTypes}}> call() { - {{>methodBody}} - } - }; - {{/async}} - {{/isDelegate}} - {{#isDelegate}} - return delegate.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#vendorExtensions.x-spring-paginated}}, pageable{{/vendorExtensions.x-spring-paginated}}); - {{/isDelegate}} - } - -{{/operation}} -{{/jdk8}} -} -{{/operations}} diff --git a/apiDelegate.mustache b/apiDelegate.mustache deleted file mode 100644 index 2e43536..0000000 --- a/apiDelegate.mustache +++ /dev/null @@ -1,80 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -import io.swagger.annotations.*; -import org.springframework.data.domain.Pageable; -{{#jdk8}} -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -{{/jdk8}} -import org.springframework.http.ResponseEntity; -{{#jdk8}} -import org.springframework.web.context.request.NativeWebRequest; -{{/jdk8}} -import org.springframework.web.multipart.MultipartFile; -{{#reactive}} -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import org.springframework.http.codec.multipart.Part; -{{/reactive}} - -import java.util.List; -import java.util.Map; -{{#jdk8}} -import java.util.Optional; -{{/jdk8}} -{{^jdk8}} - {{#useOptional}} -import java.util.Optional; - {{/useOptional}} -{{/jdk8}} -{{#async}} -import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; -{{/async}} - -{{#operations}} -/** - * A delegate to be called by the {@link {{classname}}Controller}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -{{>generatedAnnotation}} -public interface {{classname}}Delegate { -{{#jdk8-default-interface}} - - default Optional getRequest() { - return Optional.empty(); - } -{{/jdk8-default-interface}} - -{{#operation}} - /** - * {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}} - {{#notes}} - * {{.}} - {{/notes}} - * - {{#allParams}} - * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} - {{/allParams}} - * @return {{#responses}}{{message}} (status code {{code}}){{^-last}} - * or {{/-last}}{{/responses}} - {{#isDeprecated}} - * @deprecated - {{/isDeprecated}} - {{#externalDocs}} - * {{description}} - * @see {{summary}} Documentation - {{/externalDocs}} - * @see {{classname}}#{{operationId}} - */ - {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}}{{/isFile}} {{paramName}}{{^-last}}, - {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, - {{/hasParams}}ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}, final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}}{{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}} { - {{>methodBody}} - }{{/jdk8-default-interface}} - -{{/operation}} -} -{{/operations}} diff --git a/apiException.mustache b/apiException.mustache deleted file mode 100644 index 7425066..0000000 --- a/apiException.mustache +++ /dev/null @@ -1,32 +0,0 @@ -package {{apiPackage}}; - -/** - * The exception that can be used to store the HTTP status code returned by an API response. - */ -{{>generatedAnnotation}} -public class ApiException extends Exception { - - /** The HTTP status code. */ - private int code; - - /** - * Constructor. - * - * @param code The HTTP status code. - * @param msg The error message. - */ - public ApiException(int code, String msg) { - super(msg); - this.code = code; - } - - /** - * Get the HTTP status code. - * - * @return The HTTP status code. - */ - public int getCode() { - return code; - } - -} diff --git a/apiOriginFilter.mustache b/apiOriginFilter.mustache deleted file mode 100644 index 5cf72a7..0000000 --- a/apiOriginFilter.mustache +++ /dev/null @@ -1,27 +0,0 @@ -package {{apiPackage}}; - -import java.io.IOException; - -import javax.servlet.*; -import javax.servlet.http.HttpServletResponse; - -{{>generatedAnnotation}} -public class ApiOriginFilter implements javax.servlet.Filter { - @Override - 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); - } - - @Override - public void destroy() { - } - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } -} diff --git a/apiResponseMessage.mustache b/apiResponseMessage.mustache deleted file mode 100644 index 17b155f..0000000 --- a/apiResponseMessage.mustache +++ /dev/null @@ -1,69 +0,0 @@ -package {{apiPackage}}; - -import javax.xml.bind.annotation.XmlTransient; - -{{>generatedAnnotation}} -@javax.xml.bind.annotation.XmlRootElement -public class ApiResponseMessage { - public static final int ERROR = 1; - public static final int WARNING = 2; - public static final int INFO = 3; - public static final int OK = 4; - public static final int TOO_BUSY = 5; - - int code; - String type; - String message; - - public ApiResponseMessage(){} - - public ApiResponseMessage(int code, String message){ - this.code = code; - switch(code){ - case ERROR: - setType("error"); - break; - case WARNING: - setType("warning"); - break; - case INFO: - setType("info"); - break; - case OK: - setType("ok"); - break; - case TOO_BUSY: - setType("too busy"); - break; - default: - setType("unknown"); - break; - } - this.message = message; - } - - @XmlTransient - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/apiUtil.mustache b/apiUtil.mustache deleted file mode 100644 index 6608bdb..0000000 --- a/apiUtil.mustache +++ /dev/null @@ -1,34 +0,0 @@ -package {{apiPackage}}; - -{{#reactive}} -import java.nio.charset.StandardCharsets; -import org.springframework.core.io.buffer.DefaultDataBufferFactory; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; -{{/reactive}} -{{^reactive}} -import org.springframework.web.context.request.NativeWebRequest; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -{{/reactive}} - -public class ApiUtil { -{{^reactive}} - public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { - try { - HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class); - res.setCharacterEncoding("UTF-8"); - res.addHeader("Content-Type", contentType); - res.getWriter().print(example); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -{{/reactive}} -{{#reactive}} - public static Mono getExampleResponse(ServerWebExchange exchange, String example) { - return exchange.getResponse().writeWith(Mono.just(new DefaultDataBufferFactory().wrap(example.getBytes(StandardCharsets.UTF_8)))); - } -{{/reactive}} -} diff --git a/beanValidation.mustache b/beanValidation.mustache deleted file mode 100644 index 06199f2..0000000 --- a/beanValidation.mustache +++ /dev/null @@ -1,6 +0,0 @@ -{{#required}} - @NotNull -{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}} - @Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}} - @Valid{{/isPrimitiveType}}{{/isContainer}} -{{>beanValidationCore}} diff --git a/beanValidationCore.mustache b/beanValidationCore.mustache deleted file mode 100644 index cc39498..0000000 --- a/beanValidationCore.mustache +++ /dev/null @@ -1,24 +0,0 @@ -{{#pattern}}{{^isByteArray}}@Pattern(regexp="{{{pattern}}}") {{/isByteArray}}{{/pattern}}{{! -minLength && maxLength set -}}{{#minLength}}{{#maxLength}}@Size(min={{minLength}},max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! -minLength set, maxLength not -}}{{#minLength}}{{^maxLength}}@Size(min={{minLength}}) {{/maxLength}}{{/minLength}}{{! -minLength not set, maxLength set -}}{{^minLength}}{{#maxLength}}@Size(max={{maxLength}}) {{/maxLength}}{{/minLength}}{{! -@Size: minItems && maxItems set -}}{{#minItems}}{{#maxItems}}@Size(min={{minItems}},max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! -@Size: minItems set, maxItems not -}}{{#minItems}}{{^maxItems}}@Size(min={{minItems}}) {{/maxItems}}{{/minItems}}{{! -@Size: minItems not set && maxItems set -}}{{^minItems}}{{#maxItems}}@Size(max={{maxItems}}) {{/maxItems}}{{/minItems}}{{! -@Email: useBeanValidation set && isEmail && java8 set -}}{{#useBeanValidation}}{{#isEmail}}{{#java8}}@javax.validation.constraints.Email{{/java8}}{{/isEmail}}{{/useBeanValidation}}{{! -@Email: performBeanValidation set && isEmail && not java8 set -}}{{#performBeanValidation}}{{#isEmail}}{{^java8}}@org.hibernate.validator.constraints.Email{{/java8}}{{/isEmail}}{{/performBeanValidation}}{{! -check for integer or long / all others=decimal type with @Decimal* -isInteger set -}}{{#isInteger}}{{#minimum}}@Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}) {{/maximum}}{{/isInteger}}{{! -isLong set -}}{{#isLong}}{{#minimum}}@Min({{minimum}}L){{/minimum}}{{#maximum}} @Max({{maximum}}L) {{/maximum}}{{/isLong}}{{! -Not Integer, not Long => we have a decimal value! -}}{{^isInteger}}{{^isLong}}{{#minimum}}@DecimalMin({{#exclusiveMinimum}}value={{/exclusiveMinimum}}"{{minimum}}"{{#exclusiveMinimum}},inclusive=false{{/exclusiveMinimum}}){{/minimum}}{{#maximum}} @DecimalMax({{#exclusiveMaximum}}value={{/exclusiveMaximum}}"{{maximum}}"{{#exclusiveMaximum}},inclusive=false{{/exclusiveMaximum}}) {{/maximum}}{{/isLong}}{{/isInteger}} \ No newline at end of file diff --git a/beanValidationPathParams.mustache b/beanValidationPathParams.mustache deleted file mode 100644 index 051bd53..0000000 --- a/beanValidationPathParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}} \ No newline at end of file diff --git a/beanValidationQueryParams.mustache b/beanValidationQueryParams.mustache deleted file mode 100644 index 9cca8cb..0000000 --- a/beanValidationQueryParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#required}}@NotNull {{/required}}{{>beanValidationCore}} \ No newline at end of file diff --git a/bodyParams.mustache b/bodyParams.mustache deleted file mode 100644 index ebfaa14..0000000 --- a/bodyParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody{{^required}}(required = false){{/required}} {{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/cookieParams.mustache b/cookieParams.mustache deleted file mode 100644 index 6e11169..0000000 --- a/cookieParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isCookieParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @CookieValue("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isCookieParam}} \ No newline at end of file diff --git a/customInstantDeserializer.mustache b/customInstantDeserializer.mustache deleted file mode 100644 index da7b57a..0000000 --- a/customInstantDeserializer.mustache +++ /dev/null @@ -1,232 +0,0 @@ -package {{configPackage}}; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonTokenId; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; -import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; -import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; -import com.fasterxml.jackson.datatype.threetenbp.function.Function; -import org.threeten.bp.DateTimeException; -import org.threeten.bp.DateTimeUtils; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZoneId; -import org.threeten.bp.ZonedDateTime; -import org.threeten.bp.format.DateTimeFormatter; -import org.threeten.bp.temporal.Temporal; -import org.threeten.bp.temporal.TemporalAccessor; - -import java.io.IOException; -import java.math.BigDecimal; - -/** - * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. - * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. - * - * @author Nick Williams - */ -public class CustomInstantDeserializer - extends ThreeTenDateTimeDeserializerBase { - private static final long serialVersionUID = 1L; - - public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( - Instant.class, DateTimeFormatter.ISO_INSTANT, - new Function() { - @Override - public Instant apply(TemporalAccessor temporalAccessor) { - return Instant.from(temporalAccessor); - } - }, - new Function() { - @Override - public Instant apply(FromIntegerArguments a) { - return Instant.ofEpochMilli(a.value); - } - }, - new Function() { - @Override - public Instant apply(FromDecimalArguments a) { - return Instant.ofEpochSecond(a.integer, a.fraction); - } - }, - null - ); - - public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( - OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, - new Function() { - @Override - public OffsetDateTime apply(TemporalAccessor temporalAccessor) { - return OffsetDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromIntegerArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public OffsetDateTime apply(FromDecimalArguments a) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { - return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); - } - } - ); - - public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( - ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, - new Function() { - @Override - public ZonedDateTime apply(TemporalAccessor temporalAccessor) { - return ZonedDateTime.from(temporalAccessor); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromIntegerArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); - } - }, - new Function() { - @Override - public ZonedDateTime apply(FromDecimalArguments a) { - return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); - } - }, - new BiFunction() { - @Override - public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { - return zonedDateTime.withZoneSameInstant(zoneId); - } - } - ); - - protected final Function fromMilliseconds; - - protected final Function fromNanoseconds; - - protected final Function parsedToValue; - - protected final BiFunction adjust; - - protected CustomInstantDeserializer(Class supportedType, - DateTimeFormatter parser, - Function parsedToValue, - Function fromMilliseconds, - Function fromNanoseconds, - BiFunction adjust) { - super(supportedType, parser); - this.parsedToValue = parsedToValue; - this.fromMilliseconds = fromMilliseconds; - this.fromNanoseconds = fromNanoseconds; - this.adjust = adjust == null ? new BiFunction() { - @Override - public T apply(T t, ZoneId zoneId) { - return t; - } - } : adjust; - } - - @SuppressWarnings("unchecked") - protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { - super((Class) base.handledType(), f); - parsedToValue = base.parsedToValue; - fromMilliseconds = base.fromMilliseconds; - fromNanoseconds = base.fromNanoseconds; - adjust = base.adjust; - } - - @Override - protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { - if (dtf == _formatter) { - return this; - } - return new CustomInstantDeserializer(this, dtf); - } - - @Override - public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { - //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only - //string values have to be adjusted to the configured TZ. - switch (parser.getCurrentTokenId()) { - case JsonTokenId.ID_NUMBER_FLOAT: { - BigDecimal value = parser.getDecimalValue(); - long seconds = value.longValue(); - int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); - return fromNanoseconds.apply(new FromDecimalArguments( - seconds, nanoseconds, getZone(context))); - } - - case JsonTokenId.ID_NUMBER_INT: { - long timestamp = parser.getLongValue(); - if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { - return this.fromNanoseconds.apply(new FromDecimalArguments( - timestamp, 0, this.getZone(context) - )); - } - return this.fromMilliseconds.apply(new FromIntegerArguments( - timestamp, this.getZone(context) - )); - } - - case JsonTokenId.ID_STRING: { - String string = parser.getText().trim(); - if (string.length() == 0) { - return null; - } - if (string.endsWith("+0000")) { - string = string.substring(0, string.length() - 5) + "Z"; - } - T value; - try { - TemporalAccessor acc = _formatter.parse(string); - value = parsedToValue.apply(acc); - if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { - return adjust.apply(value, this.getZone(context)); - } - } catch (DateTimeException e) { - throw _peelDTE(e); - } - return value; - } - } - throw context.mappingException("Expected type float, integer, or string."); - } - - private ZoneId getZone(DeserializationContext context) { - // Instants are always in UTC, so don't waste compute cycles - return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); - } - - private static class FromIntegerArguments { - public final long value; - public final ZoneId zoneId; - - private FromIntegerArguments(long value, ZoneId zoneId) { - this.value = value; - this.zoneId = zoneId; - } - } - - private static class FromDecimalArguments { - public final long integer; - public final int fraction; - public final ZoneId zoneId; - - private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { - this.integer = integer; - this.fraction = fraction; - this.zoneId = zoneId; - } - } -} diff --git a/enumClass.mustache b/enumClass.mustache deleted file mode 100644 index c1d813a..0000000 --- a/enumClass.mustache +++ /dev/null @@ -1,50 +0,0 @@ - /** - * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} - */ - public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { - {{#gson}} - {{#allowableValues}} - {{#enumVars}} - @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) - {{{name}}}({{{value}}}){{^-last}}, - {{/-last}}{{#-last}};{{/-last}} - {{/enumVars}} - {{/allowableValues}} - {{/gson}} - {{^gson}} - {{#allowableValues}} - {{#enumVars}} - {{{name}}}({{{value}}}){{^-last}}, - {{/-last}}{{#-last}};{{/-last}} - {{/enumVars}} - {{/allowableValues}} - {{/gson}} - - private {{{dataType}}} value; - - {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{dataType}}} value) { - this.value = value; - } - - {{#jackson}} - @JsonValue - {{/jackson}} - public {{{dataType}}} getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) { - for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { - if (b.value.equals(value)) { - return b; - } - } - {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} - } - } diff --git a/enumOuterClass.mustache b/enumOuterClass.mustache deleted file mode 100644 index baa6d54..0000000 --- a/enumOuterClass.mustache +++ /dev/null @@ -1,48 +0,0 @@ -{{#jackson}} -import com.fasterxml.jackson.annotation.JsonCreator; -{{/jackson}} - -/** - * {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} - */ -public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { - {{#gson}} - {{#allowableValues}}{{#enumVars}} - @SerializedName({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) - {{{name}}}({{{value}}}){{^-last}}, - {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} - {{/gson}} - {{^gson}} - {{#allowableValues}}{{#enumVars}} - {{{name}}}({{{value}}}){{^-last}}, - {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} - {{/gson}} - - private {{{dataType}}} value; - - {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { - this.value = value; - } - - {{#jackson}} - @JsonValue - {{/jackson}} - public {{{dataType}}} getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) { - for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { - if (b.value.equals(value)) { - return b; - } - } - {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} - } -} diff --git a/exampleReturnTypes.mustache b/exampleReturnTypes.mustache deleted file mode 100644 index d13cee7..0000000 --- a/exampleReturnTypes.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#returnContainer}}{{#isMap}}Map{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/exampleString.mustache b/exampleString.mustache deleted file mode 100644 index 1f72a33..0000000 --- a/exampleString.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#lambdaSplitString}}{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{#lambdaTrimWhitespace}}{{{example}}}{{/lambdaTrimWhitespace}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}{{/lambdaSplitString}} \ No newline at end of file diff --git a/formParams.mustache b/formParams.mustache deleted file mode 100644 index 04564e1..0000000 --- a/formParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{baseName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/generatedAnnotation.mustache b/generatedAnnotation.mustache deleted file mode 100644 index 875d7b9..0000000 --- a/generatedAnnotation.mustache +++ /dev/null @@ -1 +0,0 @@ -@javax.annotation.Generated(value = "{{generatorClass}}"{{^hideGenerationTimestamp}}, date = "{{generatedDate}}"{{/hideGenerationTimestamp}}) \ No newline at end of file diff --git a/headerParams.mustache b/headerParams.mustache deleted file mode 100644 index a8bbef3..0000000 --- a/headerParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/homeController.mustache b/homeController.mustache deleted file mode 100644 index f909a15..0000000 --- a/homeController.mustache +++ /dev/null @@ -1,88 +0,0 @@ -package {{configPackage}}; - -{{^useSpringfox}} -import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.core.io.Resource; -{{/useSpringfox}} -import org.springframework.stereotype.Controller; -{{^useSpringfox}} -import org.springframework.util.StreamUtils; -import org.springframework.web.bind.annotation.GetMapping; -{{/useSpringfox}} -import org.springframework.web.bind.annotation.RequestMapping; -{{^useSpringfox}} -import org.springframework.web.bind.annotation.ResponseBody; -{{/useSpringfox}} -{{#reactive}} -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; -{{/reactive}} - -{{^useSpringfox}} -import java.io.IOException; -import java.io.InputStream; -{{/useSpringfox}} -{{#reactive}} -import java.net.URI; -{{/reactive}} -{{^useSpringfox}} -import java.nio.charset.Charset; -{{/useSpringfox}} -{{#reactive}} - -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -{{/reactive}} - -/** - * Home redirection to OpenAPI api documentation - */ -@Controller -public class HomeController { - -{{^useSpringfox}} - private static YAMLMapper yamlMapper = new YAMLMapper(); - - @Value("classpath:/openapi.yaml") - private Resource openapi; - - @Bean - public String openapiContent() throws IOException { - try(InputStream is = openapi.getInputStream()) { - return StreamUtils.copyToString(is, Charset.defaultCharset()); - } - } - - @GetMapping(value = "/openapi.yaml", produces = "application/vnd.oai.openapi") - @ResponseBody - public String openapiYaml() throws IOException { - return openapiContent(); - } - - @GetMapping(value = "/openapi.json", produces = "application/json") - @ResponseBody - public Object openapiJson() throws IOException { - return yamlMapper.readValue(openapiContent(), Object.class); - } - -{{/useSpringfox}} -{{#reactive}} - @Bean - RouterFunction index() { - return route( - GET("/"), - req -> ServerResponse.temporaryRedirect(URI.create("{{#useSpringfox}}swagger-ui.html{{/useSpringfox}}{{^useSpringfox}}swagger-ui/index.html?url=../openapi.json{{/useSpringfox}}")).build() - ); - } -{{/reactive}} -{{^reactive}} - @RequestMapping("/") - public String index() { - return "redirect:{{#useSpringfox}}swagger-ui.html{{/useSpringfox}}{{^useSpringfox}}swagger-ui/index.html?url=../openapi.json{{/useSpringfox}}"; - } -{{/reactive}} - - -} diff --git a/implicitHeader.mustache b/implicitHeader.mustache deleted file mode 100644 index cda039e..0000000 --- a/implicitHeader.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isHeaderParam}}@ApiImplicitParam(name = "{{{paramName}}}", value = "{{{description}}}", {{#required}}required=true,{{/required}} dataType = "{{{dataType}}}", paramType = "header"){{^-last}},{{/-last}}{{/isHeaderParam}} \ No newline at end of file diff --git a/jacksonConfiguration.mustache b/jacksonConfiguration.mustache deleted file mode 100644 index e96aa77..0000000 --- a/jacksonConfiguration.mustache +++ /dev/null @@ -1,23 +0,0 @@ -package {{configPackage}}; - -import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZonedDateTime; - -@Configuration -public class JacksonConfiguration { - - @Bean - @ConditionalOnMissingBean(ThreeTenModule.class) - ThreeTenModule threeTenModule() { - ThreeTenModule module = new ThreeTenModule(); - module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); - module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); - module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); - return module; - } -} diff --git a/libraries/spring-boot/README.mustache b/libraries/spring-boot/README.mustache deleted file mode 100644 index fdc8444..0000000 --- a/libraries/spring-boot/README.mustache +++ /dev/null @@ -1,60 +0,0 @@ -{{^interfaceOnly}}# OpenAPI generated server - -Spring Boot Server - - -## Overview -This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. -By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. -This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework. - -{{#useSpringfox}} -The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox) - -{{/useSpringfox}} -Start your server as a simple java application - -{{^reactive}} -You can view the api documentation in swagger-ui by pointing to -http://localhost:{{serverPort}}/ - -{{/reactive}} -Change default port value in application.properties{{/interfaceOnly}}{{#interfaceOnly}} -# OpenAPI generated API stub - -Spring Framework stub - - -## Overview -This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. -By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub. -This is an example of building API stub interfaces in Java using the Spring framework. - -The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints -by adding ```@Controller``` classes that implement the interface. Eg: -```java -@Controller -public class PetController implements PetApi { -// implement all PetApi methods -} -``` - -You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg: -```java -@FeignClient(name="pet", url="http://petstore.swagger.io/v2") -public interface PetClient extends PetApi { - -} -``` -{{/interfaceOnly}} -{{#virtualService}} - - -## Virtualan : - -You can view Virtualan UI by pointing to -http://localhost:80//virtualan-ui.html. - -How to use guide available in the Virtualan wiki -https://github.com/elan-venture/virtualan/wiki -{{/virtualService}} \ No newline at end of file diff --git a/libraries/spring-boot/RFC3339DateFormat.mustache b/libraries/spring-boot/RFC3339DateFormat.mustache deleted file mode 100644 index b1a5cb5..0000000 --- a/libraries/spring-boot/RFC3339DateFormat.mustache +++ /dev/null @@ -1,38 +0,0 @@ -package {{basePackage}}; - -import com.fasterxml.jackson.databind.util.StdDateFormat; - -import java.text.DateFormat; -import java.text.FieldPosition; -import java.text.ParsePosition; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; - -public class RFC3339DateFormat extends DateFormat { - private static final long serialVersionUID = 1L; - private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); - - private final StdDateFormat fmt = new StdDateFormat() - .withTimeZone(TIMEZONE_Z) - .withColonInTimeZone(true); - - public RFC3339DateFormat() { - this.calendar = new GregorianCalendar(); - } - - @Override - public Date parse(String source, ParsePosition pos) { - return fmt.parse(source, pos); - } - - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - return fmt.format(date, toAppendTo, fieldPosition); - } - - @Override - public Object clone() { - return this; - } -} \ No newline at end of file diff --git a/libraries/spring-boot/application.mustache b/libraries/spring-boot/application.mustache deleted file mode 100644 index b7fea3f..0000000 --- a/libraries/spring-boot/application.mustache +++ /dev/null @@ -1,12 +0,0 @@ -{{#useSpringfox}} -springfox.documentation.swagger.v2.path=/api-docs -{{/useSpringfox}} -server.port={{serverPort}} -spring.jackson.date-format={{basePackage}}.RFC3339DateFormat -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false -{{#virtualService}} -virtual.datasource.driver-class-name=org.hsqldb.jdbcDriver -virtual.datasource.jdbcurl=jdbc:hsqldb:mem:dataSource -virtual.datasource.username=sa -virtual.datasource.password= -{{/virtualService}} \ No newline at end of file diff --git a/libraries/spring-boot/defaultBasePath.mustache b/libraries/spring-boot/defaultBasePath.mustache deleted file mode 100644 index 3c7185b..0000000 --- a/libraries/spring-boot/defaultBasePath.mustache +++ /dev/null @@ -1 +0,0 @@ -{{contextPath}} \ No newline at end of file diff --git a/libraries/spring-boot/openapi2SpringBoot.mustache b/libraries/spring-boot/openapi2SpringBoot.mustache deleted file mode 100644 index 8180f6c..0000000 --- a/libraries/spring-boot/openapi2SpringBoot.mustache +++ /dev/null @@ -1,83 +0,0 @@ -package {{basePackage}}; - -import com.fasterxml.jackson.databind.Module; -{{#openApiNullable}} -import org.openapitools.jackson.nullable.JsonNullableModule; -{{/openApiNullable}} -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.ExitCodeGenerator; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -{{^reactive}} -import org.springframework.web.servlet.config.annotation.CorsRegistry; - {{^useSpringfox}} -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; - {{/useSpringfox}} -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - {{^java8}} -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - {{/java8}} -{{/reactive}} -{{#reactive}} -import org.springframework.web.reactive.config.CorsRegistry; - {{^useSpringfox}} -import org.springframework.web.reactive.config.ResourceHandlerRegistry; - {{/useSpringfox}} -import org.springframework.web.reactive.config.WebFluxConfigurer; -{{/reactive}} - -@SpringBootApplication -@ComponentScan(basePackages = {"{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"}) -public class OpenAPI2SpringBoot implements CommandLineRunner { - - @Override - public void run(String... arg0) throws Exception { - if (arg0.length > 0 && arg0[0].equals("exitcode")) { - throw new ExitException(); - } - } - - public static void main(String[] args) throws Exception { - new SpringApplication(OpenAPI2SpringBoot.class).run(args); - } - - static class ExitException extends RuntimeException implements ExitCodeGenerator { - private static final long serialVersionUID = 1L; - - @Override - public int getExitCode() { - return 10; - } - - } - - @Bean - public Web{{^reactive}}Mvc{{/reactive}}{{#reactive}}Flux{{/reactive}}Configurer webConfigurer() { - return new Web{{^reactive}}Mvc{{/reactive}}{{#reactive}}Flux{{/reactive}}Configurer{{^java8}}Adapter{{/java8}}() { - /*@Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOrigins("*") - .allowedMethods("*") - .allowedHeaders("Content-Type"); - }*/ -{{^useSpringfox}} - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); - } -{{/useSpringfox}} - }; - } - -{{#openApiNullable}} - @Bean - public Module jsonNullableModule() { - return new JsonNullableModule(); - } -{{/openApiNullable}} - -} diff --git a/libraries/spring-boot/pom.mustache b/libraries/spring-boot/pom.mustache deleted file mode 100644 index 25c4447..0000000 --- a/libraries/spring-boot/pom.mustache +++ /dev/null @@ -1,206 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - {{#useSpringfox}} - 2.9.2 - {{/useSpringfox}} - -{{#parentOverridden}} - - {{{parentGroupId}}} - {{{parentArtifactId}}} - {{{parentVersion}}} - -{{/parentOverridden}} -{{^parentOverridden}} - - org.springframework.boot - spring-boot-starter-parent - {{#java8}}2.3.3.RELEASE{{/java8}}{{^java8}}1.5.12.RELEASE{{/java8}} - -{{/parentOverridden}} - - src/main/java - {{^interfaceOnly}} - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - {{#apiFirst}} - - org.openapitools - openapi-generator-maven-plugin - {{{generatorVersion}}} - - - - generate - - - src/main/resources/openapi.yaml - spring - {{{apiPackage}}} - {{{modelPackage}}} - false - {{#modelNamePrefix}} - {{{.}}} - {{/modelNamePrefix}} - {{#modelNameSuffix}} - {{{.}}} - {{/modelNameSuffix}} - - {{#configOptions}} - <{{left}}>{{right}} - {{/configOptions}} - - - - - - {{/apiFirst}} - - {{/interfaceOnly}} - - - - org.springframework.boot - spring-boot-starter-web{{#reactive}}flux{{/reactive}} - - - org.springframework.data - spring-data-commons - - {{#useSpringfox}} - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - - javax.xml.bind - jaxb-api - 2.3.1 - - {{/useSpringfox}} - {{^useSpringfox}} - - io.springfox - springfox-swagger2 - 2.8.0 - - - org.webjars - swagger-ui - 3.14.2 - - - io.swagger - swagger-annotations - 1.5.14 - - - - com.google.code.findbugs - jsr305 - 3.0.2 - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - - {{/useSpringfox}} - {{#withXml}} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - - {{/withXml}} - {{#java8}} - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - {{/java8}} - {{#joda}} - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - {{/joda}} - {{#threetenbp}} - - com.github.joschi.jackson - jackson-datatype-threetenbp - 2.8.4 - - {{/threetenbp}} - {{#openApiNullable}} - - org.openapitools - jackson-databind-nullable - 0.2.1 - - {{/openApiNullable}} -{{#useBeanValidation}} - - - javax.validation - validation-api - -{{/useBeanValidation}} -{{#virtualService}} - - - io.virtualan - virtualan-plugin - 1.0.0 - - - - org.hsqldb - hsqldb - 2.3.2 - - - org.springframework.boot - spring-boot-starter-data-jpa - 1.5.9.RELEASE - - -{{/virtualService}} -{{#hateoas}} - - - org.springframework.boot - spring-boot-starter-hateoas - -{{/hateoas}} - - com.fasterxml.jackson.core - jackson-databind - - - diff --git a/libraries/spring-cloud/README.mustache b/libraries/spring-cloud/README.mustache deleted file mode 100644 index 3550f42..0000000 --- a/libraries/spring-cloud/README.mustache +++ /dev/null @@ -1,83 +0,0 @@ -{{^interfaceOnly}} -# {{artifactId}} - -## 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 - - {{{groupId}}} - {{{artifactId}}} - {{{artifactVersion}}} - compile - -``` - -### Gradle users - -Add this dependency to your project's build file: - -```groovy -compile "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}" -``` - -### Others - -At first generate the JAR by executing: - -mvn package - -Then manually install the following JARs: - -* target/{{{artifactId}}}-{{{artifactVersion}}}.jar -* target/lib/*.jar -{{/interfaceOnly}} -{{#interfaceOnly}} -# OpenAPI generated API stub - -Spring Framework stub - - -## Overview -This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. -By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub. -This is an example of building API stub interfaces in Java using the Spring framework. - -The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints -by adding ```@Controller``` classes that implement the interface. Eg: -```java -@Controller -public class PetController implements PetApi { -// implement all PetApi methods -} -``` - -You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg: -```java -@FeignClient(name="pet", url="http://petstore.swagger.io/v2") -public interface PetClient extends PetApi { - -} -``` -{{/interfaceOnly}} \ No newline at end of file diff --git a/libraries/spring-cloud/apiClient.mustache b/libraries/spring-cloud/apiClient.mustache deleted file mode 100644 index f00a6c3..0000000 --- a/libraries/spring-cloud/apiClient.mustache +++ /dev/null @@ -1,10 +0,0 @@ -package {{package}}; - -import org.springframework.cloud.openfeign.FeignClient; -import {{configPackage}}.ClientConfiguration; - -{{=<% %>=}} -@FeignClient(name="${<%classVarName%>.name:<%classVarName%>}", url="${<%classVarName%>.url:<%basePath%>}", configuration = ClientConfiguration.class) -<%={{ }}=%> -public interface {{classname}}Client extends {{classname}} { -} diff --git a/libraries/spring-cloud/apiKeyRequestInterceptor.mustache b/libraries/spring-cloud/apiKeyRequestInterceptor.mustache deleted file mode 100644 index a7835fc..0000000 --- a/libraries/spring-cloud/apiKeyRequestInterceptor.mustache +++ /dev/null @@ -1,31 +0,0 @@ -package {{configPackage}}; - -import feign.RequestInterceptor; -import feign.RequestTemplate; -import feign.Util; - - -public class ApiKeyRequestInterceptor implements RequestInterceptor { - private final String location; - private final String name; - private String value; - - public ApiKeyRequestInterceptor(String location, String name, String value) { - Util.checkNotNull(location, "location", new Object[0]); - Util.checkNotNull(name, "name", new Object[0]); - Util.checkNotNull(value, "value", new Object[0]); - this.location = location; - this.name = name; - this.value = value; - } - - @Override - public void apply(RequestTemplate requestTemplate) { - if(location.equals("header")) { - requestTemplate.header(name, value); - } else if(location.equals("query")) { - requestTemplate.query(name, value); - } - } - -} diff --git a/libraries/spring-cloud/clientConfiguration.mustache b/libraries/spring-cloud/clientConfiguration.mustache deleted file mode 100644 index 3d0ccc7..0000000 --- a/libraries/spring-cloud/clientConfiguration.mustache +++ /dev/null @@ -1,132 +0,0 @@ -package {{configPackage}}; - -{{#authMethods}} -{{#isBasic}} -import feign.auth.BasicAuthRequestInterceptor; -{{/isBasic}} -{{#-first}} -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -{{/-first}} -{{#isOAuth}} -import org.springframework.boot.context.properties.ConfigurationProperties; -{{/isOAuth}} -{{/authMethods}} -import org.springframework.boot.context.properties.EnableConfigurationProperties; -{{#authMethods}} -{{#-first}} -import org.springframework.context.annotation.Bean; -{{/-first}} -{{/authMethods}} -import org.springframework.context.annotation.Configuration; -{{#authMethods}} -{{#isOAuth}} -import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; -import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; -import org.springframework.security.oauth2.client.OAuth2ClientContext; -{{#isApplication}} -import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; -{{/isApplication}} -{{#isCode}} -import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails; -{{/isCode}} -{{#isImplicit}} -import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails; -{{/isImplicit}} -{{#isPassword}} -import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails; -{{/isPassword}} -{{/isOAuth}} -{{/authMethods}} - -@Configuration -@EnableConfigurationProperties -public class ClientConfiguration { - -{{#authMethods}} - {{#isBasic}} - @Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username:{{closebrace}}") - private String {{{name}}}Username; - - @Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.password:{{closebrace}}") - private String {{{name}}}Password; - - @Bean - @ConditionalOnProperty(name = "{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username") - public BasicAuthRequestInterceptor {{{name}}}RequestInterceptor() { - return new BasicAuthRequestInterceptor(this.{{{name}}}Username, this.{{{name}}}Password); - } - - {{/isBasic}} - {{#isApiKey}} - @Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.key:{{closebrace}}") - private String {{{name}}}Key; - - @Bean - @ConditionalOnProperty(name = "{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.key") - public ApiKeyRequestInterceptor {{{name}}}RequestInterceptor() { - return new ApiKeyRequestInterceptor({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{{keyParamName}}}", this.{{{name}}}Key); - } - - {{/isApiKey}} - {{#isOAuth}} - @Bean - @ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id") - public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor(OAuth2ClientContext oAuth2ClientContext) { - return new OAuth2FeignRequestInterceptor(oAuth2ClientContext, {{{name}}}ResourceDetails()); - } - - @Bean - @ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id") - public OAuth2ClientContext oAuth2ClientContext() { - return new DefaultOAuth2ClientContext(); - } - - {{#isCode}} - @Bean - @ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}") - public AuthorizationCodeResourceDetails {{{name}}}ResourceDetails() { - AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - details.setUserAuthorizationUri("{{{authorizationUrl}}}"); - return details; - } - - {{/isCode}} - {{#isPassword}} - @Bean - @ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}") - public ResourceOwnerPasswordResourceDetails {{{name}}}ResourceDetails() { - ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - return details; - } - - {{/isPassword}} - {{#isApplication}} - @Bean - @ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}") - public ClientCredentialsResourceDetails {{{name}}}ResourceDetails() { - ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - return details; - } - - {{/isApplication}} - {{#isImplicit}} - @Bean - @ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}") - public ImplicitResourceDetails {{{name}}}ResourceDetails() { - ImplicitResourceDetails details = new ImplicitResourceDetails(); - details.setUserAuthorizationUri("{{{authorizationUrl}}}"); - return details; - } - - {{/isImplicit}} - {{/isOAuth}} -{{/authMethods}} -} diff --git a/libraries/spring-cloud/formParams.mustache b/libraries/spring-cloud/formParams.mustache deleted file mode 100644 index cec76d9..0000000 --- a/libraries/spring-cloud/formParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isFormParam}}{{^isFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/isFile}}{{#isFile}}@ApiParam(value = "{{{description}}}") @RequestParam("{{baseName}}") {{#isArray}}List<{{/isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}} {{paramName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/libraries/spring-cloud/pom.mustache b/libraries/spring-cloud/pom.mustache deleted file mode 100644 index 3f35a15..0000000 --- a/libraries/spring-cloud/pom.mustache +++ /dev/null @@ -1,136 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - 1.5.18 - -{{#parentOverridden}} - - {{{parentGroupId}}} - {{{parentArtifactId}}} - {{{parentVersion}}} - -{{/parentOverridden}} -{{^parentOverridden}} - - org.springframework.boot - spring-boot-starter-parent - 2.0.5.RELEASE - -{{/parentOverridden}} - - src/main/java - - -{{^parentOverridden}} - - - - org.springframework.cloud - spring-cloud-starter-parent - Finchley.SR1 - pom - import - - - - -{{/parentOverridden}} - - - io.swagger - swagger-annotations -{{^parentOverridden}} - ${swagger-core-version} -{{/parentOverridden}} - - - - com.google.code.findbugs - jsr305 - 3.0.2 - - - org.springframework.cloud - spring-cloud-starter-openfeign - - - org.springframework.cloud - spring-cloud-starter-oauth2 - - {{#withXml}} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - - {{/withXml}} - {{#java8}} - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - {{/java8}} - {{#joda}} - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - {{/joda}} - {{#threetenbp}} - - com.github.joschi.jackson - jackson-datatype-threetenbp - {{^parentOverridden}} - 2.9.10 - {{/parentOverridden}} - - {{/threetenbp}} - {{#openApiNullable}} - - org.openapitools - jackson-databind-nullable - {{^parentOverridden}} - 0.1.0 - {{/parentOverridden}} - - {{/openApiNullable}} - - org.springframework.boot - spring-boot-starter-test - test - -{{#hateoas}} - - - org.springframework.boot - spring-boot-starter-hateoas - -{{/hateoas}} -{{#useBeanValidation}} - - org.hibernate.validator - hibernate-validator - {{^parentOverridden}} - 6.0.16.Final - {{/parentOverridden}} - -{{/useBeanValidation}} - - io.springfox - springfox-swagger2 - 2.8.0 - - - org.springframework.data - spring-data-commons - - - diff --git a/libraries/spring-mvc/README.mustache b/libraries/spring-mvc/README.mustache deleted file mode 100644 index d28df1b..0000000 --- a/libraries/spring-mvc/README.mustache +++ /dev/null @@ -1,14 +0,0 @@ -# OpenAPI generated server - -Spring MVC Server - - -## Overview -This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub. This is an example of building a OpenAPI-enabled server in Java using the Spring MVC framework. - -{{#useSpringfox}} -The underlying library integrating OpenAPI to Spring-MVC is [springfox](https://github.com/springfox/springfox) - -{{/useSpringfox}} -You can view the server in swagger-ui by pointing to -http://localhost:{{serverPort}}{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}/ \ No newline at end of file diff --git a/libraries/spring-mvc/RFC3339DateFormat.mustache b/libraries/spring-mvc/RFC3339DateFormat.mustache deleted file mode 100644 index 84897b7..0000000 --- a/libraries/spring-mvc/RFC3339DateFormat.mustache +++ /dev/null @@ -1,38 +0,0 @@ -package {{configPackage}}; - -import com.fasterxml.jackson.databind.util.StdDateFormat; - -import java.text.DateFormat; -import java.text.FieldPosition; -import java.text.ParsePosition; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; - -public class RFC3339DateFormat extends DateFormat { - private static final long serialVersionUID = 1L; - private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); - - private final StdDateFormat fmt = new StdDateFormat() - .withTimeZone(TIMEZONE_Z) - .withColonInTimeZone(true); - - public RFC3339DateFormat() { - this.calendar = new GregorianCalendar(); - } - - @Override - public Date parse(String source, ParsePosition pos) { - return fmt.parse(source, pos); - } - - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - return fmt.format(date, toAppendTo, fieldPosition); - } - - @Override - public Object clone() { - return this; - } -} \ No newline at end of file diff --git a/libraries/spring-mvc/application.mustache b/libraries/spring-mvc/application.mustache deleted file mode 100644 index 6721428..0000000 --- a/libraries/spring-mvc/application.mustache +++ /dev/null @@ -1,3 +0,0 @@ -{{#useSpringfox}} -springfox.documentation.swagger.v2.path=/api-docs -{{/useSpringfox}} diff --git a/libraries/spring-mvc/defaultBasePath.mustache b/libraries/spring-mvc/defaultBasePath.mustache deleted file mode 100644 index 35ec3b9..0000000 --- a/libraries/spring-mvc/defaultBasePath.mustache +++ /dev/null @@ -1 +0,0 @@ -/ \ No newline at end of file diff --git a/libraries/spring-mvc/openapiUiConfiguration.mustache b/libraries/spring-mvc/openapiUiConfiguration.mustache deleted file mode 100644 index 3b44ddf..0000000 --- a/libraries/spring-mvc/openapiUiConfiguration.mustache +++ /dev/null @@ -1,125 +0,0 @@ -package {{configPackage}}; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -{{#threetenbp}} -import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; -{{/threetenbp}} -{{#openApiNullable}} -import org.openapitools.jackson.nullable.JsonNullableModule; -{{/openApiNullable}} -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -{{#useSpringfox}} -import org.springframework.context.annotation.Import; -{{/useSpringfox}} -import org.springframework.context.annotation.Bean; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -{{#threetenbp}} -import org.threeten.bp.Instant; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.ZonedDateTime; -{{/threetenbp}} - -import org.springframework.web.method.support.HandlerMethodArgumentResolver; -import org.springframework.data.web.PageableHandlerMethodArgumentResolver; - -import java.util.List; - -{{>generatedAnnotation}} -@Configuration -@ComponentScan(basePackages = {"{{apiPackage}}", "{{configPackage}}"}) -@EnableWebMvc -@PropertySource("classpath:application.properties") -{{#useSpringfox}} -@Import(OpenAPIDocumentationConfig.class) -{{/useSpringfox}} -public class OpenAPIUiConfiguration extends WebMvcConfigurerAdapter { - private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; - - private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { - "classpath:/META-INF/resources/", "classpath:/resources/", - "classpath:/static/", "classpath:/public/" }; - - private static final String[] RESOURCE_LOCATIONS; - static { - RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length - + SERVLET_RESOURCE_LOCATIONS.length]; - System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0, - SERVLET_RESOURCE_LOCATIONS.length); - System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, - SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length); - } - - private static final String[] STATIC_INDEX_HTML_RESOURCES; - static { - STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length]; - for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) { - STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html"; - } - } - - @Override - public void addArgumentResolvers(List argumentResolvers) { - argumentResolvers.add(new PageableHandlerMethodArgumentResolver()); - super.addArgumentResolvers(argumentResolvers); - } - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - if (!registry.hasMappingForPattern("/webjars/**")) { - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - if (!registry.hasMappingForPattern("/**")) { - registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); - } - {{^useSpringfox}} - if (!registry.hasMappingForPattern("/swagger-ui/**")) { - registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/3.14.2/"); - } - {{/useSpringfox}} - } - - /*@Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOrigins("*") - .allowedMethods("*") - .allowedHeaders("Content-Type"); - }*/ - - @Bean - public Jackson2ObjectMapperBuilder builder() { - {{#threetenbp}} - ThreeTenModule module = new ThreeTenModule(); - module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT); - module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME); - module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); - {{/threetenbp}} - return new Jackson2ObjectMapperBuilder() - .indentOutput(true) - .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - {{#openApiNullable}}.modulesToInstall({{#threetenbp}}module, {{/threetenbp}}new JsonNullableModule()){{/openApiNullable}} - {{^openApiNullable}}{{#threetenbp}}.modulesToInstall(module){{/threetenbp}}{{/openApiNullable}} - .dateFormat(new RFC3339DateFormat()); - } - - @Override - public void configureMessageConverters(List> converters) { - converters.add(new MappingJackson2HttpMessageConverter(objectMapper())); - converters.add(new StringHttpMessageConverter()); - super.configureMessageConverters(converters); - } - - @Bean - public ObjectMapper objectMapper(){ - return builder().build(); - } -} diff --git a/libraries/spring-mvc/pom.mustache b/libraries/spring-mvc/pom.mustache deleted file mode 100644 index fbda18a..0000000 --- a/libraries/spring-mvc/pom.mustache +++ /dev/null @@ -1,298 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} -{{#parentOverridden}} - - {{{parentGroupId}}} - {{{parentArtifactId}}} - {{{parentVersion}}} - -{{/parentOverridden}} - - src/main/java - - - org.apache.maven.plugins - maven-war-plugin - 3.1.0 - - - maven-failsafe-plugin - 2.6 - - - - integration-test - verify - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty-version} - - - {{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} - - target/${project.artifactId}-${project.version} - 8079 - stopit - 10 - - {{serverPort}} - 60000 - - -{{#useBeanValidation}} - - - javax.validation - validation-api - ${beanvalidation-version} - - -{{/useBeanValidation}} - - - start-jetty - pre-integration-test - - start - - - 0 - true - - - - stop-jetty - post-integration-test - - stop - - - - - {{#apiFirst}} - - org.openapitools - openapi-generator-maven-plugin - {{{generatorVersion}}} - - - - generate - - - src/main/resources/openapi.yaml - spring - spring-mvc - {{{apiPackage}}} - {{{modelPackage}}} - false - {{#modelNamePrefix}} - {{{.}}} - {{/modelNamePrefix}} - {{#modelNameSuffix}} - {{{.}}} - {{/modelNameSuffix}} - - {{#configOptions}} - <{{left}}>{{right}} - {{/configOptions}} - - - - - - {{/apiFirst}} - - - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - - - - - org.springframework - spring-core - ${spring-version} - - - org.springframework - spring-webmvc - ${spring-version} - - - org.springframework - spring-web - ${spring-version} - - - javax.annotation - javax.annotation-api - 1.3.2 - - - javax.xml.bind - jaxb-api - 2.2.11 - - {{#useSpringfox}} - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - com.fasterxml.jackson.core - jackson-annotations - - - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - {{/useSpringfox}} - {{^useSpringfox}} - - io.springfox - springfox-swagger2 - ${springfox-version} - - - com.fasterxml.jackson.core - jackson-annotations - - - - - org.webjars - swagger-ui - 3.14.2 - - - io.swagger - swagger-annotations - 1.5.14 - - - - com.google.code.findbugs - jsr305 - 3.0.2 - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson-version} - - {{/useSpringfox}} - {{#withXml}} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - ${jackson-version} - - {{/withXml}} - {{#java8}} - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - ${jackson-version} - - {{/java8}} - {{#joda}} - - com.fasterxml.jackson.datatype - jackson-datatype-joda - ${jackson-version} - - {{/joda}} - {{#threetenbp}} - - com.github.joschi.jackson - jackson-datatype-threetenbp - ${jackson-threetenbp-version} - - {{/threetenbp}} - {{#openApiNullable}} - - org.openapitools - jackson-databind-nullable - ${jackson-databind-nullable-version} - - {{/openApiNullable}} - - junit - junit - ${junit-version} - test - - - javax.servlet - servlet-api - ${servlet-api-version} - -{{#useBeanValidation}} - - - javax.validation - validation-api - ${beanvalidation-version} - provided - -{{/useBeanValidation}} -{{#hateoas}} - - - org.springframework.hateoas - spring-hateoas - 1.0.1.RELEASE - -{{/hateoas}} - - org.springframework.data - spring-data-commons - 2.0.11.RELEASE - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-databind-version} - - - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - 9.2.15.v20160210 - 1.7.21 - 4.13.1 - 2.5 - 2.8.0 - 2.9.9 - 2.8.4 -{{#useBeanValidation}} - 1.1.0.Final -{{/useBeanValidation}} - 4.3.20.RELEASE - {{#openApiNullable}} - 0.2.1 - {{/openApiNullable}} - 2.9.8 - - diff --git a/libraries/spring-mvc/webApplication.mustache b/libraries/spring-mvc/webApplication.mustache deleted file mode 100644 index 2b16399..0000000 --- a/libraries/spring-mvc/webApplication.mustache +++ /dev/null @@ -1,22 +0,0 @@ -package {{configPackage}}; - -import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; - -{{>generatedAnnotation}} -public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer { - - @Override - protected Class[] getRootConfigClasses() { - return new Class[] { OpenAPIUiConfiguration.class }; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[] { WebMvcConfiguration.class }; - } - - @Override - protected String[] getServletMappings() { - return new String[] { "/" }; - } -} diff --git a/libraries/spring-mvc/webMvcConfiguration.mustache b/libraries/spring-mvc/webMvcConfiguration.mustache deleted file mode 100644 index d60c126..0000000 --- a/libraries/spring-mvc/webMvcConfiguration.mustache +++ /dev/null @@ -1,12 +0,0 @@ -package {{configPackage}}; - -import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; - -{{>generatedAnnotation}} -public class WebMvcConfiguration extends WebMvcConfigurationSupport { - @Override - public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { - configurer.enable(); - } -} diff --git a/methodBody.mustache b/methodBody.mustache deleted file mode 100644 index e71414e..0000000 --- a/methodBody.mustache +++ /dev/null @@ -1,52 +0,0 @@ -{{^reactive}} -{{#examples}} - {{#-first}} - {{#jdk8}} - {{#async}} -return CompletableFuture.supplyAsync(()-> { - {{/async}}getRequest().ifPresent(request -> { -{{#async}} {{/async}} {{/jdk8}}for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { - {{/-first}} -{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) { -{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} String exampleString = {{>exampleString}}; -{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} ApiUtil.setExampleResponse(request, "{{{contentType}}}", exampleString); -{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} break; -{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} } - {{#-last}} -{{#async}} {{/async}}{{^async}}{{#jdk8}} {{/jdk8}}{{/async}} } - {{#jdk8}} -{{#async}} {{/async}} }); - {{/jdk8}} -{{#async}} {{/async}} return new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}); - {{#jdk8}} - {{#async}} - }, Runnable::run); - {{/async}} - {{/jdk8}} - {{/-last}} -{{/examples}} -{{^examples}} -return {{#jdk8}}{{#async}}CompletableFuture.completedFuture({{/async}}{{/jdk8}}new ResponseEntity<>({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}){{#jdk8}}{{#async}}){{/async}}{{/jdk8}}; -{{/examples}} -{{/reactive}} -{{#reactive}} -Mono result = Mono.empty(); - {{#examples}} - {{#-first}} - exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}); - for (MediaType mediaType : exchange.getRequest().getHeaders().getAccept()) { - {{/-first}} - if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) { - String exampleString = {{>exampleString}}; - result = ApiUtil.getExampleResponse(exchange, exampleString); - break; - } - {{#-last}} - } - {{/-last}} - {{/examples}} -{{^examples}} - exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}}); -{{/examples}} - return result.then(Mono.empty()); -{{/reactive}} \ No newline at end of file diff --git a/model.mustache b/model.mustache deleted file mode 100644 index fbe3a9f..0000000 --- a/model.mustache +++ /dev/null @@ -1,41 +0,0 @@ -package {{package}}; - -import java.util.Objects; -{{#imports}}import {{import}}; -{{/imports}} -import org.openapitools.jackson.nullable.JsonNullable; -{{#serializableModel}} -import java.io.Serializable; -{{/serializableModel}} -{{#useBeanValidation}} -import javax.validation.Valid; -import javax.validation.constraints.*; -{{/useBeanValidation}} -{{#performBeanValidation}} -import org.hibernate.validator.constraints.*; -{{/performBeanValidation}} -{{#jackson}} -{{#withXml}} -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -{{/withXml}} -{{/jackson}} -{{#withXml}} -import javax.xml.bind.annotation.*; -{{/withXml}} -{{^parent}} -{{#hateoas}} -import org.springframework.hateoas.RepresentationModel; -{{/hateoas}} -{{/parent}} - -{{#models}} -{{#model}} -{{#isEnum}} -{{>enumOuterClass}} -{{/isEnum}} -{{^isEnum}} -{{>pojo}} -{{/isEnum}} -{{/model}} -{{/models}} diff --git a/notFoundException.mustache b/notFoundException.mustache deleted file mode 100644 index 40c25c5..0000000 --- a/notFoundException.mustache +++ /dev/null @@ -1,10 +0,0 @@ -package {{apiPackage}}; - -{{>generatedAnnotation}} -public class NotFoundException extends ApiException { - private int code; - public NotFoundException (int code, String msg) { - super(code, msg); - this.code = code; - } -} diff --git a/nullableDataType.mustache b/nullableDataType.mustache deleted file mode 100644 index ba9bb94..0000000 --- a/nullableDataType.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#openApiNullable}}{{#isNullable}}JsonNullable<{{{datatypeWithEnum}}}>{{/isNullable}}{{^isNullable}}{{{datatypeWithEnum}}}{{/isNullable}}{{/openApiNullable}}{{^openApiNullable}}{{{datatypeWithEnum}}}{{/openApiNullable}} \ No newline at end of file diff --git a/openapi.mustache b/openapi.mustache deleted file mode 100644 index 51ebafb..0000000 --- a/openapi.mustache +++ /dev/null @@ -1 +0,0 @@ -{{{openapi-yaml}}} \ No newline at end of file diff --git a/openapiDocumentationConfig.mustache b/openapiDocumentationConfig.mustache deleted file mode 100644 index 7dd911a..0000000 --- a/openapiDocumentationConfig.mustache +++ /dev/null @@ -1,88 +0,0 @@ -package {{configPackage}}; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.springframework.web.util.UriComponentsBuilder; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.paths.Paths; -import springfox.documentation.spring.web.paths.RelativePathProvider; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -{{#useOptional}} -import java.util.Optional; -{{/useOptional}} -import javax.servlet.ServletContext; - -{{>generatedAnnotation}} -@Configuration -@EnableSwagger2 -public class OpenAPIDocumentationConfig { - - ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("{{appName}}") - .description("{{{appDescription}}}") - .license("{{licenseInfo}}") - .licenseUrl("{{licenseUrl}}") - .termsOfServiceUrl("{{infoUrl}}") - .version("{{appVersion}}") - .contact(new Contact("","", "{{infoEmail}}")) - .build(); - } - - @Bean -{{=<% %>=}} - public Docket customImplementation(ServletContext servletContext, @Value("${openapi.<%title%>.base-path:<%>defaultBasePath%>}") String basePath) { -<%={{ }}=%> - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("{{apiPackage}}")) - .build() - {{#java8}} - .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath)) - .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class) - {{/java8}} - {{#joda}} - .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) - {{/joda}} - {{#threetenbp}} - .directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class) - .directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class) - {{/threetenbp}} - {{#useOptional}} - .genericModelSubstitutes(Optional.class) - {{/useOptional}} - .apiInfo(apiInfo()); - } - - class BasePathAwareRelativePathProvider extends RelativePathProvider { - private String basePath; - - public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) { - super(servletContext); - this.basePath = basePath; - } - - @Override - protected String applicationPath() { - return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()); - } - - @Override - public String getOperationPath(String operationPath) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/"); - return Paths.removeAdjacentForwardSlashes( - uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString()); - } - } - -} diff --git a/optionalDataType.mustache b/optionalDataType.mustache deleted file mode 100644 index 976950e..0000000 --- a/optionalDataType.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#useOptional}}{{#required}}{{{dataType}}}{{/required}}{{^required}}Optional<{{{dataType}}}>{{/required}}{{/useOptional}}{{^useOptional}}{{{dataType}}}{{/useOptional}} \ No newline at end of file diff --git a/pathParams.mustache b/pathParams.mustache deleted file mode 100644 index d3c16fa..0000000 --- a/pathParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/pojo.mustache b/pojo.mustache index b998bc1..4b9800b 100644 --- a/pojo.mustache +++ b/pojo.mustache @@ -1,30 +1,47 @@ /** - * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} - */{{#description}} -@ApiModel(description = "{{{description}}}"){{/description}} -{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}{{>additionalModelTypeAnnotations}} + * {{description}}{{^description}}{{classname}}{{/description}} + */ +{{>additionalModelTypeAnnotations}} +{{#description}} +{{#swagger1AnnotationLibrary}} +@ApiModel(description = "{{{description}}}") +{{/swagger1AnnotationLibrary}} +{{#swagger2AnnotationLibrary}} +@Schema({{#name}}name = "{{name}}", {{/name}}description = "{{{description}}}") +{{/swagger2AnnotationLibrary}} +{{/description}} +{{#discriminator}} +{{>typeInfoAnnotation}} +{{/discriminator}} +{{#withXml}} +{{>xmlAnnotation}} +{{/withXml}} +{{>generatedAnnotation}} {{#vendorExtensions.x-java-class-annotations}} {{{.}}} {{/vendorExtensions.x-java-class-annotations}} -public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}}{{#hateoas}}extends RepresentationModel<{{classname}}> {{/hateoas}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { +public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{^parent}}{{#hateoas}}extends RepresentationModel<{{classname}}> {{/hateoas}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { {{#serializableModel}} - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; {{/serializableModel}} {{#vars}} + {{#isEnum}} {{^isContainer}} {{>enumClass}} {{/isContainer}} {{#isContainer}} - {{#mostInnerItems}} + {{#mostInnerItems}} {{>enumClass}} {{/mostInnerItems}} {{/isContainer}} {{/isEnum}} {{#jackson}} - @JsonProperty("{{baseName}}"){{#withXml}} - @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"){{/withXml}} + @JsonProperty("{{baseName}}") + {{#withXml}} + @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}localName = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") + {{/withXml}} {{/jackson}} {{#gson}} @SerializedName("{{baseName}}") @@ -43,10 +60,10 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}} {{/isContainer}} {{^isContainer}} {{#isDate}} - @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE) + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) {{/isDate}} {{#isDateTime}} - @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME) + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) {{/isDateTime}} {{#openApiNullable}} private {{>nullableDataType}} {{name}}{{#isNullable}} = JsonNullable.undefined(){{/isNullable}}{{^isNullable}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/isNullable}}; @@ -55,9 +72,10 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}} private {{>nullableDataType}} {{name}}{{#isNullable}} = null{{/isNullable}}{{^isNullable}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/isNullable}}; {{/openApiNullable}} {{/isContainer}} - {{/vars}} {{#vars}} + + {{! begin feature: fluent setter methods }} public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { {{#openApiNullable}} this.{{name}} = {{#isNullable}}JsonNullable.of({{name}}){{/isNullable}}{{^isNullable}}{{name}}{{/isNullable}}; @@ -99,40 +117,47 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}} return this; } {{/isMap}} + {{! end feature: fluent setter methods }} + {{! begin feature: getter and setter }} /** {{#description}} - * {{{description}}} + * {{{.}}} {{/description}} {{^description}} * Get {{name}} {{/description}} {{#minimum}} - * minimum: {{minimum}} + * minimum: {{.}} {{/minimum}} {{#maximum}} - * maximum: {{maximum}} + * maximum: {{.}} {{/maximum}} * @return {{name}} */ - {{#vendorExtensions.x-java-getter-annotations}} - {{{.}}} - {{/vendorExtensions.x-java-getter-annotations}} - {{#vendorExtensions.x-extra-annotation}} + {{#vendorExtensions.x-extra-annotation}} {{{vendorExtensions.x-extra-annotation}}} {{/vendorExtensions.x-extra-annotation}} - @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{>nullableDataType}} {{getter}}() { + {{#useBeanValidation}} + {{>beanValidation}} + {{/useBeanValidation}} + {{#swagger2AnnotationLibrary}} + @Schema(name = "{{{baseName}}}", {{#isReadOnly}}accessMode = Schema.AccessMode.READ_ONLY, {{/isReadOnly}}{{#example}}example = "{{{.}}}", {{/example}}{{#description}}description = "{{{.}}}", {{/description}}required = {{{required}}}) + {{/swagger2AnnotationLibrary}} + {{#swagger1AnnotationLibrary}} + @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}") + {{/swagger1AnnotationLibrary}} + public {{>nullableDataType}} {{getter}}() { return {{name}}; } - {{#vendorExtensions.x-java-setter-annotations}} - {{{.}}} - {{/vendorExtensions.x-java-setter-annotations}} + {{#vendorExtensions.x-setter-extra-annotation}} + {{{vendorExtensions.x-setter-extra-annotation}}} + {{/vendorExtensions.x-setter-extra-annotation}} public void {{setter}}({{>nullableDataType}} {{name}}) { this.{{name}} = {{name}}; } - + {{! end feature: getter and setter }} {{/vars}} @Override @@ -144,22 +169,35 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}}{{^parent}} return false; }{{#hasVars}} {{classname}} {{classVarName}} = ({{classname}}) o; - return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{^-last}} && + return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} && {{/-last}}{{/vars}}{{#parent}} && super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} return true;{{/hasVars}} - } + }{{#vendorExtensions.x-jackson-optional-nullable-helpers}} + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + }{{/vendorExtensions.x-jackson-optional-nullable-helpers}} @Override public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); - } + return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); + }{{#vendorExtensions.x-jackson-optional-nullable-helpers}} + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + }{{/vendorExtensions.x-jackson-optional-nullable-helpers}} @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class {{classname}} {\n"); - {{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}} + {{#parent}} + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + {{/parent}} {{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); {{/vars}}sb.append("}"); return sb.toString(); diff --git a/project/build.properties b/project/build.properties deleted file mode 100644 index a8c2f84..0000000 --- a/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=0.12.0 diff --git a/project/plugins.sbt b/project/plugins.sbt deleted file mode 100644 index 713b7f3..0000000 --- a/project/plugins.sbt +++ /dev/null @@ -1,9 +0,0 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.4") - -libraryDependencies <+= sbtVersion(v => v match { - case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8" - case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10" - case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11" - case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-0.2.11.1" - case x if (x.startsWith("0.12")) => "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1" -}) \ No newline at end of file diff --git a/queryParams.mustache b/queryParams.mustache deleted file mode 100644 index a22a836..0000000 --- a/queryParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue={{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}){{/isModel}}{{#isDate}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE){{/isDate}}{{#isDateTime}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME){{/isDateTime}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/returnTypes.mustache b/returnTypes.mustache deleted file mode 100644 index 0d2b380..0000000 --- a/returnTypes.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isMap}}Map{{/isMap}}{{#isArray}}{{#reactive}}Flux{{/reactive}}{{^reactive}}{{{returnContainer}}}{{/reactive}}<{{{returnType}}}>{{/isArray}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/typeInfoAnnotation.mustache b/typeInfoAnnotation.mustache deleted file mode 100644 index 81c2ba0..0000000 --- a/typeInfoAnnotation.mustache +++ /dev/null @@ -1,8 +0,0 @@ -{{#jackson}} - -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true) -@JsonSubTypes({ - {{#discriminator.mappedModels}} - @JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/discriminator.mappedModels}} -}){{/jackson}} diff --git a/xmlAnnotation.mustache b/xmlAnnotation.mustache deleted file mode 100644 index fd81a4c..0000000 --- a/xmlAnnotation.mustache +++ /dev/null @@ -1,6 +0,0 @@ -{{#withXml}} -{{#jackson}} -@JacksonXmlRootElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}") -{{/jackson}} -@XmlRootElement({{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}name = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}") -@XmlAccessorType(XmlAccessType.FIELD){{/withXml}} \ No newline at end of file