diff --git a/pom.xml b/pom.xml index a1a366d5f4..6521b3fe4a 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ io.swagger.codegen.v3 swagger-codegen-generators - 1.0.12-SNAPSHOT + 1.0.13-SNAPSHOT jar @@ -246,10 +246,10 @@ - 3.0.12-SNAPSHOT - 2.0.15-SNAPSHOT - 2.0.9 - 2.9.9 + 3.0.12 + 2.0.15 + 2.0.10 + 2.9.10 2.11.1 3.3.0 2.4 diff --git a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java index c1ca4d44d4..b7db406665 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java +++ b/src/main/java/io/swagger/codegen/v3/generators/DefaultCodegenConfig.java @@ -4133,16 +4133,23 @@ else if (Parameter.StyleEnum.SPACEDELIMITED.equals(parameter.getStyle())) { } } - private boolean isObjectSchema (Schema schema) { + public boolean isObjectSchema (Schema schema) { if (schema instanceof ObjectSchema ||schema instanceof ComposedSchema) { return true; } - if (SchemaTypeUtil.OBJECT_TYPE.equals(schema.getType()) && !(schema instanceof MapSchema)) { + if (SchemaTypeUtil.OBJECT_TYPE.equalsIgnoreCase(schema.getType()) && !(schema instanceof MapSchema)) { return true; } if (schema.getType() == null && schema.getProperties() != null && !schema.getProperties().isEmpty()) { return true; } + if (StringUtils.isNotBlank(schema.get$ref())) { + Schema refSchema = OpenAPIUtil.getSchemaFromRefSchema(schema, openAPI); + if (refSchema != null) { + return isObjectSchema(refSchema); + } + } + return false; } diff --git a/src/main/java/io/swagger/codegen/v3/generators/SchemaHandler.java b/src/main/java/io/swagger/codegen/v3/generators/SchemaHandler.java index c4f41d5495..ebd15d4887 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/SchemaHandler.java +++ b/src/main/java/io/swagger/codegen/v3/generators/SchemaHandler.java @@ -184,8 +184,7 @@ private void configureModel(CodegenModel codegenModel, String name) { private boolean hasNonObjectSchema(List schemas) { for (Schema schema : schemas) { - boolean hasNonObjectSchema = (!(schema instanceof ObjectSchema)) || (schema.getProperties() != null && !schema.getProperties().isEmpty()); - if (hasNonObjectSchema) { + if (!codegenConfig.isObjectSchema(schema)) { return true; } } diff --git a/src/main/java/io/swagger/codegen/v3/generators/dotnet/AbstractCSharpCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/dotnet/AbstractCSharpCodegen.java index 9b294575dc..af10419d69 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/dotnet/AbstractCSharpCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/dotnet/AbstractCSharpCodegen.java @@ -15,6 +15,7 @@ import io.swagger.codegen.v3.generators.handlebars.lambda.TitlecaseLambda; import io.swagger.codegen.v3.generators.handlebars.lambda.UppercaseLambda; import io.swagger.codegen.v3.utils.ModelUtils; +import io.swagger.codegen.v3.utils.URLPathUtil; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.PathItem; @@ -33,6 +34,7 @@ import org.slf4j.LoggerFactory; import java.io.File; +import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -959,6 +961,18 @@ public void setPreserveNewLines(boolean preserveNewLines) { @Override public void preprocessOpenAPI(OpenAPI openAPI) { super.preprocessOpenAPI(openAPI); + + final URL urlInfo = URLPathUtil.getServerURL(openAPI); + if ( urlInfo != null && urlInfo.getPort() > 0) { + additionalProperties.put("serverUrl", String.format("%s://%s:%s", urlInfo.getProtocol(), urlInfo.getHost(), urlInfo.getPort())); + + if (StringUtils.isNotBlank(urlInfo.getPath())) { + additionalProperties.put("basePathWithoutHost", urlInfo.getPath()); + } + } else { + additionalProperties.put("serverUrl", URLPathUtil.LOCAL_HOST); + } + if (this.preserveNewLines) { Map schemaMap = openAPI.getComponents() != null ? openAPI.getComponents().getSchemas() : null; if (schemaMap != null) { @@ -1056,4 +1070,4 @@ public void postProcessParameter(CodegenParameter parameter) { } */ -} \ No newline at end of file +} diff --git a/src/main/java/io/swagger/codegen/v3/generators/dotnet/AspNetCoreServerCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/dotnet/AspNetCoreServerCodegen.java index 0254fcf77c..a4c28b3f64 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/dotnet/AspNetCoreServerCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/dotnet/AspNetCoreServerCodegen.java @@ -10,6 +10,7 @@ import io.swagger.codegen.v3.CodegenType; import io.swagger.codegen.v3.SupportingFile; import io.swagger.codegen.v3.generators.handlebars.ExtensionHelper; +import io.swagger.codegen.v3.utils.URLPathUtil; import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.security.SecurityScheme; @@ -18,6 +19,7 @@ import org.slf4j.LoggerFactory; import java.io.File; +import java.net.URL; import java.util.Arrays; import java.util.List; import java.util.Map; diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java index 4af00c1467..0cf6b86f51 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java @@ -376,7 +376,7 @@ public void processOpts() { } else { importMapping.put("Schema", "io.swagger.v3.oas.annotations.media.Schema"); } - + importMapping.put("JsonProperty", "com.fasterxml.jackson.annotation.JsonProperty"); importMapping.put("JsonSubTypes", "com.fasterxml.jackson.annotation.JsonSubTypes"); importMapping.put("JsonTypeInfo", "com.fasterxml.jackson.annotation.JsonTypeInfo"); @@ -398,7 +398,7 @@ public void processOpts() { if(additionalProperties.containsKey(JAVA8_MODE)) { setJava8Mode(Boolean.parseBoolean(additionalProperties.get(JAVA8_MODE).toString())); if ( java8Mode ) { - additionalProperties.put("java8", "true"); + additionalProperties.put("java8", true); } } @@ -427,7 +427,7 @@ public void processOpts() { importMapping.put("LocalDate", "org.joda.time.LocalDate"); importMapping.put("DateTime", "org.joda.time.DateTime"); } else if (dateLibrary.startsWith("java8")) { - additionalProperties.put("java8", "true"); + additionalProperties.put("java8", true); additionalProperties.put("jsr310", "true"); typeMapping.put("date", "LocalDate"); importMapping.put("LocalDate", "java.time.LocalDate"); @@ -439,7 +439,7 @@ public void processOpts() { importMapping.put("OffsetDateTime", "java.time.OffsetDateTime"); } } else if (dateLibrary.equals("legacy")) { - additionalProperties.put("legacyDates", "true"); + additionalProperties.put("legacyDates", true); } } @@ -947,7 +947,9 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert } if (model.discriminator != null && model.discriminator.getPropertyName().equals(property.baseName)) { property.vendorExtensions.put("x-is-discriminator-property", true); - model.imports.add("JsonTypeId"); + if (additionalProperties.containsKey("jackson")) { + model.imports.add("JsonTypeId"); + } } } @@ -1345,7 +1347,7 @@ private String deriveInvokerPackageName(String input) { public void setSupportJava6(boolean value) { this.supportJava6 = value; } - + public String toRegularExpression(String pattern) { return escapeText(pattern); } @@ -1401,7 +1403,7 @@ public void setLanguageArguments(List languageArguments) { .value(Boolean.FALSE.toString())); } } - + super.setLanguageArguments(languageArguments); } } diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaJAXRSServerCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaJAXRSServerCodegen.java index 2b623f2c0e..dc2fe3cfd4 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaJAXRSServerCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaJAXRSServerCodegen.java @@ -95,8 +95,8 @@ public void preprocessOpenAPI(OpenAPI openAPI) { if (!this.additionalProperties.containsKey("serverPort")) { final URL urlInfo = URLPathUtil.getServerURL(openAPI); String port = "8080"; // Default value for a JEE Server - if ( urlInfo != null && urlInfo.getPort() != 0) { - port = String.valueOf(urlInfo.getPort()); + if ( urlInfo != null && urlInfo.getPort() > 0) { + port = String.valueOf(urlInfo.getPort()); } this.additionalProperties.put("serverPort", port); } diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/JavaClientCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/JavaClientCodegen.java index c2b8fd9299..aa4e6c22cf 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/JavaClientCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/JavaClientCodegen.java @@ -83,16 +83,14 @@ public JavaClientCodegen() { cliOptions.add(CliOption.newBoolean(USE_GZIP_FEATURE, "Send gzip-encoded requests")); cliOptions.add(CliOption.newBoolean(USE_RUNTIME_EXCEPTION, "Use RuntimeException instead of Exception")); - supportedLibraries.put("jersey1", "HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.9.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'."); - supportedLibraries.put("feign", "HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.9.9"); - supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.9"); + supportedLibraries.put("jersey1", "HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.9.10. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'."); + supportedLibraries.put("feign", "HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.9.10"); + supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.10"); supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.8.1. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'."); supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead."); supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.8.0. JSON processing: Gson 2.6.1 (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)"); supportedLibraries.put("resttemplate", "HTTP client: Spring RestTemplate 4.3.9-RELEASE. JSON processing: Jackson 2.9.9"); supportedLibraries.put("resteasy", "HTTP client: Resteasy client 3.1.3.Final. JSON processing: Jackson 2.9.9"); - supportedLibraries.put("vertx", "HTTP client: VertX client 3.2.4. JSON processing: Jackson 2.9.9"); - supportedLibraries.put("google-api-client", "HTTP client: Google API client 1.23.0. JSON processing: Jackson 2.9.9"); CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); libraryOption.setEnum(supportedLibraries); @@ -187,14 +185,11 @@ public void processOpts() { supportingFiles.add(new SupportingFile("StringUtil.mustache", invokerFolder, "StringUtil.java")); } - // google-api-client doesn't use the Swagger auth, because it uses Google Credential directly (HttpRequestInitializer) - if (!"google-api-client".equals(getLibrary())) { + supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java")); + supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java")); + supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java")); + supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java")); - supportingFiles.add(new SupportingFile("auth/HttpBasicAuth.mustache", authFolder, "HttpBasicAuth.java")); - supportingFiles.add(new SupportingFile("auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java")); - supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java")); - supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java")); - } supportingFiles.add(new SupportingFile( "gradlew.mustache", "", "gradlew") ); supportingFiles.add(new SupportingFile( "gradlew.bat.mustache", "", "gradlew.bat") ); supportingFiles.add(new SupportingFile( "gradle-wrapper.properties.mustache", @@ -215,7 +210,7 @@ public void processOpts() { apiDocTemplateFiles.remove("api_doc.mustache"); } - if (!("feign".equals(getLibrary()) || "resttemplate".equals(getLibrary()) || usesAnyRetrofitLibrary() || "google-api-client".equals(getLibrary()))) { + if (!("feign".equals(getLibrary()) || "resttemplate".equals(getLibrary()) || usesAnyRetrofitLibrary())) { supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java")); supportingFiles.add(new SupportingFile("Configuration.mustache", invokerFolder, "Configuration.java")); supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java")); @@ -250,18 +245,6 @@ public void processOpts() { } else if("resttemplate".equals(getLibrary())) { additionalProperties.put("jackson", "true"); supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java")); - } else if("vertx".equals(getLibrary())) { - typeMapping.put("file", "AsyncFile"); - importMapping.put("AsyncFile", "io.vertx.core.file.AsyncFile"); - setJava8Mode(true); - additionalProperties.put("java8", "true"); - additionalProperties.put("jackson", "true"); - - apiTemplateFiles.put("apiImpl.mustache", "Impl.java"); - apiTemplateFiles.put("rxApiImpl.mustache", ".java"); - supportingFiles.remove(new SupportingFile("manifest.mustache", projectFolder, "AndroidManifest.xml")); - } else if ("google-api-client".equals(getLibrary())) { - additionalProperties.put("jackson", "true"); } else { LOGGER.error("Unknown library option (-l/--library): " + getLibrary()); } @@ -397,16 +380,7 @@ && getBooleanValue(another, CodegenConstants.IS_PATH_PARAM_EXT_NAME)){ @Override public String apiFilename(String templateName, String tag) { - if("vertx".equals(getLibrary())) { - String suffix = apiTemplateFiles().get(templateName); - String subFolder = ""; - if (templateName.startsWith("rx")) { - subFolder = "/rxjava"; - } - return apiFileFolder() + subFolder + '/' + toApiFilename(tag) + suffix; - } else { - return super.apiFilename(templateName, tag); - } + return super.apiFilename(templateName, tag); } /** @@ -547,7 +521,8 @@ protected List> modelInheritanceSupportInGson(List allMod } } List> parentsList = new ArrayList<>(); - for (CodegenModel parentModel : byParent.keySet()) { + for (Map.Entry> parentModelEntry : byParent.entrySet()) { + CodegenModel parentModel = parentModelEntry.getKey(); List> childrenList = new ArrayList<>(); Map parent = new HashMap<>(); parent.put("classname", parentModel.classname); @@ -566,6 +541,7 @@ protected List> modelInheritanceSupportInGson(List allMod } parentsList.add(parent); } + return parentsList; } diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/Spring2Codegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/Spring2Codegen.java deleted file mode 100644 index 7178d9aa98..0000000000 --- a/src/main/java/io/swagger/codegen/v3/generators/java/Spring2Codegen.java +++ /dev/null @@ -1,748 +0,0 @@ -package io.swagger.codegen.v3.generators.java; - -import com.samskivert.mustache.Mustache; -import com.samskivert.mustache.Template; -import io.swagger.codegen.v3.*; -import io.swagger.codegen.v3.generators.features.BeanValidationFeatures; -import io.swagger.codegen.v3.generators.features.OptionalFeatures; -import io.swagger.codegen.v3.utils.URLPathUtil; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.PathItem; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.io.Writer; -import java.net.URL; -import java.util.*; -import java.util.regex.Matcher; -import java.util.stream.Collectors; - -import static io.swagger.codegen.v3.CodegenConstants.HAS_ENUMS_EXT_NAME; -import static io.swagger.codegen.v3.CodegenConstants.IS_ENUM_EXT_NAME; -import static io.swagger.codegen.v3.generators.handlebars.ExtensionHelper.getBooleanValue; - -public class Spring2Codegen extends AbstractJavaCodegen implements BeanValidationFeatures, OptionalFeatures { - static Logger LOGGER = LoggerFactory.getLogger(Spring2Codegen.class); - public static final String DEFAULT_LIBRARY = "spring-boot"; - public static final String TITLE = "title"; - public static final String CONFIG_PACKAGE = "configPackage"; - public static final String BASE_PACKAGE = "basePackage"; - public static final String INTERFACE_ONLY = "interfaceOnly"; - public static final String DELEGATE_PATTERN = "delegatePattern"; - public static final String SINGLE_CONTENT_TYPES = "singleContentTypes"; - public static final String JAVA_8 = "java8"; - public static final String ASYNC = "async"; - public static final String RESPONSE_WRAPPER = "responseWrapper"; - public static final String USE_TAGS = "useTags"; - public static final String SPRING_MVC_LIBRARY = "spring-mvc"; - public static final String SPRING_CLOUD_LIBRARY = "spring-cloud"; - public static final String IMPLICIT_HEADERS = "implicitHeaders"; - public static final String SWAGGER_DOCKET_CONFIG = "swaggerDocketConfig"; - - protected String title = "swagger-petstore"; - protected String configPackage = "io.swagger.configuration"; - protected String basePackage = "io.swagger"; - protected boolean interfaceOnly = false; - protected boolean delegatePattern = false; - protected boolean delegateMethod = false; - protected boolean singleContentTypes = false; - protected boolean java8 = false; - protected boolean async = false; - protected String responseWrapper = ""; - protected boolean useTags = false; - protected boolean useBeanValidation = true; - protected boolean implicitHeaders = false; - protected boolean swaggerDocketConfig = false; - protected boolean useOptional = false; - - public Spring2Codegen() { - super(); - outputFolder = "generated-code/javaSpring2"; - apiPackage = "io.swagger.api"; - modelPackage = "io.swagger.model"; - invokerPackage = "io.swagger.api"; - artifactId = "swagger-spring2"; - - additionalProperties.put(CONFIG_PACKAGE, configPackage); - additionalProperties.put(BASE_PACKAGE, basePackage); - - // spring uses the jackson lib - additionalProperties.put("jackson", "true"); - - cliOptions.add(new CliOption(TITLE, "server title name or client service name")); - cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code")); - cliOptions.add(new CliOption(BASE_PACKAGE, "base package (invokerPackage) for generated code")); - cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.")); - cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern")); - cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation.")); - cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface")); - cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers")); - cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)")); - cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames")); - cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations")); - cliOptions.add(CliOption.newBoolean(IMPLICIT_HEADERS, "Use of @ApiImplicitParams for headers.")); - cliOptions.add(CliOption.newBoolean(SWAGGER_DOCKET_CONFIG, "Generate Spring Swagger Docket configuration class.")); - cliOptions.add(CliOption.newBoolean(USE_OPTIONAL, - "Use Optional container for optional parameters")); - - supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration."); - supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration."); - supportedLibraries.put(SPRING_CLOUD_LIBRARY, "Spring-Cloud-Feign client with Spring-Boot auto-configured settings."); - setLibrary(DEFAULT_LIBRARY); - - CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); - library.setDefault(DEFAULT_LIBRARY); - library.setEnum(supportedLibraries); - library.setDefault(DEFAULT_LIBRARY); - cliOptions.add(library); - } - - @Override - public CodegenType getTag() { - return CodegenType.SERVER; - } - - @Override - public String getName() { - return "spring2"; - } - - @Override - public String getHelp() { - return "Generates a Java SpringBoot Server application using the SpringFox integration."; - } - - @Override - public void processOpts() { - setUseOas2(true); - additionalProperties.put(CodegenConstants.USE_OAS2, true); - - // Process java8 option before common java ones to change the default dateLibrary to java8. - if (additionalProperties.containsKey(JAVA_8)) { - this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString())); - } - if (this.java8) { - additionalProperties.put("javaVersion", "1.8"); - additionalProperties.put("jdk8", "true"); - if (!additionalProperties.containsKey(DATE_LIBRARY)) { - setDateLibrary("java8"); - } - } - - // set invokerPackage as basePackage - if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { - this.setBasePackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); - additionalProperties.put(BASE_PACKAGE, basePackage); - LOGGER.info("Set base package to invoker package (" + basePackage + ")"); - } - - super.processOpts(); - - if (StringUtils.isBlank(templateDir)) { - embeddedTemplateDir = templateDir = getTemplateDir(); - } - - // clear model and api doc template as this codegen - // does not support auto-generated markdown doc at the moment - //TODO: add doc templates - modelDocTemplateFiles.remove("model_doc.mustache"); - apiDocTemplateFiles.remove("api_doc.mustache"); - - if (additionalProperties.containsKey(TITLE)) { - this.setTitle((String) additionalProperties.get(TITLE)); - } - - if (additionalProperties.containsKey(CONFIG_PACKAGE)) { - this.setConfigPackage((String) additionalProperties.get(CONFIG_PACKAGE)); - } - - if (additionalProperties.containsKey(BASE_PACKAGE)) { - this.setBasePackage((String) additionalProperties.get(BASE_PACKAGE)); - } - - if (additionalProperties.containsKey(INTERFACE_ONLY)) { - this.setInterfaceOnly(Boolean.valueOf(additionalProperties.get(INTERFACE_ONLY).toString())); - } - - if (additionalProperties.containsKey(DELEGATE_PATTERN)) { - this.setDelegatePattern(Boolean.valueOf(additionalProperties.get(DELEGATE_PATTERN).toString())); - } - - if (additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) { - this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString())); - } - - if (additionalProperties.containsKey(JAVA_8)) { - this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString())); - } - - if (additionalProperties.containsKey(ASYNC)) { - this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString())); - } - - if (additionalProperties.containsKey(RESPONSE_WRAPPER)) { - this.setResponseWrapper((String) additionalProperties.get(RESPONSE_WRAPPER)); - } - - if (additionalProperties.containsKey(USE_TAGS)) { - this.setUseTags(Boolean.valueOf(additionalProperties.get(USE_TAGS).toString())); - } - - if (additionalProperties.containsKey(USE_BEANVALIDATION)) { - this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION)); - } - - if (additionalProperties.containsKey(USE_OPTIONAL)) { - this.setUseOptional(convertPropertyToBoolean(USE_OPTIONAL)); - } - - if (useBeanValidation) { - writePropertyBack(USE_BEANVALIDATION, useBeanValidation); - } - - if (additionalProperties.containsKey(IMPLICIT_HEADERS)) { - this.setImplicitHeaders(Boolean.valueOf(additionalProperties.get(IMPLICIT_HEADERS).toString())); - } - - if (additionalProperties.containsKey(SWAGGER_DOCKET_CONFIG)) { - this.setSwaggerDocketConfig(Boolean.valueOf(additionalProperties.get(SWAGGER_DOCKET_CONFIG).toString())); - } - - typeMapping.put("file", "Resource"); - importMapping.put("Resource", "org.springframework.core.io.Resource"); - - if (useOptional) { - writePropertyBack(USE_OPTIONAL, useOptional); - } - - if (this.interfaceOnly && this.delegatePattern) { - if (this.java8) { - this.delegateMethod = true; - additionalProperties.put("delegate-method", true); - } else { - throw new IllegalArgumentException( - String.format("Can not generate code with `%s` and `%s` true while `%s` is false.", - DELEGATE_PATTERN, INTERFACE_ONLY, JAVA_8)); - } - } - - supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); - supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); - - if (!this.interfaceOnly) { - - if (library.equals(DEFAULT_LIBRARY)) { - supportingFiles.add(new SupportingFile("homeController.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "HomeController.java")); - supportingFiles.add(new SupportingFile("swagger2SpringBoot.mustache", - (sourceFolder + File.separator + basePackage).replace(".", File.separator), "Swagger2SpringBoot.java")); - supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", - (sourceFolder + File.separator + basePackage).replace(".", File.separator), "RFC3339DateFormat.java")); - supportingFiles.add(new SupportingFile("application.mustache", - ("src.main.resources").replace(".", File.separator), "application.properties")); - } - if (library.equals(SPRING_MVC_LIBRARY)) { - supportingFiles.add(new SupportingFile("webApplication.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "WebApplication.java")); - supportingFiles.add(new SupportingFile("webMvcConfiguration.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "WebMvcConfiguration.java")); - supportingFiles.add(new SupportingFile("swaggerUiConfiguration.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "SwaggerUiConfiguration.java")); - supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "RFC3339DateFormat.java")); - supportingFiles.add(new SupportingFile("application.properties", - ("src.main.resources").replace(".", File.separator), "swagger.properties")); - } - if (library.equals(SPRING_CLOUD_LIBRARY)) { - supportingFiles.add(new SupportingFile("apiKeyRequestInterceptor.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "ApiKeyRequestInterceptor.java")); - supportingFiles.add(new SupportingFile("clientConfiguration.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "ClientConfiguration.java")); - supportingFiles.add(new SupportingFile("Application.mustache", - (testFolder + File.separator + basePackage).replace(".", File.separator), "Application.java")); - apiTemplateFiles.put("apiClient.mustache", "Client.java"); - if (!additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) { - additionalProperties.put(SINGLE_CONTENT_TYPES, "true"); - this.setSingleContentTypes(true); - } - } else { - apiTemplateFiles.put("apiController.mustache", "Controller.java"); - supportingFiles.add(new SupportingFile("apiException.mustache", - (sourceFolder + File.separator + apiPackage).replace(".", File.separator), "ApiException.java")); - supportingFiles.add(new SupportingFile("apiResponseMessage.mustache", - (sourceFolder + File.separator + apiPackage).replace(".", File.separator), "ApiResponseMessage.java")); - supportingFiles.add(new SupportingFile("notFoundException.mustache", - (sourceFolder + File.separator + apiPackage).replace(".", File.separator), "NotFoundException.java")); - supportingFiles.add(new SupportingFile("apiOriginFilter.mustache", - (sourceFolder + File.separator + apiPackage).replace(".", File.separator), "ApiOriginFilter.java")); - supportingFiles.add(new SupportingFile("swaggerDocumentationConfig.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "SwaggerDocumentationConfig.java")); - } - } else if ( this.swaggerDocketConfig && !library.equals(SPRING_CLOUD_LIBRARY)) { - supportingFiles.add(new SupportingFile("swaggerDocumentationConfig.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "SwaggerDocumentationConfig.java")); - } - - if ("threetenbp".equals(dateLibrary)) { - supportingFiles.add(new SupportingFile("customInstantDeserializer.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "CustomInstantDeserializer.java")); - if (library.equals(DEFAULT_LIBRARY) || library.equals(SPRING_CLOUD_LIBRARY)) { - supportingFiles.add(new SupportingFile("jacksonConfiguration.mustache", - (sourceFolder + File.separator + configPackage).replace(".", File.separator), "JacksonConfiguration.java")); - } - } - - if ((!this.delegatePattern && this.java8) || this.delegateMethod) { - additionalProperties.put("jdk8-no-delegate", true); - } - - - if (this.delegatePattern && !this.delegateMethod) { - additionalProperties.put("isDelegate", "true"); - apiTemplateFiles.put("apiDelegate.mustache", "Delegate.java"); - } - - if (this.java8) { - additionalProperties.put("javaVersion", "1.8"); - additionalProperties.put("jdk8", "true"); - if (this.async) { - additionalProperties.put(RESPONSE_WRAPPER, "CompletableFuture"); - } - } else if (this.async) { - additionalProperties.put(RESPONSE_WRAPPER, "Callable"); - } - - // Some well-known Spring or Spring-Cloud response wrappers - switch (this.responseWrapper) { - case "Future": - case "Callable": - case "CompletableFuture": - additionalProperties.put(RESPONSE_WRAPPER, "java.util.concurrent" + this.responseWrapper); - break; - case "ListenableFuture": - additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.util.concurrent.ListenableFuture"); - break; - case "DeferredResult": - additionalProperties.put(RESPONSE_WRAPPER, "org.springframework.web.context.request.async.DeferredResult"); - break; - case "HystrixCommand": - additionalProperties.put(RESPONSE_WRAPPER, "com.netflix.hystrix.HystrixCommand"); - break; - case "RxObservable": - additionalProperties.put(RESPONSE_WRAPPER, "rx.Observable"); - break; - case "RxSingle": - additionalProperties.put(RESPONSE_WRAPPER, "rx.Single"); - break; - default: - break; - } - - // add lambda for mustache templates - additionalProperties.put("lambdaEscapeDoubleQuote", new Mustache.Lambda() { - @Override - public void execute(Template.Fragment fragment, Writer writer) throws IOException { - writer.write(fragment.execute().replaceAll("\"", Matcher.quoteReplacement("\\\""))); - } - }); - additionalProperties.put("lambdaRemoveLineBreak", new Mustache.Lambda() { - @Override - public void execute(Template.Fragment fragment, Writer writer) throws IOException { - writer.write(fragment.execute().replaceAll("\\r|\\n", "")); - } - }); - } - - @Override - public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { - if((library.equals(DEFAULT_LIBRARY) || library.equals(SPRING_MVC_LIBRARY)) && !useTags) { - String basePath = resourcePath; - if (basePath.startsWith("/")) { - basePath = basePath.substring(1); - } - int pos = basePath.indexOf("/"); - if (pos > 0) { - basePath = basePath.substring(0, pos); - } - - if (basePath.equals("")) { - basePath = "default"; - } else { - co.subresourceOperation = !co.path.isEmpty(); - } - List opList = operations.get(basePath); - if (opList == null) { - opList = new ArrayList(); - operations.put(basePath, opList); - } - opList.add(co); - co.baseName = basePath; - } else { - super.addOperationToGroup(tag, resourcePath, operation, co, operations); - } - } - - @Override - public String getArgumentsLocation() { - return null; - } - - @Override - public String getDefaultTemplateDir() { - return "JavaSpring2"; - } - - @Override - public void preprocessOpenAPI(OpenAPI openAPI) { - super.preprocessOpenAPI(openAPI); - - if(!additionalProperties.containsKey(TITLE)) { - // From the title, compute a reasonable name for the package and the API - String title = openAPI.getInfo().getTitle(); - - // Drop any API suffix - if (title != null) { - title = title.trim().replace(" ", "-"); - if (title.toUpperCase().endsWith("API")) { - title = title.substring(0, title.length() - 3); - } - - this.title = camelize(sanitizeName(title), true); - } - additionalProperties.put(TITLE, this.title); - } - - final URL urlInfo = URLPathUtil.getServerURL(openAPI); - String port = "8080"; // Default value for a JEE Server - if (urlInfo != null && urlInfo.getPort() > 0) { - port = String.valueOf(urlInfo.getPort()); - } - - this.additionalProperties.put("serverPort", port); - if (openAPI.getPaths() != null) { - for (String pathname : openAPI.getPaths().keySet()) { - PathItem pathItem = openAPI.getPaths().get(pathname); - final List operations = pathItem.readOperations(); - for (Operation operation : operations) { - if (operation.getTags() != null) { - List> tags = new ArrayList<>(); - for (String tag : operation.getTags()) { - Map value = new HashMap<>(); - value.put("tag", tag); - value.put("hasMore", "true"); - tags.add(value); - } - if (tags.size() > 0) { - tags.get(tags.size() - 1).remove("hasMore"); - } - if (operation.getTags().size() > 0) { - String tag = operation.getTags().get(0); - operation.setTags(Arrays.asList(tag)); - } - operation.addExtension("x-tags", tags); - } - } - } - } - } - - @Override - public Map postProcessOperations(Map objs) { - Map operations = (Map) objs.get("operations"); - if (operations != null) { - List ops = (List) operations.get("operation"); - for (final CodegenOperation operation : ops) { - List responses = operation.responses; - if (responses != null) { - for (final CodegenResponse resp : responses) { - if ("0".equals(resp.code)) { - resp.code = "200"; - } - doDataTypeAssignment(resp.dataType, new DataTypeAssigner() { - @Override - public void setReturnType(final String returnType) { - resp.dataType = returnType; - } - - @Override - public void setReturnContainer(final String returnContainer) { - resp.containerType = returnContainer; - } - }); - } - } - - doDataTypeAssignment(operation.returnType, new DataTypeAssigner() { - - @Override - public void setReturnType(final String returnType) { - operation.returnType = returnType; - } - - @Override - public void setReturnContainer(final String returnContainer) { - operation.returnContainer = returnContainer; - } - }); - - if(implicitHeaders){ - removeHeadersFromAllParams(operation.allParams); - removeHeadersFromContents(operation.contents); - } - if (operation.examples != null){ - for (Map example : operation.examples) - { - for (Map.Entry entry : example.entrySet()) - { - // Replace " with \", \r, \n with \\r, \\n - String val = entry.getValue().replace("\"", "\\\"") - .replace("\r","\\r") - .replace("\n","\\n"); - entry.setValue(val); - } - } - } - } - } - - return objs; - } - - private interface DataTypeAssigner { - void setReturnType(String returnType); - void setReturnContainer(String returnContainer); - } - - /** - * - * @param returnType The return type that needs to be converted - * @param dataTypeAssigner An object that will assign the data to the respective fields in the model. - */ - private void doDataTypeAssignment(String returnType, Spring2Codegen.DataTypeAssigner dataTypeAssigner) { - final String rt = returnType; - if (rt == null) { - dataTypeAssigner.setReturnType("Void"); - } else if (rt.startsWith("List")) { - int end = rt.lastIndexOf(">"); - if (end > 0) { - dataTypeAssigner.setReturnType(rt.substring("List<".length(), end).trim()); - dataTypeAssigner.setReturnContainer("List"); - } - } else if (rt.startsWith("Map")) { - int end = rt.lastIndexOf(">"); - if (end > 0) { - String mapTypes = rt.substring("Map<".length(), end); - String mapKey = mapTypes.split(",")[0]; - String mapValue = mapTypes.substring(mapKey.length() + 1).trim(); - dataTypeAssigner.setReturnType(mapValue); - dataTypeAssigner.setReturnContainer("Map"); - } - } else if (rt.startsWith("Set")) { - int end = rt.lastIndexOf(">"); - if (end > 0) { - dataTypeAssigner.setReturnType(rt.substring("Set<".length(), end).trim()); - dataTypeAssigner.setReturnContainer("Set"); - } - } - } - - /** - * This method removes header parameters from the list of parameters and also - * corrects last allParams hasMore state. - * @param allParams list of all parameters - */ - private void removeHeadersFromAllParams(List allParams) { - if(allParams.isEmpty()){ - return; - } - final ArrayList copy = new ArrayList<>(allParams); - allParams.clear(); - - for(CodegenParameter p : copy){ - if(!getBooleanValue(p, CodegenConstants.IS_HEADER_PARAM_EXT_NAME)){ - allParams.add(p); - } - } - allParams.get(allParams.size()-1).getVendorExtensions().put(CodegenConstants.HAS_MORE_EXT_NAME, Boolean.FALSE); - } - - private void removeHeadersFromContents(List contents) { - if(contents == null || contents.isEmpty()){ - return; - } - for(int index = 0; index < contents.size(); index++) { - final CodegenContent codegenContent = contents.get(index); - final List parameters = codegenContent.getParameters(); - if (parameters == null || parameters.isEmpty()) { - continue; - } - final List filteredParameters = parameters.stream() - .filter(codegenParameter -> !getBooleanValue(codegenParameter, CodegenConstants.IS_HEADER_PARAM_EXT_NAME)) - .collect(Collectors.toList()); - parameters.clear(); - parameters.addAll(filteredParameters); - parameters.get(parameters.size()-1).getVendorExtensions().put(CodegenConstants.HAS_MORE_EXT_NAME, Boolean.FALSE); - } - } - - @Override - public Map postProcessSupportingFileData(Map objs) { - if(library.equals(SPRING_CLOUD_LIBRARY)) { - List authMethods = (List) objs.get("authMethods"); - if (authMethods != null) { - for (CodegenSecurity authMethod : authMethods) { - authMethod.name = camelize(sanitizeName(authMethod.name), true); - } - } - } - return objs; - } - - @Override - public String toApiName(String name) { - if (name.length() == 0) { - return "DefaultApi"; - } - name = sanitizeName(name); - return camelize(name) + "Api"; - } - - @Override - public String toApiTestFilename(String name) { - if(library.equals(SPRING_MVC_LIBRARY)) { - return toApiName(name) + "ControllerIT"; - } - if(library.equals(SPRING_CLOUD_LIBRARY)) { - return toApiName(name) + "Test"; - } - return toApiName(name) + "ControllerIntegrationTest"; - } - - @Override - public void setParameterExampleValue(CodegenParameter p) { - String type = p.baseType; - if (type == null) { - type = p.dataType; - } - - if ("File".equalsIgnoreCase(type)) { - String example; - - if (p.defaultValue == null) { - example = p.example; - } else { - example = p.defaultValue; - } - - if (example == null) { - example = "/path/to/file"; - } - example = "new org.springframework.core.io.FileSystemResource(new java.io.File(\"" + escapeText(example) + "\"))"; - p.example = example; - } else { - super.setParameterExampleValue(p); - } - } - - public String toBooleanGetter(String name) { - return getterAndSetterCapitalize(name); - } - - public void setTitle(String title) { - this.title = title; - } - - public void setConfigPackage(String configPackage) { - this.configPackage = configPackage; - } - - public void setBasePackage(String configPackage) { - this.basePackage = configPackage; - } - - public void setInterfaceOnly(boolean interfaceOnly) { this.interfaceOnly = interfaceOnly; } - - public void setDelegatePattern(boolean delegatePattern) { this.delegatePattern = delegatePattern; } - - public void setSingleContentTypes(boolean singleContentTypes) { - this.singleContentTypes = singleContentTypes; - } - - public void setJava8(boolean java8) { this.java8 = java8; } - - public void setAsync(boolean async) { this.async = async; } - - public void setResponseWrapper(String responseWrapper) { this.responseWrapper = responseWrapper; } - - public void setUseTags(boolean useTags) { - this.useTags = useTags; - } - - public void setImplicitHeaders(boolean implicitHeaders) { - this.implicitHeaders = implicitHeaders; - } - - public void setSwaggerDocketConfig(boolean swaggerDocketConfig) { - this.swaggerDocketConfig = swaggerDocketConfig; - } - - @Override - public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { - super.postProcessModelProperty(model, property); - - if ("null".equals(property.example)) { - property.example = null; - } - - //Add imports for Jackson - boolean isEnum = getBooleanValue(model, IS_ENUM_EXT_NAME); - if (!Boolean.TRUE.equals(isEnum)) { - model.imports.add("JsonProperty"); - boolean hasEnums = getBooleanValue(model, HAS_ENUMS_EXT_NAME); - if (Boolean.TRUE.equals(hasEnums)) { - model.imports.add("JsonValue"); - } - } else { // enum class - //Needed imports for Jackson's JsonCreator - if (additionalProperties.containsKey("jackson")) { - model.imports.add("JsonCreator"); - } - } - } - - @Override - public Map postProcessModelsEnum(Map objs) { - objs = super.postProcessModelsEnum(objs); - - //Add imports for Jackson - List> imports = (List>)objs.get("imports"); - List models = (List) objs.get("models"); - for (Object _mo : models) { - Map mo = (Map) _mo; - CodegenModel cm = (CodegenModel) mo.get("model"); - // for enum model - boolean isEnum = getBooleanValue(cm, IS_ENUM_EXT_NAME); - if (Boolean.TRUE.equals(isEnum) && cm.allowableValues != null) { - cm.imports.add(importMapping.get("JsonValue")); - Map item = new HashMap(); - item.put("import", importMapping.get("JsonValue")); - imports.add(item); - } - } - - return objs; - } - - public void setUseBeanValidation(boolean useBeanValidation) { - this.useBeanValidation = useBeanValidation; - } - - @Override - public void setUseOptional(boolean useOptional) { - this.useOptional = useOptional; - } -} diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java index eeaa962870..8f32d99224 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java @@ -15,8 +15,6 @@ import io.swagger.codegen.v3.SupportingFile; import io.swagger.codegen.v3.generators.features.BeanValidationFeatures; import io.swagger.codegen.v3.generators.features.OptionalFeatures; -import io.swagger.codegen.v3.templates.MustacheTemplateEngine; -import io.swagger.codegen.v3.templates.TemplateEngine; import io.swagger.codegen.v3.utils.URLPathUtil; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; @@ -41,9 +39,6 @@ import static io.swagger.codegen.v3.CodegenConstants.IS_ENUM_EXT_NAME; import static io.swagger.codegen.v3.generators.handlebars.ExtensionHelper.getBooleanValue; -/* - DEPRECATED, Spring Boot 1 is in maintenance mode only. Please use JavaSpring2. - */ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidationFeatures, OptionalFeatures { static Logger LOGGER = LoggerFactory.getLogger(SpringCodegen.class); public static final String DEFAULT_LIBRARY = "spring-boot"; @@ -53,7 +48,6 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation public static final String INTERFACE_ONLY = "interfaceOnly"; public static final String DELEGATE_PATTERN = "delegatePattern"; public static final String SINGLE_CONTENT_TYPES = "singleContentTypes"; - public static final String JAVA_8 = "java8"; public static final String ASYNC = "async"; public static final String RESPONSE_WRAPPER = "responseWrapper"; public static final String USE_TAGS = "useTags"; @@ -61,6 +55,10 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation public static final String SPRING_CLOUD_LIBRARY = "spring-cloud"; public static final String IMPLICIT_HEADERS = "implicitHeaders"; public static final String SWAGGER_DOCKET_CONFIG = "swaggerDocketConfig"; + public static final String TARGET_OPENFEIGN = "generateForOpenFeign"; + public static final String DEFAULT_INTERFACES = "defaultInterfaces"; + public static final String SPRING_BOOT_VERSION = "springBootVersion"; + public static final String SPRING_BOOT_VERSION_2 = "springBootV2"; protected String title = "swagger-petstore"; protected String configPackage = "io.swagger.configuration"; @@ -77,6 +75,9 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation protected boolean implicitHeaders = false; protected boolean swaggerDocketConfig = false; protected boolean useOptional = false; + protected boolean openFeign = false; + protected boolean defaultInterfaces = true; + protected String springBootVersion = "1.5.22.RELEASE"; public SpringCodegen() { super(); @@ -98,7 +99,6 @@ public SpringCodegen() { cliOptions.add(CliOption.newBoolean(INTERFACE_ONLY, "Whether to generate only API interface stubs without the server files.")); cliOptions.add(CliOption.newBoolean(DELEGATE_PATTERN, "Whether to generate the server files using the delegate pattern")); cliOptions.add(CliOption.newBoolean(SINGLE_CONTENT_TYPES, "Whether to select only one produces/consumes content-type by operation.")); - cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface")); cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers")); cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)")); cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames")); @@ -107,6 +107,8 @@ public SpringCodegen() { cliOptions.add(CliOption.newBoolean(SWAGGER_DOCKET_CONFIG, "Generate Spring Swagger Docket configuration class.")); cliOptions.add(CliOption.newBoolean(USE_OPTIONAL, "Use Optional container for optional parameters")); + cliOptions.add(CliOption.newBoolean(TARGET_OPENFEIGN,"Generate for usage with OpenFeign (instead of feign)")); + cliOptions.add(CliOption.newBoolean(DEFAULT_INTERFACES, "Generate default implementations for interfaces").defaultValue("true")); supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration."); supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration."); @@ -118,6 +120,14 @@ public SpringCodegen() { library.setEnum(supportedLibraries); library.setDefault(DEFAULT_LIBRARY); cliOptions.add(library); + + CliOption springBootVersionOption = new CliOption(SPRING_BOOT_VERSION, "Spring boot version"); + Map springBootEnum = new HashMap<>(); + springBootEnum.put("1.5.22.RELEASE", "1.5.22.RELEASE"); + springBootEnum.put("2.1.7.RELEASE", "2.1.7.RELEASE"); + springBootVersionOption.setEnum(springBootEnum); + cliOptions.add(springBootVersionOption); + } @Override @@ -141,15 +151,23 @@ public void processOpts() { additionalProperties.put(CodegenConstants.USE_OAS2, true); // Process java8 option before common java ones to change the default dateLibrary to java8. - if (additionalProperties.containsKey(JAVA_8)) { - this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString())); + if (additionalProperties.containsKey(JAVA8_MODE)) { + this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA8_MODE).toString())); + } + + if (additionalProperties.containsKey(DATE_LIBRARY)) { + if (additionalProperties.get(DATE_LIBRARY).toString().startsWith("java8")) { + this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA8_MODE).toString())); + } } if (this.java8) { additionalProperties.put("javaVersion", "1.8"); - additionalProperties.put("jdk8", "true"); + additionalProperties.put("jdk8", true); if (!additionalProperties.containsKey(DATE_LIBRARY)) { setDateLibrary("java8"); } + } else { + this.defaultInterfaces = false; } // set invokerPackage as basePackage @@ -195,10 +213,6 @@ public void processOpts() { this.setSingleContentTypes(Boolean.valueOf(additionalProperties.get(SINGLE_CONTENT_TYPES).toString())); } - if (additionalProperties.containsKey(JAVA_8)) { - this.setJava8(Boolean.valueOf(additionalProperties.get(JAVA_8).toString())); - } - if (additionalProperties.containsKey(ASYNC)) { this.setAsync(Boolean.valueOf(additionalProperties.get(ASYNC).toString())); } @@ -219,6 +233,24 @@ public void processOpts() { this.setUseOptional(convertPropertyToBoolean(USE_OPTIONAL)); } + if (additionalProperties.containsKey(TARGET_OPENFEIGN)) { + this.setOpenFeign(convertPropertyToBoolean(TARGET_OPENFEIGN)); + } + + if (additionalProperties.containsKey(DEFAULT_INTERFACES)) { + this.setDefaultInterfaces(Boolean.valueOf(additionalProperties.get(DEFAULT_INTERFACES).toString())); + } + additionalProperties.put(DEFAULT_INTERFACES, this.defaultInterfaces); + + if (additionalProperties.containsKey(SPRING_BOOT_VERSION)) { + this.springBootVersion = additionalProperties.get(SPRING_BOOT_VERSION).toString(); + } + additionalProperties.put(SPRING_BOOT_VERSION, this.springBootVersion); + if (springBootVersion.startsWith("2")) { + additionalProperties.put(SPRING_BOOT_VERSION_2, true); + this.setOpenFeign(true); + } + if (useBeanValidation) { writePropertyBack(USE_BEANVALIDATION, useBeanValidation); } @@ -245,7 +277,7 @@ public void processOpts() { } else { throw new IllegalArgumentException( String.format("Can not generate code with `%s` and `%s` true while `%s` is false.", - DELEGATE_PATTERN, INTERFACE_ONLY, JAVA_8)); + DELEGATE_PATTERN, INTERFACE_ONLY, JAVA8_MODE)); } } @@ -255,6 +287,7 @@ public void processOpts() { if (!this.interfaceOnly) { if (library.equals(DEFAULT_LIBRARY)) { + apiTestTemplateFiles.clear(); supportingFiles.add(new SupportingFile("homeController.mustache", (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java")); supportingFiles.add(new SupportingFile("swagger2SpringBoot.mustache", @@ -281,13 +314,24 @@ public void processOpts() { (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "ApiKeyRequestInterceptor.java")); supportingFiles.add(new SupportingFile("clientConfiguration.mustache", (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "ClientConfiguration.java")); - supportingFiles.add(new SupportingFile("Application.mustache", - (testFolder + File.separator + basePackage).replace(".", java.io.File.separator), "Application.java")); apiTemplateFiles.put("apiClient.mustache", "Client.java"); if (!additionalProperties.containsKey(SINGLE_CONTENT_TYPES)) { additionalProperties.put(SINGLE_CONTENT_TYPES, "true"); this.setSingleContentTypes(true); } + if (additionalProperties.containsKey(CodegenConstants.GENERATE_API_TESTS)) { + if (Boolean.valueOf(additionalProperties.get(CodegenConstants.GENERATE_API_TESTS).toString())) { + // TODO Api Tests are not currently supported in spring-cloud template + apiTestTemplateFiles.clear(); + supportingFiles.add(new SupportingFile("application-test.mustache", + ("src.test.resources").replace(".", java.io.File.separator), "application.yml")); + supportingFiles.add(new SupportingFile("TestUtils.mustache", + (testFolder + File.separator + basePackage).replace(".", java.io.File.separator), "TestUtils.java")); + supportingFiles.add(new SupportingFile("Application.mustache", + (testFolder + File.separator + basePackage).replace(".", java.io.File.separator), "Application.java")); + + } + } } else { apiTemplateFiles.put("apiController.mustache", "Controller.java"); supportingFiles.add(new SupportingFile("apiException.mustache", @@ -306,6 +350,9 @@ public void processOpts() { (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerDocumentationConfig.java")); } + if (this.interfaceOnly) { + apiTestTemplateFiles.clear(); + } if ("threetenbp".equals(dateLibrary)) { supportingFiles.add(new SupportingFile("customInstantDeserializer.mustache", (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "CustomInstantDeserializer.java")); @@ -326,8 +373,6 @@ public void processOpts() { } if (this.java8) { - additionalProperties.put("javaVersion", "1.8"); - additionalProperties.put("jdk8", "true"); if (this.async) { additionalProperties.put(RESPONSE_WRAPPER, "CompletableFuture"); } @@ -335,6 +380,10 @@ public void processOpts() { additionalProperties.put(RESPONSE_WRAPPER, "Callable"); } + if(this.openFeign){ + additionalProperties.put("isOpenFeign", true); + } + // Some well-known Spring or Spring-Cloud response wrappers switch (this.responseWrapper) { case "Future": @@ -374,6 +423,10 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio writer.write(fragment.execute().replaceAll("\\r|\\n", "")); } }); + + if ((this.java8 && !this.defaultInterfaces) || !this.java8) { + additionalProperties.put("fullController", true); + } } @Override @@ -667,10 +720,6 @@ public void setParameterExampleValue(CodegenParameter p) { } } - public String toBooleanGetter(String name) { - return getterAndSetterCapitalize(name); - } - public void setTitle(String title) { this.title = title; } @@ -764,4 +813,12 @@ public void setUseBeanValidation(boolean useBeanValidation) { public void setUseOptional(boolean useOptional) { this.useOptional = useOptional; } + + public void setOpenFeign(boolean openFeign) { + this.openFeign = openFeign; + } + + public void setDefaultInterfaces(boolean defaultInterfaces) { + this.defaultInterfaces = defaultInterfaces; + } } diff --git a/src/main/java/io/swagger/codegen/v3/generators/kotlin/AbstractKotlinCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/kotlin/AbstractKotlinCodegen.java index cbfadce32b..f2cc7542bc 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/kotlin/AbstractKotlinCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/kotlin/AbstractKotlinCodegen.java @@ -17,14 +17,12 @@ import java.util.Map; import java.util.Set; -public abstract class AbstractKotlinCodegen extends DefaultCodegenConfig { +public abstract class AbstractKotlinCodegen extends DefaultCodegenConfig { private static Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class); private Set instantiationLibraryFunction; - - protected String artifactId; protected String artifactVersion = "1.0.0"; protected String groupId = "io.swagger"; @@ -41,7 +39,7 @@ public AbstractKotlinCodegen() { super(); supportsInheritance = true; - languageSpecificPrimitives = new HashSet(Arrays.asList( + languageSpecificPrimitives = new HashSet<>(Arrays.asList( "kotlin.Any", "kotlin.Byte", "kotlin.Short", @@ -60,8 +58,9 @@ public AbstractKotlinCodegen() { // this includes hard reserved words defined by https://github.com/JetBrains/kotlin/blob/master/core/descriptors/src/org/jetbrains/kotlin/renderer/KeywordStringsGenerated.java // as well as keywords from https://kotlinlang.org/docs/reference/keyword-reference.html - reservedWords = new HashSet(Arrays.asList( + reservedWords = new HashSet<>(Arrays.asList( "abstract", + "actual", "annotation", "as", "break", @@ -78,6 +77,7 @@ public AbstractKotlinCodegen() { "do", "else", "enum", + "expect", "external", "false", "final", @@ -126,7 +126,7 @@ public AbstractKotlinCodegen() { "while" )); - defaultIncludes = new HashSet(Arrays.asList( + defaultIncludes = new HashSet<>(Arrays.asList( "kotlin.Byte", "kotlin.Short", "kotlin.Int", @@ -141,12 +141,12 @@ public AbstractKotlinCodegen() { "kotlin.collections.Map" )); - instantiationLibraryFunction = new HashSet(Arrays.asList( + instantiationLibraryFunction = new HashSet<>(Arrays.asList( "arrayOf", "mapOf" )); - typeMapping = new HashMap(); + typeMapping = new HashMap<>(); typeMapping.put("string", "kotlin.String"); typeMapping.put("boolean", "kotlin.Boolean"); typeMapping.put("integer", "kotlin.Int"); @@ -169,7 +169,7 @@ public AbstractKotlinCodegen() { instantiationTypes.put("list", "arrayOf"); instantiationTypes.put("map", "mapOf"); - importMapping = new HashMap(); + importMapping = new HashMap<>(); importMapping.put("BigDecimal", "java.math.BigDecimal"); importMapping.put("UUID", "java.util.UUID"); importMapping.put("File", "java.io.File"); @@ -272,7 +272,7 @@ public void setEnumPropertyNaming(final String enumPropertyNamingType) { public String getTypeDeclaration(Schema propertySchema) { if (propertySchema instanceof ArraySchema) { return getArrayTypeDeclaration((ArraySchema) propertySchema); - } else if (propertySchema instanceof MapSchema && hasSchemaProperties(propertySchema)) { + } else if (propertySchema instanceof MapSchema && hasSchemaProperties(propertySchema)) { Schema inner = (Schema) propertySchema.getAdditionalProperties(); if (inner == null) { LOGGER.warn(propertySchema.getName() + "(map property) does not have a proper inner type defined"); @@ -444,7 +444,7 @@ public String toEnumVarName(String value, String datatype) { break; } - if (reservedWords.contains(modified)) { + if (isReservedWord(modified)) { return escapeReservedWord(modified); } @@ -498,7 +498,7 @@ public String toModelName(final String name) { String modifiedName = name.replaceAll("\\.", ""); modifiedName = sanitizeKotlinSpecificNames(modifiedName); - if (reservedWords.contains(modifiedName)) { + if (isReservedWord(modifiedName)) { modifiedName = escapeReservedWord(modifiedName); } @@ -578,11 +578,11 @@ protected boolean isReservedWord(String word) { protected boolean needToImport(String type) { // provides extra protection against improperly trying to import language primitives and java types boolean imports = - !type.startsWith("kotlin.") && - !type.startsWith("java.") && - !defaultIncludes.contains(type) && - !languageSpecificPrimitives.contains(type) && - !instantiationLibraryFunction.contains(type); + !type.startsWith("kotlin.") && + !type.startsWith("java.") && + !defaultIncludes.contains(type) && + !languageSpecificPrimitives.contains(type) && + !instantiationLibraryFunction.contains(type); return imports; } diff --git a/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java index cdd7fc572a..0e7be8bee9 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/kotlin/KotlinClientCodegen.java @@ -1,8 +1,11 @@ package io.swagger.codegen.v3.generators.kotlin; +import com.github.jknack.handlebars.Handlebars; +import com.github.jknack.handlebars.helper.ConditionalHelpers; import io.swagger.codegen.v3.CliOption; import io.swagger.codegen.v3.CodegenType; import io.swagger.codegen.v3.SupportingFile; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -10,11 +13,9 @@ import java.util.HashMap; import java.util.Map; -import org.apache.commons.lang3.StringUtils; - public class KotlinClientCodegen extends AbstractKotlinCodegen { - public static final String DATE_LIBRARY = "dateLibrary"; + public static final String DATE_LIBRARY = "dateLibrary"; private static Logger LOGGER = LoggerFactory.getLogger(KotlinClientCodegen.class); protected String dateLibrary = DateLibrary.JAVA8.value; @@ -57,6 +58,12 @@ public KotlinClientCodegen() { cliOptions.add(dateLibrary); } + @Override + public void addHandlebarHelpers(Handlebars handlebars) { + super.addHandlebarHelpers(handlebars); + handlebars.registerHelpers(ConditionalHelpers.class); + } + @Override public String getDefaultTemplateDir() { return "kotlin-client"; @@ -80,7 +87,7 @@ public void setDateLibrary(String library) { @Override public void processOpts() { - super.processOpts(); + super.processOpts(); if (StringUtils.isBlank(templateDir)) { embeddedTemplateDir = templateDir = getTemplateDir(); @@ -90,7 +97,7 @@ public void processOpts() { setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString()); } - if (DateLibrary.THREETENBP.value.equals(dateLibrary)) { + if (DateLibrary.THREETENBP.value.equals(dateLibrary)) { additionalProperties.put(DateLibrary.THREETENBP.value, true); typeMapping.put("date", "LocalDate"); typeMapping.put("DateTime", "LocalDateTime"); @@ -123,4 +130,4 @@ public void processOpts() { supportingFiles.add(new SupportingFile("infrastructure/Serializer.kt.mustache", infrastructureFolder, "Serializer.kt")); supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt")); } -} +} \ No newline at end of file diff --git a/src/main/java/io/swagger/codegen/v3/generators/python/PythonClientCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/python/PythonClientCodegen.java index ec76459807..add037f303 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/python/PythonClientCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/python/PythonClientCodegen.java @@ -124,7 +124,7 @@ public PythonClientCodegen() { "assert", "else", "if", "pass", "yield", "break", "except", "import", "print", "class", "exec", "in", "raise", "continue", "finally", "is", "return", "def", "for", "lambda", "try", "self", "nonlocal", "None", "True", "nonlocal", - "float", "int", "str", "date", "datetime")); + "float", "int", "str", "date", "datetime", "False", "await", "async")); regexModifiers = new HashMap(); regexModifiers.put('i', "IGNORECASE"); diff --git a/src/main/java/io/swagger/codegen/v3/generators/python/PythonFlaskConnexionCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/python/PythonFlaskConnexionCodegen.java index e768da3ace..283d1a15fe 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/python/PythonFlaskConnexionCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/python/PythonFlaskConnexionCodegen.java @@ -101,7 +101,7 @@ public PythonFlaskConnexionCodegen() { "assert", "else", "if", "pass", "yield", "break", "except", "import", "print", "class", "exec", "in", "raise", "continue", "finally", "is", "return", "def", "for", "lambda", "try", "self", "None", "True", "False", "nonlocal", - "float", "int", "str", "date", "datetime")); + "float", "int", "str", "date", "datetime", "False", "await", "async")); // set the output folder here outputFolder = "generated-code/connexion"; diff --git a/src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java index fbbe1a5787..09cad267bb 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/typescript/TypeScriptAngularClientCodegen.java @@ -39,6 +39,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode public static final String SNAPSHOT = "snapshot"; public static final String WITH_INTERFACES = "withInterfaces"; public static final String NG_VERSION = "ngVersion"; + public static final String NG_PACKAGR = "useNgPackagr"; protected String npmName = null; protected String npmVersion = "1.0.0"; @@ -102,19 +103,9 @@ public void processOpts() { supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts")); supportingFiles.add(new SupportingFile("encoder.mustache", getIndexDirectory(), "encoder.ts")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); + supportingFiles.add(new SupportingFile("npmignore", "", ".npmignore")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); - if (additionalProperties.containsKey(NPM_NAME)) { - addNpmPackageGeneration(); - } - - if (additionalProperties.containsKey(WITH_INTERFACES)) { - boolean withInterfaces = Boolean.parseBoolean(additionalProperties.get(WITH_INTERFACES).toString()); - if (withInterfaces) { - apiTemplateFiles.put("apiInterface.mustache", "Interface.ts"); - } - } - // determine NG version SemVer ngVersion; if (additionalProperties.containsKey(NG_VERSION)) { @@ -125,13 +116,27 @@ public void processOpts() { LOGGER.info(" (you can select the angular version by setting the additionalProperty ngVersion)"); } additionalProperties.put(NG_VERSION, ngVersion); + additionalProperties.put(NG_PACKAGR, ngVersion.atLeast("4.0.0")); additionalProperties.put("useRxJS6", ngVersion.atLeast("6.0.0")); additionalProperties.put("injectionToken", ngVersion.atLeast("4.0.0") ? "InjectionToken" : "OpaqueToken"); additionalProperties.put("injectionTokenTyped", ngVersion.atLeast("4.0.0")); additionalProperties.put("useHttpClient", ngVersion.atLeast("4.3.0")); + additionalProperties.put("useHttpClientPackage", ngVersion.atLeast("4.3.0") && !ngVersion.atLeast("8.0.0")); if (!ngVersion.atLeast("4.3.0")) { supportingFiles.add(new SupportingFile("rxjs-operators.mustache", getIndexDirectory(), "rxjs-operators.ts")); } + + if (additionalProperties.containsKey(NPM_NAME)) { + addNpmPackageGeneration(); + } + + if (additionalProperties.containsKey(WITH_INTERFACES)) { + boolean withInterfaces = Boolean.parseBoolean(additionalProperties.get(WITH_INTERFACES).toString()); + if (withInterfaces) { + apiTemplateFiles.put("apiInterface.mustache", "Interface.ts"); + } + } + } private void addNpmPackageGeneration() { @@ -158,6 +163,10 @@ private void addNpmPackageGeneration() { supportingFiles.add(new SupportingFile("package.mustache", getIndexDirectory(), "package.json")); supportingFiles.add(new SupportingFile("typings.mustache", getIndexDirectory(), "typings.json")); supportingFiles.add(new SupportingFile("tsconfig.mustache", getIndexDirectory(), "tsconfig.json")); + if (additionalProperties.containsKey(NG_PACKAGR) + && Boolean.valueOf(additionalProperties.get(NG_PACKAGR).toString())) { + supportingFiles.add(new SupportingFile("ng-package.mustache", getIndexDirectory(), "ng-package.json")); + } } private String getIndexDirectory() { @@ -348,7 +357,7 @@ private List> toTsImports(CodegenModel cm, Set impor if (!im.equals(cm.classname)) { HashMap tsImport = new HashMap<>(); tsImport.put("classname", im); - tsImport.put("filename", im); + tsImport.put("filename", toModelFilename(im)); tsImports.add(tsImport); } } @@ -383,7 +392,7 @@ public String toModelFilename(String name) { @Override public String toModelImport(String name) { - return modelPackage() + "/" + name; + return modelPackage() + "/" + toModelFilename(name); } public String getNpmName() { diff --git a/src/main/java/io/swagger/codegen/v3/generators/util/OpenAPIUtil.java b/src/main/java/io/swagger/codegen/v3/generators/util/OpenAPIUtil.java index 2b34279d21..73f74b24d6 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/util/OpenAPIUtil.java +++ b/src/main/java/io/swagger/codegen/v3/generators/util/OpenAPIUtil.java @@ -4,6 +4,7 @@ import io.swagger.codegen.v3.CodegenProperty; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.media.Schema; +import org.apache.commons.lang3.StringUtils; import java.util.Map; @@ -34,4 +35,23 @@ public static String getSimpleRef(String ref) { } return ref; } + + public static Schema getSchemaFromName(String name, OpenAPI openAPI) { + if (openAPI.getComponents() == null) { + return null; + } + final Map mapSchema = openAPI.getComponents().getSchemas(); + if (mapSchema == null || mapSchema.isEmpty()) { + return null; + } + return mapSchema.get(name); + } + + public static Schema getSchemaFromRefSchema(Schema refSchema, OpenAPI openAPI) { + if (StringUtils.isBlank(refSchema.get$ref())) { + return null; + } + final String name = getSimpleRef(refSchema.get$ref()); + return getSchemaFromName(name, openAPI); + } } diff --git a/src/main/resources/META-INF/services/io.swagger.codegen.v3.CodegenConfig b/src/main/resources/META-INF/services/io.swagger.codegen.v3.CodegenConfig index cea3edb841..ec84b34ad4 100644 --- a/src/main/resources/META-INF/services/io.swagger.codegen.v3.CodegenConfig +++ b/src/main/resources/META-INF/services/io.swagger.codegen.v3.CodegenConfig @@ -16,7 +16,6 @@ io.swagger.codegen.v3.generators.java.JavaResteasyEapServerCodegen io.swagger.codegen.v3.generators.java.JavaResteasyServerCodegen io.swagger.codegen.v3.generators.java.MicronautCodegen io.swagger.codegen.v3.generators.java.SpringCodegen -io.swagger.codegen.v3.generators.java.Spring2Codegen io.swagger.codegen.v3.generators.nodejs.NodeJSServerCodegen io.swagger.codegen.v3.generators.openapi.OpenAPIGenerator io.swagger.codegen.v3.generators.openapi.OpenAPIYamlGenerator diff --git a/src/main/resources/handlebars/Java/build.gradle.mustache b/src/main/resources/handlebars/Java/build.gradle.mustache index 05c8b29e0f..06f58d52a6 100644 --- a/src/main/resources/handlebars/Java/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/build.gradle.mustache @@ -112,7 +112,7 @@ ext { {{^useOas2}} swagger_annotations_version = "2.0.0" {{/useOas2}} - jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" + jackson_version = "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" jersey_version = "1.19.4" jodatime_version = "2.9.9" junit_version = "4.12" diff --git a/src/main/resources/handlebars/Java/libraries/feign/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/feign/build.gradle.mustache index 00a1269f46..79b16f5106 100644 --- a/src/main/resources/handlebars/Java/libraries/feign/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/feign/build.gradle.mustache @@ -106,7 +106,7 @@ ext { {{^useOas2}} swagger_annotations_version = "2.0.0" {{/useOas2}} - jackson_version = "2.9.9" + jackson_version = "2.9.10" {{#threetenbp}} threepane_version = "2.6.4" {{/threetenbp}} diff --git a/src/main/resources/handlebars/Java/libraries/feign/build.sbt.mustache b/src/main/resources/handlebars/Java/libraries/feign/build.sbt.mustache index 24e1df83f9..a466841c47 100644 --- a/src/main/resources/handlebars/Java/libraries/feign/build.sbt.mustache +++ b/src/main/resources/handlebars/Java/libraries/feign/build.sbt.mustache @@ -19,10 +19,10 @@ lazy val root = (project in file(".")). "com.netflix.feign" % "feign-jackson" % "9.4.0" % "compile", "com.netflix.feign" % "feign-slf4j" % "9.4.0" % "compile", "io.github.openfeign.form" % "feign-form" % "2.1.0" % "compile", - "com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile", - "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile", - "com.fasterxml.jackson.datatype" % "jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}" % "2.9.9" % "compile", + "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.datatype" % "jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}" % "2.9.10" % "compile", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.2" % "compile", "com.brsanthu" % "migbase64" % "2.2" % "compile", "junit" % "junit" % "4.12" % "test", diff --git a/src/main/resources/handlebars/Java/libraries/feign/pom.mustache b/src/main/resources/handlebars/Java/libraries/feign/pom.mustache index 0b0a19b92e..362fd5da0b 100644 --- a/src/main/resources/handlebars/Java/libraries/feign/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/feign/pom.mustache @@ -290,7 +290,7 @@ {{/useOas2}} 9.4.0 2.1.0 - 2.9.9 + 2.9.10 {{#threetenbp}} 2.6.4 {{/threetenbp}} diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache index c12e7658f5..2574f9a69c 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache @@ -111,7 +111,7 @@ ext { {{^useOas2}} swagger_annotations_version = "2.0.0" {{/useOas2}} - jackson_version = "2.9.9" + jackson_version = "2.9.10" jersey_version = "2.25.1" {{#supportJava6}} commons_io_version=2.5 diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/build.sbt.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/build.sbt.mustache index b6e2739699..b0a6298e95 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/build.sbt.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/build.sbt.mustache @@ -18,14 +18,14 @@ lazy val root = (project in file(".")). "org.glassfish.jersey.core" % "jersey-client" % "2.25.1", "org.glassfish.jersey.media" % "jersey-media-multipart" % "2.25.1", "org.glassfish.jersey.media" % "jersey-media-json-jackson" % "2.25.1", - "com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", - "com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", + "com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", + "com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", {{#joda}} - "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.9" % "compile", + "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.10" % "compile", {{/joda}} {{#java8}} - "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.9" % "compile", + "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.10" % "compile", {{/java8}} {{#threetenbp}} "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile", diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/pom.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/pom.mustache index 20c72edf3c..8414d5c013 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/pom.mustache @@ -314,7 +314,7 @@ 2.5 3.6 {{/supportJava6}} - {{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} + {{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} 1.0.0 4.12 diff --git a/src/main/resources/handlebars/Java/libraries/vertx/ApiClient.mustache b/src/main/resources/handlebars/Java/libraries/vertx/ApiClient.mustache deleted file mode 100644 index 0f35af0ac9..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/ApiClient.mustache +++ /dev/null @@ -1,601 +0,0 @@ -package {{invokerPackage}}; - -import {{invokerPackage}}.auth.Authentication; -import {{invokerPackage}}.auth.HttpBasicAuth; -import {{invokerPackage}}.auth.ApiKeyAuth; -import {{invokerPackage}}.auth.OAuth; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import io.vertx.core.*; -import io.vertx.core.buffer.Buffer; -import io.vertx.core.file.AsyncFile; -import io.vertx.core.file.FileSystem; -import io.vertx.core.file.OpenOptions; -import io.vertx.core.http.HttpHeaders; -import io.vertx.core.http.HttpMethod; -import io.vertx.core.json.Json; -import io.vertx.core.json.JsonObject; -import io.vertx.ext.web.client.HttpRequest; -import io.vertx.ext.web.client.HttpResponse; -import io.vertx.ext.web.client.WebClient; -import io.vertx.ext.web.client.WebClientOptions; - -import java.text.DateFormat; -import java.util.*; -import java.util.function.Consumer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static java.util.stream.Collectors.toMap; - -{{>generatedAnnotation}} -public class ApiClient { - - private static final Pattern CONTENT_DISPOSITION_PATTERN = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); - private static final OpenOptions FILE_DOWNLOAD_OPTIONS = new OpenOptions().setCreate(true).setTruncateExisting(true); - - private final Vertx vertx; - private final JsonObject config; - private final String identifier; - - private MultiMap defaultHeaders = MultiMap.caseInsensitiveMultiMap(); - private Map authentications; - private String basePath = "{{{basePath}}}"; - private DateFormat dateFormat; - private ObjectMapper objectMapper; - private String downloadsDir = ""; - - public ApiClient(Vertx vertx, JsonObject config) { - Objects.requireNonNull(vertx, "Vertx must not be null"); - Objects.requireNonNull(config, "Config must not be null"); - - this.vertx = vertx; - - // Use RFC3339 format for date and datetime. - // See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14 - this.dateFormat = new RFC3339DateFormat(); - - // Use UTC as the default time zone. - this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - - // Build object mapper - this.objectMapper = new ObjectMapper(); - this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - this.objectMapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); - this.objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); - this.objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); - this.objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); - this.objectMapper.registerModule(new JavaTimeModule()); - this.objectMapper.setDateFormat(dateFormat); - - // Setup authentications (key: authentication name, value: authentication). - this.authentications = new HashMap<>();{{#authMethods}}{{#is this 'basic'}} - authentications.put("{{name}}", new HttpBasicAuth());{{/is}}{{#is this 'api-key'}} - authentications.put("{{name}}", new ApiKeyAuth({{#is this 'key-in-header'}}"header"{{/is}}{{#isNot this 'key-in-header'}}"query"{{/isNot}}, "{{keyParamName}}"));{{/is}}{{#is this 'oauth'}} - authentications.put("{{name}}", new OAuth());{{/is}}{{#is this 'bearer'}} - authentications.put("{{name}}", new OAuth());{{/is}}{{/authMethods}} - // Prevent the authentications from being modified. - this.authentications = Collections.unmodifiableMap(authentications); - - // Configurations - this.basePath = config.getString("basePath", this.basePath); - this.downloadsDir = config.getString("downloadsDir", this.downloadsDir); - this.config = config; - this.identifier = UUID.randomUUID().toString(); - } - - public Vertx getVertx() { - return vertx; - } - - public ObjectMapper getObjectMapper() { - return objectMapper; - } - - public ApiClient setObjectMapper(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; - return this; - } - - public synchronized WebClient getWebClient() { - String webClientIdentifier = "web-client-" + identifier; - WebClient webClient = Vertx.currentContext().get(webClientIdentifier); - if (webClient == null) { - webClient = buildWebClient(vertx, config); - Vertx.currentContext().put(webClientIdentifier, webClient); - } - return webClient; - } - - public String getBasePath() { - return basePath; - } - - public ApiClient setBasePath(String basePath) { - this.basePath = basePath; - return this; - } - - public String getDownloadsDir() { - return downloadsDir; - } - - public ApiClient setDownloadsDir(String downloadsDir) { - this.downloadsDir = downloadsDir; - return this; - } - - public MultiMap getDefaultHeaders() { - return defaultHeaders; - } - - public ApiClient addDefaultHeader(String key, String value) { - defaultHeaders.add(key, value); - return this; - } - - /** - * Get authentications (key: authentication name, value: authentication). - * - * @return Map of authentication object - */ - public Map getAuthentications() { - return authentications; - } - - /** - * Get authentication for the given name. - * - * @param authName The authentication name - * @return The authentication, null if not found - */ - public Authentication getAuthentication(String authName) { - return authentications.get(authName); - } - - /** - * Helper method to set username for the first HTTP basic authentication. - * - * @param username Username - */ - public ApiClient setUsername(String username) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setUsername(username); - return this; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); - } - - /** - * Helper method to set password for the first HTTP basic authentication. - * - * @param password Password - */ - public ApiClient setPassword(String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setPassword(password); - return this; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); - } - - /** - * Helper method to set API key value for the first API key authentication. - * - * @param apiKey API key - */ - public ApiClient setApiKey(String apiKey) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKey(apiKey); - return this; - } - } - throw new RuntimeException("No API key authentication configured!"); - } - - /** - * Helper method to set API key prefix for the first API key authentication. - * - * @param apiKeyPrefix API key prefix - */ - public ApiClient setApiKeyPrefix(String apiKeyPrefix) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); - return this; - } - } - throw new RuntimeException("No API key authentication configured!"); - } - - /** - * Helper method to set access token for the first OAuth2 authentication. - * - * @param accessToken Access token - */ - public ApiClient setAccessToken(String accessToken) { - for (Authentication auth : authentications.values()) { - if (auth instanceof OAuth) { - ((OAuth) auth).setAccessToken(accessToken); - return this; - } - } - throw new RuntimeException("No OAuth2 authentication configured!"); - } - - /** - * Format the given Date object into string. - * - * @param date Date - * @return Date in string format - */ - public String formatDate(Date date) { - return dateFormat.format(date); - } - - /** - * Format the given parameter object into string. - * - * @param param Object - * @return Object in string format - */ - public String parameterToString(Object param) { - if (param == null) { - return ""; - } else if (param instanceof Date) { - return formatDate((Date) param); - } else if (param instanceof Collection) { - StringBuilder b = new StringBuilder(); - for (Object o : (Collection) param) { - if (b.length() > 0) { - b.append(','); - } - b.append(String.valueOf(o)); - } - return b.toString(); - } else { - return String.valueOf(param); - } - } - - /* - * Format to {@code Pair} objects. - * @param collectionFormat Collection format - * @param name Name - * @param value Value - * @return List of pairs - */ - public List parameterToPairs(String collectionFormat, String name, Object value) { - List params = new ArrayList(); - - // preconditions - if (name == null || name.isEmpty() || value == null) return params; - - Collection valueCollection; - if (value instanceof Collection) { - valueCollection = (Collection) value; - } else { - params.add(new Pair(name, parameterToString(value))); - return params; - } - - if (valueCollection.isEmpty()) { - return params; - } - - // get the collection format (default: csv) - String format = (collectionFormat == null || collectionFormat.isEmpty() ? "csv" : collectionFormat); - - // create the params based on the collection format - if ("multi".equals(format)) { - for (Object item : valueCollection) { - params.add(new Pair(name, parameterToString(item))); - } - return params; - } - - String delimiter = ","; - if ("csv".equals(format)) { - delimiter = ","; - } else if ("ssv".equals(format)) { - delimiter = " "; - } else if ("tsv".equals(format)) { - delimiter = "\t"; - } else if ("pipes".equals(format)) { - delimiter = "|"; - } - - StringBuilder sb = new StringBuilder(); - for (Object item : valueCollection) { - sb.append(delimiter); - sb.append(parameterToString(item)); - } - - params.add(new Pair(name, sb.substring(1))); - - return params; - } - - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * - * @param mime MIME - * @return True if the MIME type is JSON - */ - private boolean isJsonMime(String mime) { - String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; - return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json")); - } - - /** - * Select the Accept header's value from the given accepts array: - * if JSON exists in the given array, use it; - * otherwise use all of them (joining into a string) - * - * @param accepts The accepts array to select from - * @return The Accept header to use. If the given array is empty, - * null will be returned (not to set the Accept header explicitly). - */ - protected String selectHeaderAccept(String[] accepts) { - if (accepts.length == 0) { - return null; - } - for (String accept : accepts) { - if (isJsonMime(accept)) { - return accept; - } - } - return StringUtil.join(accepts, ","); - } - - /** - * Select the Content-Type header's value from the given array: - * if JSON exists in the given array, use it; - * otherwise use the first one of the array. - * - * @param contentTypes The Content-Type array to select from - * @return The Content-Type header to use. If the given array is empty, - * JSON will be used. - */ - protected String selectHeaderContentType(String[] contentTypes) { - if (contentTypes.length == 0) { - return "application/json"; - } - for (String contentType : contentTypes) { - if (isJsonMime(contentType)) { - return contentType; - } - } - return contentTypes[0]; - } - - public void sendBody(HttpRequest request, - Handler>> responseHandler, - Object body) { - if (body instanceof byte[]) { - Buffer buffer = Buffer.buffer((byte[]) body); - request.sendBuffer(buffer, responseHandler); - } else if (body instanceof AsyncFile) { - AsyncFile file = (AsyncFile) body; - request.sendStream(file, responseHandler); - } else { - request.sendJson(body, responseHandler); - } - } - - /** - * Invoke API by sending HTTP request with the given options. - * - * @param Type - * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE" - * @param queryParams The query parameters - * @param body The request body object - * @param headerParams The header parameters - * @param formParams The form parameters - * @param accepts The request's Accept headers - * @param contentTypes The request's Content-Type headers - * @param authNames The authentications to apply - * @param returnType The return type into which to deserialize the response - * @param resultHandler The asynchronous response handler - */ - public void invokeAPI(String path, String method, List queryParams, Object body, MultiMap headerParams, - Map formParams, String[] accepts, String[] contentTypes, String[] authNames, - TypeReference returnType, Handler> resultHandler) { - - updateParamsForAuth(authNames, queryParams, headerParams); - - if (accepts != null) { - headerParams.add(HttpHeaders.ACCEPT, selectHeaderAccept(accepts)); - } - - if (contentTypes != null) { - headerParams.add(HttpHeaders.CONTENT_TYPE, selectHeaderContentType(contentTypes)); - } - - HttpMethod httpMethod = HttpMethod.valueOf(method); - HttpRequest request = getWebClient().requestAbs(httpMethod, basePath + path); - - if (httpMethod == HttpMethod.PATCH) { - request.putHeader("X-HTTP-Method-Override", "PATCH"); - } - - queryParams.forEach(entry -> { - if (entry.getValue() != null) { - request.addQueryParam(entry.getName(), entry.getValue()); - } - }); - - headerParams.forEach(entry -> { - if (entry.getValue() != null) { - request.putHeader(entry.getKey(), entry.getValue()); - } - }); - - defaultHeaders.forEach(entry -> { - if (entry.getValue() != null) { - request.putHeader(entry.getKey(), entry.getValue()); - } - }); - - Handler>> responseHandler = buildResponseHandler(returnType, resultHandler); - if (body != null) { - sendBody(request, responseHandler, body); - } else if (formParams != null && !formParams.isEmpty()) { - Map formMap = formParams.entrySet().stream().collect(toMap(Map.Entry::getKey, entry -> parameterToString(entry.getValue()))); - MultiMap form = MultiMap.caseInsensitiveMultiMap().addAll(formMap); - request.sendForm(form, responseHandler); - } else { - request.send(responseHandler); - } - } - - /** - * Sanitize filename by removing path. - * e.g. ../../sun.gif becomes sun.gif - * - * @param filename The filename to be sanitized - * @return The sanitized filename - */ - protected String sanitizeFilename(String filename) { - return filename.replaceAll(".*[/\\\\]", ""); - } - - /** - * Create a filename from the given headers. - * When the headers have no "Content-Disposition" information, a random UUID name is generated. - * - * @param headers The HTTP response headers - * @return The filename - */ - protected String generateFilename(MultiMap headers) { - String filename = UUID.randomUUID().toString(); - String contentDisposition = headers.get("Content-Disposition"); - if (contentDisposition != null && !contentDisposition.isEmpty()) { - Matcher matcher = CONTENT_DISPOSITION_PATTERN.matcher(contentDisposition); - if (matcher.find()) { - filename = sanitizeFilename(matcher.group(1)); - } - } - return filename; - } - - /** - * File Download handling. - * - * @param response The HTTP response - * @param handler The response handler - */ - protected void handleFileDownload(HttpResponse response, Handler> handler) { - FileSystem fs = getVertx().fileSystem(); - - String filename = generateFilename(response.headers()); - Consumer fileHandler = directory -> { - fs.open(directory + filename, FILE_DOWNLOAD_OPTIONS, asyncFileResult -> { - if (asyncFileResult.succeeded()) { - AsyncFile asyncFile = asyncFileResult.result(); - asyncFile.write(response.bodyAsBuffer()); - //noinspection unchecked - handler.handle(Future.succeededFuture((T) asyncFile)); - } else { - handler.handle(ApiException.fail(asyncFileResult.cause())); - } - }); - }; - - String dir = getDownloadsDir(); - if (dir != null && !dir.isEmpty()) { - fs.mkdirs(dir, mkdirResult -> { - String sanitizedFolder = dir.endsWith("/") ? dir : dir + "/"; - fileHandler.accept(sanitizedFolder); - }); - } else { - fileHandler.accept(""); - } - } - - /** - * Build a response handler for the HttpResponse. - * - * @param returnType The return type - * @param handler The response handler - * @return The HTTP response handler - */ - protected Handler>> buildResponseHandler(TypeReference returnType, - Handler> handler) { - return response -> { - AsyncResult result; - if (response.succeeded()) { - HttpResponse httpResponse = response.result(); - if (httpResponse.statusCode() / 100 == 2) { - if (httpResponse.statusCode() == 204 || returnType == null) { - result = Future.succeededFuture(null); - } else { - T resultContent; - if ("byte[]".equals(returnType.getType().toString())) { - resultContent = (T) httpResponse.body().getBytes(); - } else if (AsyncFile.class.equals(returnType.getType())) { - handleFileDownload(httpResponse, handler); - return; - } else { - resultContent = Json.decodeValue(httpResponse.body(), returnType); - } - result = Future.succeededFuture(resultContent); - } - } else { - result = ApiException.fail(httpResponse.statusMessage(), httpResponse.statusCode(), httpResponse.headers(), httpResponse.bodyAsString()); - } - } else if (response.cause() instanceof ApiException) { - result = Future.failedFuture(response.cause()); - } else { - result = ApiException.fail(500, response.cause() != null ? response.cause().getMessage() : null); - } - handler.handle(result); - }; - } - - /** - * Build the WebClient used to make HTTP requests. - * - * @param vertx Vertx - * @return WebClient - */ - protected WebClient buildWebClient(Vertx vertx, JsonObject config) { - - if (!config.containsKey("userAgent")) { - config.put("userAgent", "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/java{{/httpUserAgent}}"); - } - - return WebClient.create(vertx, new WebClientOptions(config)); - } - - - /** - * Update query and header parameters based on authentication settings. - * - * @param authNames The authentications to apply - */ - protected void updateParamsForAuth(String[] authNames, List queryParams, MultiMap headerParams) { - for (String authName : authNames) { - Authentication auth = authentications.get(authName); - if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); - auth.applyToParams(queryParams, headerParams); - } - } -} \ No newline at end of file diff --git a/src/main/resources/handlebars/Java/libraries/vertx/Configuration.mustache b/src/main/resources/handlebars/Java/libraries/vertx/Configuration.mustache deleted file mode 100644 index 17710ae160..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/Configuration.mustache +++ /dev/null @@ -1,42 +0,0 @@ -package {{invokerPackage}}; - -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; - -import java.util.Objects; - -public class Configuration { - - private static ApiClient defaultApiClient = null; - - /** - * Setup the default API client. - * Will be used by API instances when a client is not provided. - * - * @return Default API client - */ - public synchronized static ApiClient setupDefaultApiClient(Vertx vertx, JsonObject config) { - defaultApiClient = new ApiClient(vertx, config); - return defaultApiClient; - } - - /** - * Get the default API client, which would be used when creating API - * instances without providing an API client. - * - * @return Default API client - */ - public synchronized static ApiClient getDefaultApiClient() { - return defaultApiClient; - } - - /** - * Set the default API client, which would be used when creating API - * instances without providing an API client. - * - * @param apiClient API client - */ - public synchronized static void setDefaultApiClient(ApiClient apiClient) { - defaultApiClient = apiClient; - } -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/api.mustache b/src/main/resources/handlebars/Java/libraries/vertx/api.mustache deleted file mode 100644 index 6ba9fb46ce..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/api.mustache +++ /dev/null @@ -1,21 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.json.JsonObject; - -import java.util.*; - -public interface {{classname}} { - - {{#operations}} - {{#operation}} - {{#contents}} - void {{operationId}}({{#parameters}}{{{dataType}}} {{paramName}}, {{/parameters}}Handler> handler); - - {{/contents}} - {{/operation}} - {{/operations}} -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/apiException.mustache b/src/main/resources/handlebars/Java/libraries/vertx/apiException.mustache deleted file mode 100644 index 6e9bbdbb88..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/apiException.mustache +++ /dev/null @@ -1,110 +0,0 @@ -{{>licenseInfo}} - -package {{invokerPackage}}; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Future; -import io.vertx.core.MultiMap; - -{{>generatedAnnotation}} -public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{ - private int code = 0; - private MultiMap responseHeaders = null; - private String responseBody = null; - - - public static AsyncResult fail(int failureCode, String message) { - return Future.failedFuture(new ApiException(failureCode, message)); - } - - public static AsyncResult fail(Throwable throwable) { - return Future.failedFuture(new ApiException(throwable)); - } - - public static AsyncResult fail(String message) { - return Future.failedFuture(new ApiException(message)); - } - - public static AsyncResult fail(String message, Throwable throwable, int code, MultiMap responseHeaders) { - return Future.failedFuture(new ApiException(message, throwable, code, responseHeaders, null)); - } - - public static AsyncResult fail(String message, Throwable throwable, int code, MultiMap responseHeaders, String responseBody) { - return Future.failedFuture(new ApiException(message, throwable, code, responseHeaders, responseBody)); - } - - public static AsyncResult fail(String message, int code, MultiMap responseHeaders, String responseBody) { - return Future.failedFuture(new ApiException(message, (Throwable) null, code, responseHeaders, responseBody)); - } - - public static AsyncResult fail(int code, MultiMap responseHeaders, String responseBody) { - return Future.failedFuture(new ApiException((String) null, (Throwable) null, code, responseHeaders, responseBody)); - } - - public ApiException() {} - - public ApiException(Throwable throwable) { - super(throwable); - } - - public ApiException(String message) { - super(message); - } - - public ApiException(String message, Throwable throwable, int code, MultiMap responseHeaders, String responseBody) { - super(message, throwable); - this.code = code; - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - public ApiException(String message, int code, MultiMap responseHeaders, String responseBody) { - this(message, (Throwable) null, code, responseHeaders, responseBody); - } - - public ApiException(String message, Throwable throwable, int code, MultiMap responseHeaders) { - this(message, throwable, code, responseHeaders, null); - } - - public ApiException(int code, MultiMap responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); - } - - public ApiException(int code, String message) { - super(message); - this.code = code; - } - - public ApiException(int code, String message, MultiMap responseHeaders, String responseBody) { - this(code, message); - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - /** - * Get the HTTP status code. - * - * @return HTTP status code - */ - public int getCode() { - return code; - } - - /** - * Get the HTTP response headers. - * - * @return A map of list of string - */ - public MultiMap getResponseHeaders() { - return responseHeaders; - } - - /** - * Get the HTTP response body. - * - * @return Response body in the form of string - */ - public String getResponseBody() { - return responseBody; - } -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/apiImpl.mustache b/src/main/resources/handlebars/Java/libraries/vertx/apiImpl.mustache deleted file mode 100644 index d458a3d260..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/apiImpl.mustache +++ /dev/null @@ -1,93 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.MultiMap; -import io.vertx.core.json.JsonObject; - -import com.fasterxml.jackson.core.type.TypeReference; - -import java.util.*; - -import {{invokerPackage}}.ApiClient; -import {{invokerPackage}}.ApiException; -import {{invokerPackage}}.Configuration; -import {{invokerPackage}}.Pair; - -{{>generatedAnnotation}} -{{#operations}} -public class {{classname}}Impl implements {{classname}} { - - private ApiClient {{localVariablePrefix}}apiClient; - - public {{classname}}Impl() { - this(null); - } - - public {{classname}}Impl(ApiClient apiClient) { - this.{{localVariablePrefix}}apiClient = apiClient != null ? apiClient : Configuration.getDefaultApiClient(); - } - - public ApiClient getApiClient() { - return {{localVariablePrefix}}apiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.{{localVariablePrefix}}apiClient = apiClient; - } - - {{#operation}} - {{#contents}} - /** - * {{summary}} - * {{notes}} - {{#parameters}} - * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} - {{/parameters}} - * @param resultHandler Asynchronous result handler - */ - public void {{operationId}}({{#parameters}}{{{dataType}}} {{paramName}}, {{/parameters}}Handler> resultHandler) { - Object {{localVariablePrefix}}localVarBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; - {{#parameters}}{{#required}} - // verify the required parameter '{{paramName}}' is set - if ({{paramName}} == null) { - resultHandler.handle(ApiException.fail(400, "Missing the required parameter '{{paramName}}' when calling {{operationId}}")); - return; - } - {{/required}}{{/parameters}} - // create path and map variables - String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}}.replaceAll("\\{" + "{{baseName}}" + "\\}", {{{paramName}}}.toString()){{/pathParams}}; - - // query params - List {{localVariablePrefix}}localVarQueryParams = new ArrayList<>(); - {{#queryParams}} - {{localVariablePrefix}}localVarQueryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}})); - {{/queryParams}} - - // header params - MultiMap {{localVariablePrefix}}localVarHeaderParams = MultiMap.caseInsensitiveMultiMap(); - {{#headerParams}}if ({{paramName}} != null) - {{localVariablePrefix}}localVarHeaderParams.add("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}})); - {{/headerParams}} - - // form params - // TODO: sending files within multipart/form-data is not supported yet (because of vertx web-client) - Map {{localVariablePrefix}}localVarFormParams = new HashMap<>(); - {{#formParams}}if ({{paramName}} != null) {{localVariablePrefix}}localVarFormParams.put("{{baseName}}", {{paramName}}); - {{/formParams}} - - String[] {{localVariablePrefix}}localVarAccepts = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }; - String[] {{localVariablePrefix}}localVarContentTypes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }; - String[] {{localVariablePrefix}}localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; - {{#returnType}} - TypeReference<{{{returnType}}}> {{localVariablePrefix}}localVarReturnType = new TypeReference<{{{returnType}}}>() {}; - {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAccepts, {{localVariablePrefix}}localVarContentTypes, {{localVariablePrefix}}localVarAuthNames, {{localVariablePrefix}}localVarReturnType, resultHandler);{{/returnType}}{{^returnType}} - {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAccepts, {{localVariablePrefix}}localVarContentTypes, {{localVariablePrefix}}localVarAuthNames, null, resultHandler);{{/returnType}} - } - {{/contents}} - {{/operation}} -} -{{/operations}} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/api_test.mustache b/src/main/resources/handlebars/Java/libraries/vertx/api_test.mustache deleted file mode 100644 index 9aab4d3fdc..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/api_test.mustache +++ /dev/null @@ -1,70 +0,0 @@ -{{>licenseInfo}} -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import {{invokerPackage}}.Configuration; - -import org.junit.Test; -import org.junit.Ignore; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.runner.RunWith; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.json.JsonObject; -import io.vertx.core.Vertx; -import io.vertx.ext.unit.junit.VertxUnitRunner; -import io.vertx.ext.unit.junit.RunTestOnContext; -import io.vertx.ext.unit.TestContext; -import io.vertx.ext.unit.Async; - -{{^fullJavaUtil}} -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -{{/fullJavaUtil}} - -/** - * API tests for {{classname}} - */ -@RunWith(VertxUnitRunner.class) -@Ignore -public class {{classname}}Test { - - private {{classname}} api; - - @Rule - public RunTestOnContext rule = new RunTestOnContext(); - - @BeforeClass - public void setupApiClient() { - JsonObject config = new JsonObject(); - Vertx vertx = rule.vertx(); - Configuration.setupDefaultApiClient(vertx, config); - - api = new {{classname}}Impl(); - } - {{#operations}}{{#operation}}{{#contents}}{{#@first}} - /** - * {{summary}} - * {{notes}} - * - * @param context Vertx test context for doing assertions - */ - @Test - public void {{operationId}}Test(TestContext context) { - Async async = context.async(); - {{#parameters}} - {{{dataType}}} {{paramName}} = null; - {{/parameters}} - api.{{operationId}}({{#parameters}}{{paramName}}, {{/parameters}}result -> { - // TODO: test validations - async.complete(); - }); - } - {{/@first}}{{/contents}}{{/operation}}{{/operations}} -} \ No newline at end of file diff --git a/src/main/resources/handlebars/Java/libraries/vertx/auth/ApiKeyAuth.mustache b/src/main/resources/handlebars/Java/libraries/vertx/auth/ApiKeyAuth.mustache deleted file mode 100644 index 43b1866e46..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/auth/ApiKeyAuth.mustache +++ /dev/null @@ -1,64 +0,0 @@ -{{>licenseInfo}} - -package {{invokerPackage}}.auth; - -import {{invokerPackage}}.Pair; -import io.vertx.core.MultiMap; - -import java.util.List; - -{{>generatedAnnotation}} -public class ApiKeyAuth implements Authentication { - private final String location; - private final String paramName; - - private String apiKey; - private String apiKeyPrefix; - - public ApiKeyAuth(String location, String paramName) { - this.location = location; - this.paramName = paramName; - } - - public String getLocation() { - return location; - } - - public String getParamName() { - return paramName; - } - - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public String getApiKeyPrefix() { - return apiKeyPrefix; - } - - public void setApiKeyPrefix(String apiKeyPrefix) { - this.apiKeyPrefix = apiKeyPrefix; - } - - @Override - public void applyToParams(List queryParams, MultiMap headerParams) { - if (apiKey == null) { - return; - } - String value; - if (apiKeyPrefix != null) { - value = apiKeyPrefix + " " + apiKey; - } else { - value = apiKey; - } - if ("query".equals(location)) { - queryParams.add(new Pair(paramName, value)); - } else if ("header".equals(location)) { - headerParams.add(paramName, value); - } - } -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/auth/Authentication.mustache b/src/main/resources/handlebars/Java/libraries/vertx/auth/Authentication.mustache deleted file mode 100644 index 5dccb93f2a..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/auth/Authentication.mustache +++ /dev/null @@ -1,18 +0,0 @@ -{{>licenseInfo}} - -package {{invokerPackage}}.auth; - -import {{invokerPackage}}.Pair; -import io.vertx.core.MultiMap; - -import java.util.List; - -public interface Authentication { - /** - * Apply authentication settings to header and query params. - * - * @param queryParams List of query parameters - * @param headerParams Map of header parameters - */ - void applyToParams(List queryParams, MultiMap headerParams); -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/auth/HttpBasicAuth.mustache b/src/main/resources/handlebars/Java/libraries/vertx/auth/HttpBasicAuth.mustache deleted file mode 100644 index 43862b508b..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/auth/HttpBasicAuth.mustache +++ /dev/null @@ -1,40 +0,0 @@ -{{>licenseInfo}} - -package {{invokerPackage}}.auth; - -import {{invokerPackage}}.Pair; -import io.vertx.core.MultiMap; -import java.util.Base64; -import java.nio.charset.StandardCharsets; -import java.util.List; - -{{>generatedAnnotation}} -public class HttpBasicAuth implements Authentication { - private String username; - private String password; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public void applyToParams(List queryParams, MultiMap headerParams) { - if (username == null && password == null) { - return; - } - String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); - headerParams.add("Authorization", "Basic " + Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8))); - } -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/auth/OAuth.mustache b/src/main/resources/handlebars/Java/libraries/vertx/auth/OAuth.mustache deleted file mode 100644 index f3c5b34ee1..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/auth/OAuth.mustache +++ /dev/null @@ -1,28 +0,0 @@ -{{>licenseInfo}} - -package {{invokerPackage}}.auth; - -import {{invokerPackage}}.Pair; -import io.vertx.core.MultiMap; - -import java.util.List; - -{{>generatedAnnotation}} -public class OAuth implements Authentication { - private String accessToken; - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - @Override - public void applyToParams(List queryParams, MultiMap headerParams) { - if (accessToken != null) { - headerParams.add("Authorization", "Bearer " + accessToken); - } - } -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/auth/OAuthFlow.mustache b/src/main/resources/handlebars/Java/libraries/vertx/auth/OAuthFlow.mustache deleted file mode 100644 index 002e9572f3..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/auth/OAuthFlow.mustache +++ /dev/null @@ -1,7 +0,0 @@ -{{>licenseInfo}} - -package {{invokerPackage}}.auth; - -public enum OAuthFlow { - accessCode, implicit, password, application -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/vertx/build.gradle.mustache deleted file mode 100644 index 99a1532270..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/build.gradle.mustache +++ /dev/null @@ -1,63 +0,0 @@ -apply plugin: 'idea' -apply plugin: 'eclipse' - -group = '{{groupId}}' -version = '{{artifactVersion}}' - -repositories { - jcenter() -} - -apply plugin: 'java' -apply plugin: 'maven' - -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -install { - repositories.mavenInstaller { - pom.artifactId = '{{artifactId}}' - } -} - -task execute(type:JavaExec) { - main = System.getProperty('mainClass') - classpath = sourceSets.main.runtimeClasspath -} - -ext { - {{#useOas2}} - swagger_annotations_version = "1.5.15" - {{/useOas2}} - {{^useOas2}} - swagger_annotations_version = "2.0.0" - {{/useOas2}} - jackson_version = "{{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" - vertx_version = "3.4.2" - junit_version = "4.12" -} - -dependencies { - {{#useOas2}} - compile "io.swagger:swagger-annotations:$swagger_annotations_version" - {{/useOas2}} - {{^useOas2}} - compile "io.swagger.core.v3:swagger-annotations:$swagger_annotations_version" - {{/useOas2}} - compile "io.vertx:vertx-web-client:$vertx_version" - compile "io.vertx:vertx-rx-java:$vertx_version" - compile "com.fasterxml.jackson.core:jackson-core:$jackson_version" - compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" - compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version" - {{#joda}} - compile "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version" - {{/joda}} - {{#java8}} - compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version" - {{/java8}} - {{#threetenbp}} - compile "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version" - {{/threetenbp}} - testCompile "junit:junit:$junit_version" - testCompile "io.vertx:vertx-unit:$vertx_version" -} diff --git a/src/main/resources/handlebars/Java/libraries/vertx/pom.mustache b/src/main/resources/handlebars/Java/libraries/vertx/pom.mustache deleted file mode 100644 index 16bebfd374..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/pom.mustache +++ /dev/null @@ -1,273 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - {{artifactUrl}} - {{artifactDescription}} - - {{scmConnection}} - {{scmDeveloperConnection}} - {{scmUrl}} - - - 2.2.0 - - - - - {{licenseName}} - {{licenseUrl}} - repo - - - - - - {{developerName}} - {{developerEmail}} - {{developerOrganization}} - {{developerOrganizationUrl}} - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12 - - - - loggerPath - conf/log4j.properties - - - -Xms512m -Xmx1500m - methods - pertest - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory}/lib - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - - - jar - test-jar - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.0.0 - - - add_sources - generate-sources - - add-source - - - - src/main/java - - - - - add_test_sources - generate-test-sources - - add-test-source - - - - src/test/java - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.6.1 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - - - - - sign-artifacts - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - - - - - - {{#useOas2}} - - io.swagger - swagger-annotations - ${swagger-core-version} - - {{/useOas2}} - {{^useOas2}} - - io.swagger.core.v3 - swagger-annotations - ${swagger-core-version} - - {{/useOas2}} - - - - io.vertx - vertx-rx-java - ${vertx-version} - - - io.vertx - vertx-web-client - ${vertx-version} - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson-version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson-version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-version} - - {{#joda}} - - com.fasterxml.jackson.datatype - jackson-datatype-joda - ${jackson-version} - - {{/joda}} - {{#java8}} - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - ${jackson-version} - - {{/java8}} - {{#threetenbp}} - - com.github.joschi.jackson - jackson-datatype-threetenbp - ${jackson-version} - - {{/threetenbp}} - - - - junit - junit - ${junit-version} - test - - - io.vertx - vertx-unit - ${vertx-version} - test - - - - - UTF-8 - 3.4.2 - {{#useOas2}} - 1.5.16 - {{/useOas2}} - {{^useOas2}} - 2.0.0 - {{/useOas2}} - {{^threetenbp}}2.8.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} - 4.12 - - diff --git a/src/main/resources/handlebars/Java/libraries/vertx/rxApiImpl.mustache b/src/main/resources/handlebars/Java/libraries/vertx/rxApiImpl.mustache deleted file mode 100644 index eeadbb77ac..0000000000 --- a/src/main/resources/handlebars/Java/libraries/vertx/rxApiImpl.mustache +++ /dev/null @@ -1,60 +0,0 @@ -package {{package}}.rxjava; - -{{#imports}}import {{import}}; -{{/imports}} - -import java.util.*; - -import rx.Single; -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; - -{{>generatedAnnotation}} -{{#operations}} -public class {{classname}} { - - private final {{package}}.{{classname}} delegate; - - public {{classname}}({{package}}.{{classname}} delegate) { - this.delegate = delegate; - } - - public {{package}}.{{classname}} getDelegate() { - return delegate; - } - - {{#operation}} - {{#contents}} - /** - * {{summary}} - * {{notes}} - {{#parameters}} - * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} - {{/parameters}} - * @param resultHandler Asynchronous result handler - */ - public void {{operationId}}({{#parameters}}{{{dataType}}} {{paramName}}, {{/parameters}}Handler> resultHandler) { - delegate.{{operationId}}({{#parameters}}{{paramName}}, {{/parameters}}resultHandler); - } - - /** - * {{summary}} - * {{notes}} - {{#parameters}} - * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} - {{/parameters}} - * @return Asynchronous result handler (RxJava Single) - */ - public Single<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> rx{{operationIdCamelCase}}({{#parameters}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}) { - return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { - delegate.{{operationId}}({{#parameters}}{{paramName}}, {{/parameters}}fut); - })); - } - {{/contents}} - {{/operation}} - - public static {{classname}} newInstance({{package}}.{{classname}} arg) { - return arg != null ? new {{classname}}(arg) : null; - } -} -{{/operations}} diff --git a/src/main/resources/handlebars/Java/pojo.mustache b/src/main/resources/handlebars/Java/pojo.mustache index 74df105514..7a557ef7a5 100644 --- a/src/main/resources/handlebars/Java/pojo.mustache +++ b/src/main/resources/handlebars/Java/pojo.mustache @@ -4,7 +4,7 @@ {{#description}}{{#useOas2}}@ApiModel{{/useOas2}}{{^useOas2}}@Schema{{/useOas2}}(description = "{{{description}}}"){{/description}} {{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} -public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{#interfaceModels}}{{#@first}}, {{/@first}}{{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable{{#interfaceModels}}, {{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{^serializableModel}}{{#interfaceModels}}{{#@first}}implements {{/@first}}{{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{/parcelableModel}}{ +public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{#interfaceModels}}{{#@first}}, {{/@first}}{{classname}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable{{#interfaceModels}}, {{classname}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{^serializableModel}}{{#interfaceModels}}{{#@first}}implements {{/@first}}{{classname}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{/parcelableModel}}{ {{#serializableModel}} private static final long serialVersionUID = 1L; {{/serializableModel}} diff --git a/src/main/resources/handlebars/Java/pom.mustache b/src/main/resources/handlebars/Java/pom.mustache index 82c950458f..a821e48810 100644 --- a/src/main/resources/handlebars/Java/pom.mustache +++ b/src/main/resources/handlebars/Java/pom.mustache @@ -322,7 +322,7 @@ 2.5 3.6 {{/supportJava6}} - {{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} + {{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} 1.0.0 4.12 diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache index af92f7cc7e..cf499831f8 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache @@ -41,7 +41,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{#useOas2}}@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}"){{/useOas2}} {{^useOas2}}@Schema({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}"){{/useOas2}} @JsonProperty("{{baseName}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache index b0996f0ce1..e4ba76b6db 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache @@ -69,14 +69,14 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#interfa {{#vendorExtensions.extraAnnotation}} {{{vendorExtensions.extraAnnotation}}} {{/vendorExtensions.extraAnnotation}} -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#is this 'enum'}}{{#isNot this 'list-container'}}{{#isNot this 'map-container'}}public {{datatype}} {{#is this 'boolean'}}is{{/is}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#is this 'enum'}}{{#isNot this 'list-container'}}{{#isNot this 'map-container'}}public {{datatype}} {{getter}}() { if ({{name}} == null) { return null; } return {{name}}.getValue(); - }{{/isNot}}{{/isNot}}{{/is}}{{#is this 'enum'}}{{#is this 'list-container'}}public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() { + }{{/isNot}}{{/isNot}}{{/is}}{{#is this 'enum'}}{{#is this 'list-container'}}public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; - }{{/is}}{{/is}}{{#is this 'enum'}}{{#is this 'map-container'}}public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() { + }{{/is}}{{/is}}{{#is this 'enum'}}{{#is this 'map-container'}}public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; }{{/is}}{{/is}}{{#isNot this 'enum'}}public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache index f71a06d9bc..912b7a4ecb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/api.mustache @@ -29,7 +29,8 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.*; -@Path("/{{{baseName}}}") +{{#apiBasePath}}@Path("/{{{apiBasePath}}}"){{/apiBasePath}} +{{^apiBasePath}}@Path("/{{{baseName}}}"){{/apiBasePath}} {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}} {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} @io.swagger.annotations.Api(description = "the {{{baseName}}} API") @@ -57,7 +58,7 @@ public class {{classname}} { {{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}, {{/parameters}}@Context SecurityContext securityContext) throws NotFoundException { - return delegate.{{nickname}}({{#parameters}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/parameters}}securityContext); + return delegate.{{nickname}}({{#parameters}}{{#isFile}} {{paramName}}InputStream, {{paramName}}Detail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}},{{/parameters}}securityContext); } {{/contents}} {{/operation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache index 5a0da70233..1be7abd835 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache @@ -5,10 +5,15 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; +{{#java8}} +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +{{/java8}} +{{#joda}} import com.fasterxml.jackson.datatype.joda.JodaModule; import org.joda.time.DateTime; import org.joda.time.LocalDate; import org.joda.time.format.ISODateTimeFormat; +{{/joda}} import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; @@ -21,7 +26,11 @@ public class JacksonConfig implements ContextResolver { public JacksonConfig() throws Exception { objectMapper = new ObjectMapper() - .setDateFormat(new RFC3339DateFormat()) + .setDateFormat(new RFC3339DateFormat()){{#legacyDates}};{{/legacyDates}} +{{#java8}} + .registerModule(new JavaTimeModule()); +{{/java8}} +{{#joda}} .registerModule(new JodaModule() { { addSerializer(DateTime.class, new StdSerializer(DateTime.class) { @@ -39,9 +48,10 @@ public class JacksonConfig implements ContextResolver { } }); +{{/joda}} } public ObjectMapper getContext(Class arg0) { return objectMapper; } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/README.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/README.mustache index 45ce075085..55614c33fb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/README.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/README.mustache @@ -10,7 +10,7 @@ This example uses the [JAX-RS](https://jax-rs-spec.java.net/) framework. To run the server, please execute the following: ``` -mvn clean package jetty:run +mvn clean package ``` You can then view the swagger listing here: diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/gradle.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/gradle.mustache index df8a82b461..63c6384938 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/gradle.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/gradle.mustache @@ -19,11 +19,11 @@ dependencies { providedCompile 'javax.validation:validation-api:1.1.0.Final' {{/useBeanValidation}} {{^java8}} - compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.9' + compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.10' compile 'joda-time:joda-time:2.7' {{/java8}} {{#java8}} - compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.9' + compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.10' {{/java8}} testCompile 'junit:junit:4.12', 'org.hamcrest:hamcrest-core:1.3' diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pojo.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pojo.mustache index a1349c26cd..a2004cbc17 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pojo.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pojo.mustache @@ -40,7 +40,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali @Schema({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}") {{/useOas2}} @JsonProperty("{{baseName}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache index 790d435828..91ecdd5e08 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache @@ -195,30 +195,30 @@ com.fasterxml.jackson.datatype jackson-datatype-joda - 2.9.9 + 2.9.10 {{/java8}} {{#java8}} com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.9.9 + 2.9.10 {{/java8}} com.fasterxml.jackson.core jackson-databind - 2.9.9 + 2.9.10 com.fasterxml.jackson.core jackson-core - 2.9.9 + 2.9.10 com.fasterxml.jackson.core jackson-annotations - 2.9.9 + 2.9.10 org.apache.httpcomponents diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache index 47af212cf4..6f9f711d4f 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache @@ -22,17 +22,23 @@ dependencies { compile 'io.swagger.core.v3:swagger-annotations:2.0.0' {{/useOas2}} compile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.11.Final' + compile 'org.apache.httpcomponents:httpclient:4.5.10' {{#useBeanValidation}} providedCompile 'javax.validation:validation-api:1.1.0.Final' {{/useBeanValidation}} - compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.4.1' +{{^java8}} + compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.10' compile 'joda-time:joda-time:2.7' +{{/java8}} +{{#java8}} + compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.10' +{{/java8}} //TODO: swaggerFeature {{#useOas2}} compile 'io.swagger:swagger-jaxrs:1.5.12' {{/useOas2}} {{^useOas2}} - compile 'io.swagger.core.v3:swagger-jaxrs2:2.0.0' + compile 'io.swagger.core.v3:swagger-jaxrs2:2.0.9' {{/useOas2}} testCompile 'junit:junit:4.12', diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/pojo.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/pojo.mustache index e1ba9f4e69..746cb2c86f 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/pojo.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/pojo.mustache @@ -35,7 +35,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali @Schema({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}description = "{{{description}}}") {{/useOas2}} @JsonProperty("{{baseName}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#is this 'boolean'}}is{{/is}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache index 57cf4c95aa..3610b9170b 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache @@ -126,7 +126,14 @@ 1.2 provided - +{{#java8}} + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + +{{/java8}} +{{^java8}} com.fasterxml.jackson.datatype jackson-datatype-joda @@ -137,6 +144,7 @@ joda-time 2.7 +{{/java8}} {{#useOas2}} io.swagger @@ -177,6 +185,12 @@ + + org.apache.httpcomponents + httpclient + 4.5.10 + test + {{#useBeanValidation}} @@ -202,12 +216,13 @@ 1.5.18 {{/useOas2}} {{^useOas2}} - 2.0.0 + 2.0.9 {{/useOas2}} 9.2.9.v20150224 3.0.11.Final 1.6.3 4.8.1 2.5 + {{#java8}}2.9.10{{/java8}} diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/pojo.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/pojo.mustache index 7e2b91fae6..25155a6fc0 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/pojo.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/pojo.mustache @@ -45,7 +45,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{>beanValidation}} {{/useBeanValidation}} - public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { + public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/handlebars/JavaSpring/TestUtils.mustache b/src/main/resources/handlebars/JavaSpring/TestUtils.mustache new file mode 100644 index 0000000000..2165f2232b --- /dev/null +++ b/src/main/resources/handlebars/JavaSpring/TestUtils.mustache @@ -0,0 +1,17 @@ +package {{basePackage}}; + +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; + +public class TestUtils { + private static final AtomicLong atomicId = createAtomicId(); + + public static long nextId() { + return atomicId.getAndIncrement(); + } + + private static AtomicLong createAtomicId() { + int baseId = new Random(System.currentTimeMillis()).nextInt(1000000) + 20000; + return new AtomicLong((long) baseId); + } +} diff --git a/src/main/resources/handlebars/JavaSpring/api.mustache b/src/main/resources/handlebars/JavaSpring/api.mustache index 7551be6b6f..5e5fb76c7d 100644 --- a/src/main/resources/handlebars/JavaSpring/api.mustache +++ b/src/main/resources/handlebars/JavaSpring/api.mustache @@ -61,17 +61,17 @@ public interface {{classname}} { {{^isDelegate}} Logger log = LoggerFactory.getLogger({{classname}}.class); - default Optional getObjectMapper() { + {{#defaultInterfaces}}default {{/defaultInterfaces}}Optional getObjectMapper(){{^defaultInterfaces}};{{/defaultInterfaces}}{{#defaultInterfaces}}{ return Optional.empty(); - } + }{{/defaultInterfaces}} - default Optional getRequest() { + {{#defaultInterfaces}}default {{/defaultInterfaces}}Optional getRequest(){{^defaultInterfaces}};{{/defaultInterfaces}}{{#defaultInterfaces}}{ return Optional.empty(); - } + }{{/defaultInterfaces}} - default Optional getAcceptHeader() { + {{#defaultInterfaces}}default Optional getAcceptHeader() { return getRequest().map(r -> r.getHeader("Accept")); - } + }{{/defaultInterfaces}} {{/isDelegate}} {{#isDelegate}} {{classname}}Delegate getDelegate(); @@ -81,9 +81,8 @@ public interface {{classname}} { {{#contents}} @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { - {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { - {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, - {{/hasMore}}{{/scopes}} + {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { {{#each scopes}} + @AuthorizationScope(scope = "{{@key}}", description = "{{this}}"){{^@last}},{{/@last}}{{/each}} }{{/isOAuth}}){{#hasMore}}, {{/hasMore}}{{/authMethods}} }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} }) @@ -102,7 +101,7 @@ public interface {{classname}} { produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} method = RequestMethod.{{httpMethod}}) - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { + {{#defaultInterfaces}}default {{/defaultInterfaces}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}){{^defaultInterfaces}};{{/defaultInterfaces}}{{#defaultInterfaces}} { {{#delegate-method}} return {{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); } @@ -130,7 +129,7 @@ public interface {{classname}} { {{#isDelegate}} return getDelegate().{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); {{/isDelegate}} - }{{/jdk8}} + }{{/defaultInterfaces}} {{/contents}} {{/operation}} diff --git a/src/main/resources/handlebars/JavaSpring/apiController.mustache b/src/main/resources/handlebars/JavaSpring/apiController.mustache index ab8eb2d9bc..361e480278 100644 --- a/src/main/resources/handlebars/JavaSpring/apiController.mustache +++ b/src/main/resources/handlebars/JavaSpring/apiController.mustache @@ -1,21 +1,21 @@ package {{package}}; -{{^jdk8}} +{{#fullController}} {{#imports}}import {{import}}; {{/imports}} -{{/jdk8}} +{{/fullController}} {{^isDelegate}} import com.fasterxml.jackson.databind.ObjectMapper; {{/isDelegate}} -{{^jdk8}} +{{#fullController}} import io.swagger.annotations.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -{{/jdk8}} +{{/fullController}} import org.springframework.stereotype.Controller; -{{^jdk8}} +{{#fullController}} import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -27,7 +27,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.*; import javax.validation.Valid; {{/useBeanValidation}} -{{/jdk8}} +{{/fullController}} {{^isDelegate}} import javax.servlet.http.HttpServletRequest; {{#jdk8}} @@ -39,7 +39,7 @@ import java.util.Optional; import java.util.Optional; {{/useOptional}} {{/jdk8-no-delegate}} -{{^jdk8}} +{{#fullController}} {{^isDelegate}} import java.io.IOException; {{/isDelegate}} @@ -48,7 +48,7 @@ import java.util.Map; {{#async}} import java.util.concurrent.Callable; {{/async}} -{{/jdk8}} +{{/fullController}} {{>generatedAnnotation}} @Controller {{#operations}} @@ -70,10 +70,10 @@ public class {{classname}}Controller implements {{classname}} { {{/jdk8}} {{/isDelegate}} {{^isDelegate}} - {{^jdk8}} + {{#fullController}} private static final Logger log = LoggerFactory.getLogger({{classname}}Controller.class); - {{/jdk8}} + {{/fullController}} private final ObjectMapper objectMapper; private final HttpServletRequest request; @@ -97,7 +97,7 @@ public class {{classname}}Controller implements {{classname}} { {{/jdk8}} {{/isDelegate}} -{{^jdk8}} +{{#fullController}} {{#operation}} {{#contents}} public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { @@ -145,6 +145,6 @@ public class {{classname}}Controller implements {{classname}} { {{/contents}} {{/operation}} -{{/jdk8}} +{{/fullController}} } {{/operations}} diff --git a/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache b/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache index c75596caea..ee740a321c 100644 --- a/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache +++ b/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache @@ -45,17 +45,17 @@ public interface {{classname}}Delegate { Logger log = LoggerFactory.getLogger({{classname}}.class); - default Optional getObjectMapper() { + {{#defaultInterfaces}}default {{/defaultInterfaces}}Optional getObjectMapper(){{^defaultInterfaces}};{{/defaultInterfaces}}{{#defaultInterfaces}}{ return Optional.empty(); - } + }{{/defaultInterfaces}} - default Optional getRequest() { + {{#defaultInterfaces}}default {{/defaultInterfaces}}Optional getRequest(){{^defaultInterfaces}};{{/defaultInterfaces}}{{#defaultInterfaces}}{ return Optional.empty(); - } + }{{/defaultInterfaces}} - default Optional getAcceptHeader() { + {{#defaultInterfaces}}default Optional getAcceptHeader() { return getRequest().map(r -> r.getHeader("Accept")); - } + }{{/defaultInterfaces}} {{/jdk8}} {{#operation}} @@ -63,8 +63,8 @@ public interface {{classname}}Delegate { /** * @see {{classname}}#{{operationId}} */ - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, - {{/hasMore}}{{/parameters}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { + {{#defaultInterfaces}}default {{/defaultInterfaces}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, + {{/hasMore}}{{/parameters}}){{^defaultInterfaces}};{{/defaultInterfaces}}{{#defaultInterfaces}} { if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { {{#examples}} if (getAcceptHeader().get().contains("{{{contentType}}}")) { @@ -80,7 +80,7 @@ public interface {{classname}}Delegate { log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); } return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - }{{/jdk8}} + }{{/defaultInterfaces}} {{/contents}} {{/operation}} diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache index da72c2bb8d..72ddaba231 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.22.RELEASE + {{springBootVersion}} src/main/java diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/Application.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/Application.mustache index 372b8da31e..3708ed46f1 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/Application.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/Application.mustache @@ -3,7 +3,12 @@ package io.swagger; import feign.Logger; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; +{{^isOpenFeign}} import org.springframework.cloud.netflix.feign.EnableFeignClients; +{{/isOpenFeign}} +{{#isOpenFeign}} +import org.springframework.cloud.openfeign.EnableFeignClients; +{{/isOpenFeign}} import org.springframework.context.annotation.Bean; @SpringBootApplication diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/apiClient.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/apiClient.mustache index 52fedbea77..dc4afa0ea3 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/apiClient.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/apiClient.mustache @@ -1,10 +1,15 @@ package {{package}}; +{{^isOpenFeign}} import org.springframework.cloud.netflix.feign.FeignClient; +{{/isOpenFeign}} +{{#isOpenFeign}} +import org.springframework.cloud.openfeign.FeignClient; +{{/isOpenFeign}} import {{configPackage}}.ClientConfiguration; {{=<% %>=}} -@FeignClient(name="${<%title%>.name:<%title%>}", url="${<%title%>.url:<%basePath%>}", configuration = ClientConfiguration.class) +@FeignClient(<%#isOpenFeign%>contextId="<%classname%>Client", <%/isOpenFeign%>name="${<%title%>.name:<%title%>}", url="${<%title%>.url:<%basePath%>}", configuration = ClientConfiguration.class) <%={{ }}=%> public interface {{classname}}Client extends {{classname}} { -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/application-test.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/application-test.mustache new file mode 100644 index 0000000000..49e253e9ae --- /dev/null +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/application-test.mustache @@ -0,0 +1,11 @@ +spring: + application: + name: {{artifactId}}-test + jackson: + serialization.WRITE_DATES_AS_TIMESTAMPS: false + +hystrix.command.default.execution.timeout.enabled: false + +logging.level.{{apiPackage}}: DEBUG + +feign.hystrix.enabled: true diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache index 9efcee55a5..e53a952bc0 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 1.5.4.RELEASE + {{springBootVersion}} src/main/java @@ -25,7 +25,7 @@ org.springframework.cloud spring-cloud-starter-parent - Dalston.SR1 + {{^springBootV2}}Dalston.SR1{{/springBootV2}}{{#springBootV2}}Greenwich.RELEASE{{/springBootV2}} pom import @@ -38,7 +38,7 @@ swagger-annotations ${swagger-core-version} - + {{^springBootV2}} org.springframework.cloud spring-cloud-starter-feign @@ -49,7 +49,23 @@ org.springframework.security.oauth spring-security-oauth2 + {{/springBootV2}} + {{#springBootV2}} + org.springframework.cloud + spring-cloud-starter-openfeign + 2.1.3.RELEASE + + + org.springframework.cloud + spring-cloud-security + 2.1.4.RELEASE + + org.springframework.security.oauth + spring-security-oauth2 + 2.3.6.RELEASE + {{/springBootV2}} + {{#withXml}} diff --git a/src/main/resources/handlebars/JavaSpring/pojo.mustache b/src/main/resources/handlebars/JavaSpring/pojo.mustache index 492e8084b8..812e5ebfa0 100644 --- a/src/main/resources/handlebars/JavaSpring/pojo.mustache +++ b/src/main/resources/handlebars/JavaSpring/pojo.mustache @@ -92,7 +92,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{{vendorExtensions.extraAnnotation}}} {{/vendorExtensions.extraAnnotation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { + {{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } diff --git a/src/main/resources/handlebars/JavaSpring2/api.mustache b/src/main/resources/handlebars/JavaSpring2/api.mustache deleted file mode 100644 index 7551be6b6f..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/api.mustache +++ /dev/null @@ -1,138 +0,0 @@ -/** - * NOTE: This class is auto generated by the swagger code generator program ({{{generatorVersion}}}). - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -{{#jdk8-no-delegate}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/jdk8-no-delegate}} -import io.swagger.annotations.*; -{{#jdk8-no-delegate}} -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -{{/jdk8-no-delegate}} -import org.springframework.http.ResponseEntity; -{{#useBeanValidation}} -import org.springframework.validation.annotation.Validated; -{{/useBeanValidation}} -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -{{#jdk8-no-delegate}} -import javax.servlet.http.HttpServletRequest; -{{/jdk8-no-delegate}} -{{#useBeanValidation}} -import javax.validation.Valid; -import javax.validation.constraints.*; -{{/useBeanValidation}} -{{#jdk8-no-delegate}} -import java.io.IOException; -{{/jdk8-no-delegate}} -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}} -@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") -{{#operations}} -public interface {{classname}} { -{{#jdk8}} - - {{^isDelegate}} - Logger log = LoggerFactory.getLogger({{classname}}.class); - - default Optional getObjectMapper() { - return Optional.empty(); - } - - default Optional getRequest() { - return Optional.empty(); - } - - default Optional getAcceptHeader() { - return getRequest().map(r -> r.getHeader("Accept")); - } - {{/isDelegate}} - {{#isDelegate}} - {{classname}}Delegate getDelegate(); - {{/isDelegate}} -{{/jdk8}} -{{#operation}} -{{#contents}} - - @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { - {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { - {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, - {{/hasMore}}{{/scopes}} - }{{/isOAuth}}){{#hasMore}}, - {{/hasMore}}{{/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}}){{#hasMore}},{{/hasMore}}{{/responses}} }) - {{#implicitHeaders}} - @ApiImplicitParams({ - {{#headerParams}} - {{>implicitHeader}} - {{/headerParams}} - }) - {{/implicitHeaders}} - @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}}{{#hasProduces}} - produces = "{{{vendorExtensions.x-accepts}}}", {{/hasProduces}}{{#hasConsumes}} - consumes = "{{{vendorExtensions.x-contentType}}}",{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} - produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} - consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} - method = RequestMethod.{{httpMethod}}) - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { - {{#delegate-method}} - return {{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - } - - // Override this method - default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { - {{/delegate-method}} - {{^isDelegate}} - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - {{#examples}} - if (getAcceptHeader().get().contains("{{{contentType}}}")) { - try { - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; - } - } - {{/examples}} - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); - } - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - {{/isDelegate}} - {{#isDelegate}} - return getDelegate().{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - {{/isDelegate}} - }{{/jdk8}} - -{{/contents}} -{{/operation}} -} -{{/operations}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/apiController.mustache b/src/main/resources/handlebars/JavaSpring2/apiController.mustache deleted file mode 100644 index ab8eb2d9bc..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/apiController.mustache +++ /dev/null @@ -1,150 +0,0 @@ -package {{package}}; - -{{^jdk8}} -{{#imports}}import {{import}}; -{{/imports}} -{{/jdk8}} -{{^isDelegate}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/isDelegate}} -{{^jdk8}} -import io.swagger.annotations.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -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; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - - {{#useBeanValidation}} -import javax.validation.constraints.*; -import javax.validation.Valid; - {{/useBeanValidation}} -{{/jdk8}} -{{^isDelegate}} -import javax.servlet.http.HttpServletRequest; - {{#jdk8}} -import java.util.Optional; - {{/jdk8}} -{{/isDelegate}} -{{^jdk8-no-delegate}} - {{#useOptional}} -import java.util.Optional; - {{/useOptional}} -{{/jdk8-no-delegate}} -{{^jdk8}} - {{^isDelegate}} -import java.io.IOException; - {{/isDelegate}} -import java.util.List; -import java.util.Map; - {{#async}} -import java.util.concurrent.Callable; - {{/async}} -{{/jdk8}} -{{>generatedAnnotation}} -@Controller -{{#operations}} -public class {{classname}}Controller implements {{classname}} { - -{{#isDelegate}} - private final {{classname}}Delegate delegate; - - @org.springframework.beans.factory.annotation.Autowired - public {{classname}}Controller({{classname}}Delegate delegate) { - this.delegate = delegate; - } - {{#jdk8}} - - @Override - public {{classname}}Delegate getDelegate() { - return delegate; - } - {{/jdk8}} -{{/isDelegate}} -{{^isDelegate}} - {{^jdk8}} - private static final Logger log = LoggerFactory.getLogger({{classname}}Controller.class); - - {{/jdk8}} - private final ObjectMapper objectMapper; - - private final HttpServletRequest request; - - @org.springframework.beans.factory.annotation.Autowired - public {{classname}}Controller(ObjectMapper objectMapper, HttpServletRequest request) { - this.objectMapper = objectMapper; - this.request = request; - } - {{#jdk8}} - - @Override - public Optional getObjectMapper() { - return Optional.ofNullable(objectMapper); - } - - @Override - public Optional getRequest() { - return Optional.ofNullable(request); - } - {{/jdk8}} - -{{/isDelegate}} -{{^jdk8}} -{{#operation}} -{{#contents}} - public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { - {{^isDelegate}} - {{^async}} - String accept = request.getHeader("Accept"); - {{#examples}} - if (accept != null && accept.contains("{{{contentType}}}")) { - try { - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - {{/examples}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED); - {{/async}} - {{#async}} - return new CallablereturnTypes}}>>() { - @Override - public ResponseEntity<{{>returnTypes}}> call() { - String accept = request.getHeader("Accept"); - {{#examples}} - if (accept != null && accept.contains("{{{contentType}}}")) { - try { - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - {{/examples}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED); - } - }; - {{/async}} - {{/isDelegate}} - {{#isDelegate}} - return delegate.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - {{/isDelegate}} - } - -{{/contents}} -{{/operation}} -{{/jdk8}} -} -{{/operations}} diff --git a/src/main/resources/handlebars/JavaSpring2/apiDelegate.mustache b/src/main/resources/handlebars/JavaSpring2/apiDelegate.mustache deleted file mode 100644 index c75596caea..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/apiDelegate.mustache +++ /dev/null @@ -1,88 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -{{#jdk8}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/jdk8}} -import io.swagger.annotations.*; -{{#jdk8}} -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -{{/jdk8}} -import org.springframework.http.ResponseEntity; -import org.springframework.web.multipart.MultipartFile; -{{#jdk8}} -import java.io.IOException; -{{/jdk8}} - -{{#jdk8}} -import javax.servlet.http.HttpServletRequest; -{{/jdk8}} -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}} - - Logger log = LoggerFactory.getLogger({{classname}}.class); - - default Optional getObjectMapper() { - return Optional.empty(); - } - - default Optional getRequest() { - return Optional.empty(); - } - - default Optional getAcceptHeader() { - return getRequest().map(r -> r.getHeader("Accept")); - } -{{/jdk8}} - -{{#operation}} -{{#contents}} - /** - * @see {{classname}}#{{operationId}} - */ - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, - {{/hasMore}}{{/parameters}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - {{#examples}} - if (getAcceptHeader().get().contains("{{{contentType}}}")) { - try { - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; - } - } - {{/examples}} - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); - } - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - }{{/jdk8}} - -{{/contents}} -{{/operation}} -} -{{/operations}} diff --git a/src/main/resources/handlebars/JavaSpring2/apiException.mustache b/src/main/resources/handlebars/JavaSpring2/apiException.mustache deleted file mode 100644 index f616114770..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/apiException.mustache +++ /dev/null @@ -1,10 +0,0 @@ -package {{apiPackage}}; - -{{>generatedAnnotation}} -public class ApiException extends Exception{ - private int code; - public ApiException (int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/src/main/resources/handlebars/JavaSpring2/apiOriginFilter.mustache b/src/main/resources/handlebars/JavaSpring2/apiOriginFilter.mustache deleted file mode 100644 index 5cf72a7dc4..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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/src/main/resources/handlebars/JavaSpring2/apiResponseMessage.mustache b/src/main/resources/handlebars/JavaSpring2/apiResponseMessage.mustache deleted file mode 100644 index 17b155f3b6..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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/src/main/resources/handlebars/JavaSpring2/application.mustache b/src/main/resources/handlebars/JavaSpring2/application.mustache deleted file mode 100644 index cf9520a7e7..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/application.mustache +++ /dev/null @@ -1,5 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -server.servlet.context-path={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} -server.port={{serverPort}} -spring.jackson.date-format={{basePackage}}.RFC3339DateFormat -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/src/main/resources/handlebars/JavaSpring2/application.properties b/src/main/resources/handlebars/JavaSpring2/application.properties deleted file mode 100644 index 99ebf4d7c5..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/application.properties +++ /dev/null @@ -1 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs diff --git a/src/main/resources/handlebars/JavaSpring2/beanValidation.mustache b/src/main/resources/handlebars/JavaSpring2/beanValidation.mustache deleted file mode 100644 index 3e4ef612a4..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/beanValidation.mustache +++ /dev/null @@ -1,6 +0,0 @@ -{{#required}} - @NotNull -{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}} - @Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{#isNotContainer}}{{^isPrimitiveType}} - @Valid{{/isPrimitiveType}}{{/isNotContainer}} -{{>beanValidationCore}} diff --git a/src/main/resources/handlebars/JavaSpring2/beanValidationCore.mustache b/src/main/resources/handlebars/JavaSpring2/beanValidationCore.mustache deleted file mode 100644 index 29d043cc77..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/beanValidationCore.mustache +++ /dev/null @@ -1,20 +0,0 @@ -{{#pattern}}@Pattern(regexp="{{{pattern}}}"{{#vendorExtensions.x-pattern-message}}, message="{{vendorExtensions.x-pattern-message}}"{{/vendorExtensions.x-pattern-message}}) {{/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}}{{! -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("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}") {{/maximum}}{{/isLong}}{{/isInteger}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/beanValidationPathParams.mustache b/src/main/resources/handlebars/JavaSpring2/beanValidationPathParams.mustache deleted file mode 100644 index 051bd53c0a..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/beanValidationPathParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/beanValidationQueryParams.mustache b/src/main/resources/handlebars/JavaSpring2/beanValidationQueryParams.mustache deleted file mode 100644 index 9cca8cb887..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/beanValidationQueryParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#required}}@NotNull {{/required}}{{>beanValidationCore}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/bodyParams.mustache b/src/main/resources/handlebars/JavaSpring2/bodyParams.mustache deleted file mode 100644 index 7fef9ad2b6..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/bodyParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/customInstantDeserializer.mustache b/src/main/resources/handlebars/JavaSpring2/customInstantDeserializer.mustache deleted file mode 100644 index b7b8e251bd..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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.DateTimeUtils; -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.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.timeZoneToZoneId(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/src/main/resources/handlebars/JavaSpring2/enumClass.mustache b/src/main/resources/handlebars/JavaSpring2/enumClass.mustache deleted file mode 100644 index 3a77cb0f36..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/enumClass.mustache +++ /dev/null @@ -1,44 +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; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { - for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } diff --git a/src/main/resources/handlebars/JavaSpring2/enumOuterClass.mustache b/src/main/resources/handlebars/JavaSpring2/enumOuterClass.mustache deleted file mode 100644 index 1ca135d46b..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/enumOuterClass.mustache +++ /dev/null @@ -1,42 +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; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { - for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } -} diff --git a/src/main/resources/handlebars/JavaSpring2/exampleReturnTypes.mustache b/src/main/resources/handlebars/JavaSpring2/exampleReturnTypes.mustache deleted file mode 100644 index 395e3889c2..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/exampleReturnTypes.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/formParams.mustache b/src/main/resources/handlebars/JavaSpring2/formParams.mustache deleted file mode 100644 index f9c3e502b8..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/formParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^@last}}, {{/@last}}{{#@last}}{{/@last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaSpring2/generatedAnnotation.mustache deleted file mode 100644 index ad17a426e9..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/generatedAnnotation.mustache +++ /dev/null @@ -1,3 +0,0 @@ -{{^hideGenerationTimestamp}} -@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") -{{/hideGenerationTimestamp}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/headerParams.mustache b/src/main/resources/handlebars/JavaSpring2/headerParams.mustache deleted file mode 100644 index 2c8aa49d7d..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/headerParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^@last}}, {{/@last}}{{#@last}}{{/@last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/implicitHeader.mustache b/src/main/resources/handlebars/JavaSpring2/implicitHeader.mustache deleted file mode 100644 index 64d7af2080..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/implicitHeader.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isHeaderParam}}@ApiImplicitParam(name = "{{{paramName}}}", value = "{{{description}}}", {{#required}}required=true,{{/required}} dataType = "{{{dataType}}}", paramType = "header"){{#hasMore}},{{/hasMore}}{{/isHeaderParam}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/interface.mustache b/src/main/resources/handlebars/JavaSpring2/interface.mustache deleted file mode 100644 index becc0c5549..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/interface.mustache +++ /dev/null @@ -1,6 +0,0 @@ -/** -* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} -*/ -public interface {{{classname}}} { - -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/README.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/README.mustache deleted file mode 100644 index 02d932b8ac..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/README.mustache +++ /dev/null @@ -1,45 +0,0 @@ -{{^interfaceOnly}}# Swagger generated server - -Spring Boot Server - - -## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. -This is an example of building a swagger-enabled server in Java using the SpringBoot framework. - -The underlying library integrating swagger to SpringBoot is [springfox](https://github.com/springfox/springfox) - -Start your server as an simple java application - -You can view the api documentation in swagger-ui by pointing to -http://localhost:8080/ - -Change default port value in application.properties{{/interfaceOnly}}{{#interfaceOnly}} -# Swagger generated API stub - -Spring Framework stub - - -## Overview -This code was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), 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/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/RFC3339DateFormat.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/RFC3339DateFormat.mustache deleted file mode 100644 index d5dff8ac63..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/RFC3339DateFormat.mustache +++ /dev/null @@ -1,22 +0,0 @@ -package {{basePackage}}; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - - -public class RFC3339DateFormat extends ISO8601DateFormat { - - private static final long serialVersionUID = 1L; - - // Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/api_test.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/api_test.mustache deleted file mode 100644 index 6558eb235c..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/api_test.mustache +++ /dev/null @@ -1,45 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import java.util.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.junit.Assert.assertEquals; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class {{classname}}ControllerIntegrationTest { - - @Autowired - private {{classname}} api; - - {{#operations}} - {{#operation}} - {{#contents}} - @Test - public void {{operationId}}Test() throws Exception { - {{#parameters}} - {{^isFile}} - {{{dataType}}} {{paramName}} = {{{example}}}; - {{/isFile}} - {{#isFile}} - org.springframework.web.multipart.MultipartFile {{paramName}} = null; - {{/isFile}} - {{/parameters}} - ResponseEntity<{{>returnTypes}}> responseEntity = api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); - } - - {{/contents}} - {{/operation}} - {{/operations}} -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/homeController.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/homeController.mustache deleted file mode 100644 index 91a07d5efb..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/homeController.mustache +++ /dev/null @@ -1,16 +0,0 @@ -package {{configPackage}}; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * Home redirection to swagger api documentation - */ -@Controller -public class HomeController { - @RequestMapping(value = "/") - public String index() { - System.out.println("swagger-ui.html"); - return "redirect:swagger-ui.html"; - } -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/jacksonConfiguration.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/jacksonConfiguration.mustache deleted file mode 100644 index e96aa772c6..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/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/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/pom.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/pom.mustache deleted file mode 100644 index cc40757b88..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/pom.mustache +++ /dev/null @@ -1,102 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - 2.9.2 - - - org.springframework.boot - spring-boot-starter-parent - 2.1.7.RELEASE - - - src/main/java - {{^interfaceOnly}} - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - {{/interfaceOnly}} - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - {{#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.6.4 - - {{/threetenbp}} -{{#useBeanValidation}} - - - javax.validation - validation-api - -{{/useBeanValidation}} - - - org.springframework.boot - spring-boot-starter-test - test - - - diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/swagger2SpringBoot.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/swagger2SpringBoot.mustache deleted file mode 100644 index d329e337fb..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-boot/swagger2SpringBoot.mustache +++ /dev/null @@ -1,36 +0,0 @@ -package {{basePackage}}; - -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.ComponentScan; - -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@SpringBootApplication -@EnableSwagger2 -@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"}) -public class Swagger2SpringBoot 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(Swagger2SpringBoot.class).run(args); - } - - class ExitException extends RuntimeException implements ExitCodeGenerator { - private static final long serialVersionUID = 1L; - - @Override - public int getExitCode() { - return 10; - } - - } -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/Application.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/Application.mustache deleted file mode 100644 index 372b8da31e..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/Application.mustache +++ /dev/null @@ -1,20 +0,0 @@ -package io.swagger; - -import feign.Logger; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -@EnableFeignClients -public class Application { - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).run(args); - } - - @Bean - Logger.Level feignLoggerLevel() { - return Logger.Level.FULL; - } -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/README.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/README.mustache deleted file mode 100644 index 3130b07017..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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}} -# Swagger generated API stub - -Spring Framework stub - - -## Overview -This code was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), 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/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/apiClient.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/apiClient.mustache deleted file mode 100644 index 52fedbea77..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/apiClient.mustache +++ /dev/null @@ -1,10 +0,0 @@ -package {{package}}; - -import org.springframework.cloud.netflix.feign.FeignClient; -import {{configPackage}}.ClientConfiguration; - -{{=<% %>=}} -@FeignClient(name="${<%title%>.name:<%title%>}", url="${<%title%>.url:<%basePath%>}", configuration = ClientConfiguration.class) -<%={{ }}=%> -public interface {{classname}}Client extends {{classname}} { -} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/apiKeyRequestInterceptor.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/apiKeyRequestInterceptor.mustache deleted file mode 100644 index a7835fc983..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/api_test.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/api_test.mustache deleted file mode 100644 index 0723a652b4..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/api_test.mustache +++ /dev/null @@ -1,45 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -import io.swagger.Application; - -import java.util.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import static org.junit.Assert.assertEquals; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = Application.class) -public class {{classname}}Test { - -@Autowired -private {{classname}} api; - -{{#operations}} -{{#operation}} -{{#contents}} - @Test - public void {{operationId}}Test() throws Exception { - {{#parameters}} - {{^isFile}} - {{{dataType}}} {{paramName}} = {{{example}}}; - {{/isFile}} - {{#isFile}} - org.springframework.web.multipart.MultipartFile {{paramName}} = null; - {{/isFile}} - {{/parameters}} - api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - // todo: add verifications - } -{{/contents}} -{{/operation}} -{{/operations}} -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/clientConfiguration.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/clientConfiguration.mustache deleted file mode 100644 index 3e86330c91..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/clientConfiguration.mustache +++ /dev/null @@ -1,105 +0,0 @@ -package {{configPackage}}; - -import feign.Logger; -import feign.auth.BasicAuthRequestInterceptor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; -import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; -import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; -import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; -import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails; -import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails; -import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails; -import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; -import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; - -@Configuration -@EnableConfigurationProperties -public class ClientConfiguration { - -{{#authMethods}} - {{#isBasic}} - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.username:}")<%={{ }}=%> - private String {{{name}}}Username; - - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.password:}")<%={{ }}=%> - private String {{{name}}}Password; - - @Bean - @ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.username") - public BasicAuthRequestInterceptor {{{name}}}RequestInterceptor() { - return new BasicAuthRequestInterceptor(this.{{{name}}}Username, this.{{{name}}}Password); - } - - {{/isBasic}} - {{#isApiKey}} - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.key:}")<%={{ }}=%> - private String {{{name}}}Key; - - @Bean - @ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.key") - public ApiKeyRequestInterceptor {{{name}}}RequestInterceptor() { - return new ApiKeyRequestInterceptor({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{{keyParamName}}}", this.{{{name}}}Key); - } - - {{/isApiKey}} - {{#isOAuth}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor() { - return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), {{{name}}}ResourceDetails()); - } - - {{#isCode}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public AuthorizationCodeResourceDetails {{{name}}}ResourceDetails() { - AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - details.setUserAuthorizationUri("{{{authorizationUrl}}}"); - return details; - } - - {{/isCode}} - {{#isPassword}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ResourceOwnerPasswordResourceDetails {{{name}}}ResourceDetails() { - ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - return details; - } - - {{/isPassword}} - {{#isApplication}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ClientCredentialsResourceDetails {{{name}}}ResourceDetails() { - ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - return details; - } - - {{/isApplication}} - {{#isImplicit}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ImplicitResourceDetails {{{name}}}ResourceDetails() { - ImplicitResourceDetails details = new ImplicitResourceDetails(); - details.setUserAuthorizationUri("{{{authorizationUrl}}}"); - return details; - } - - {{/isImplicit}} - {{/isOAuth}} -{{/authMethods}} -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/formParams.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/formParams.mustache deleted file mode 100644 index bd2cb8bb64..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/formParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestParam("{{baseName}}") MultipartFile {{paramName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/jacksonConfiguration.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/jacksonConfiguration.mustache deleted file mode 100644 index e96aa772c6..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/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/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/pom.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/pom.mustache deleted file mode 100644 index 9efcee55a5..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-cloud/pom.mustache +++ /dev/null @@ -1,99 +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 - - - org.springframework.boot - spring-boot-starter-parent - 1.5.4.RELEASE - - - src/main/java - - - - - - org.springframework.cloud - spring-cloud-starter-parent - Dalston.SR1 - pom - import - - - - - - - io.swagger - swagger-annotations - ${swagger-core-version} - - - org.springframework.cloud - spring-cloud-starter-feign - - - org.springframework.cloud - spring-cloud-security - - - org.springframework.security.oauth - spring-security-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 - 2.6.4 - - {{/threetenbp}} -{{#useBeanValidation}} - - - javax.validation - validation-api - 1.1.0.Final - provided - -{{/useBeanValidation}} - - org.springframework.boot - spring-boot-starter-test - test - - - diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/README.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/README.mustache deleted file mode 100644 index 1354151afb..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/README.mustache +++ /dev/null @@ -1,12 +0,0 @@ -# Swagger generated server - -Spring MVC Server - - -## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the Spring MVC framework. - -The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox) - -You can view the server in swagger-ui by pointing to -http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}/swagger-ui.html \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/RFC3339DateFormat.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/RFC3339DateFormat.mustache deleted file mode 100644 index 597120b5b2..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/RFC3339DateFormat.mustache +++ /dev/null @@ -1,22 +0,0 @@ -package {{configPackage}}; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - - -public class RFC3339DateFormat extends ISO8601DateFormat { - - private static final long serialVersionUID = 1L; - - // Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/api_test.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/api_test.mustache deleted file mode 100644 index 52f7248870..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/api_test.mustache +++ /dev/null @@ -1,33 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import java.util.*; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; - -import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; - -/** - * Test class to verify that GET endpoints on generated project are reached. - */ -public class {{classname}}ControllerIT { - - {{#operations}} - {{#operation}} - {{#vendorExtensions.x-is-get-method}} - @Test - public void {{operationId}}Test() throws Exception { - final String requestURL = "http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}{{testPath}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{paramName}}={{testExample}}{{#hasMore}}&{{/hasMore}}{{/queryParams}}"; - final HttpClient client = HttpClientBuilder.create().build(); - final HttpResponse response = client.execute(new HttpGet(requestURL)); - assertEquals(response.getStatusLine().getStatusCode(), 501); - } - {{/vendorExtensions.x-is-get-method}} - {{/operation}} - {{/operations}} -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/pom.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/pom.mustache deleted file mode 100644 index bd4245633c..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/pom.mustache +++ /dev/null @@ -1,205 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - src/main/java - - - org.apache.maven.plugins - maven-war-plugin - 3.1.0 - - - maven-failsafe-plugin - 2.18.1 - - - - integration-test - verify - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty-version} - - - {{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} - - target/${project.artifactId}-${project.version} - 8079 - stopit - 10 - - 8002 - 60000 - - - - - start-jetty - pre-integration-test - - start - - - 0 - true - - - - stop-jetty - post-integration-test - - stop - - - - - - - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - - - - - org.springframework - spring-core - ${spring-version} - - - org.springframework - spring-webmvc - ${spring-version} - - - org.springframework - spring-web - ${spring-version} - - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - com.fasterxml.jackson.core - jackson-annotations - - - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - {{#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}} - - - junit - junit - ${junit-version} - test - - - javax.servlet - servlet-api - ${servlet-api-version} - -{{#useBeanValidation}} - - - javax.validation - validation-api - 1.1.0.Final - provided - -{{/useBeanValidation}} - - org.testng - testng - 6.8.8 - test - - - junit - junit - - - snakeyaml - org.yaml - - - bsh - org.beanshell - - - - - - org.apache.httpcomponents - httpclient - 4.5.2 - test - - - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - 9.2.15.v20160210 - 1.7.21 - 4.12 - 2.5 - 2.7.0 - 2.8.9 - 2.6.4 - 4.3.9.RELEASE - - diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/swaggerUiConfiguration.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/swaggerUiConfiguration.mustache deleted file mode 100644 index 563a76915f..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/swaggerUiConfiguration.mustache +++ /dev/null @@ -1,89 +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}} -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Bean; -import org.springframework.http.converter.HttpMessageConverter; -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 springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.util.List; - -{{>generatedAnnotation}} -@Configuration -@ComponentScan(basePackages = "{{apiPackage}}") -@EnableWebMvc -@EnableSwagger2 //Loads the spring beans required by the framework -@PropertySource("classpath:swagger.properties") -@Import(SwaggerDocumentationConfig.class) -public class SwaggerUiConfiguration 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 addResourceHandlers(ResourceHandlerRegistry registry) { - if (!registry.hasMappingForPattern("/webjars/**")) { - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - if (!registry.hasMappingForPattern("/**")) { - registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); - } - } - - @Bean - public Jackson2ObjectMapperBuilder builder() { - Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() - .indentOutput(true) - .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .dateFormat(new RFC3339DateFormat()); - return builder; - } - - @Override - public void configureMessageConverters(List> converters) { - converters.add(new MappingJackson2HttpMessageConverter(objectMapper())); - super.configureMessageConverters(converters); - } - - @Bean - public ObjectMapper objectMapper(){ - return builder().build(); - } -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/webApplication.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/webApplication.mustache deleted file mode 100644 index 9c31004d13..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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[] { SwaggerUiConfiguration.class }; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[] { WebMvcConfiguration.class }; - } - - @Override - protected String[] getServletMappings() { - return new String[] { "/" }; - } -} diff --git a/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/webMvcConfiguration.mustache b/src/main/resources/handlebars/JavaSpring2/libraries/spring-mvc/webMvcConfiguration.mustache deleted file mode 100644 index d60c126316..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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/src/main/resources/handlebars/JavaSpring2/model.mustache b/src/main/resources/handlebars/JavaSpring2/model.mustache deleted file mode 100644 index 4c471ff2b7..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/model.mustache +++ /dev/null @@ -1,40 +0,0 @@ -package {{package}}; - -{{^x-is-composed-model}} -import java.util.Objects; -{{#imports}}import {{import}}; -{{/imports}} -{{#serializableModel}} -import java.io.Serializable; -{{/serializableModel}} -{{#useBeanValidation}} -import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.*; -{{/useBeanValidation}} -{{#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}} -{{/x-is-composed-model}} - -{{#models}} -{{#model}} -{{#vendorExtensions.x-is-composed-model}} -{{>interface}} -{{/vendorExtensions.x-is-composed-model}} -{{^vendorExtensions.x-is-composed-model}} -{{#isEnum}} -{{>enumOuterClass}} -{{/isEnum}} -{{^isEnum}} -{{>pojo}} -{{/isEnum}} -{{/vendorExtensions.x-is-composed-model}} -{{/model}} -{{/models}} diff --git a/src/main/resources/handlebars/JavaSpring2/notFoundException.mustache b/src/main/resources/handlebars/JavaSpring2/notFoundException.mustache deleted file mode 100644 index 40c25c5ea5..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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/src/main/resources/handlebars/JavaSpring2/optionalDataType.mustache b/src/main/resources/handlebars/JavaSpring2/optionalDataType.mustache deleted file mode 100644 index 976950e27e..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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/src/main/resources/handlebars/JavaSpring2/pathParams.mustache b/src/main/resources/handlebars/JavaSpring2/pathParams.mustache deleted file mode 100644 index 6cc92cfe47..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/pathParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^@last}}, {{/@last}}{{#@last}}{{/@last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/pojo.mustache b/src/main/resources/handlebars/JavaSpring2/pojo.mustache deleted file mode 100644 index 492e8084b8..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/pojo.mustache +++ /dev/null @@ -1,145 +0,0 @@ -/** - * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} - */{{#description}} -@ApiModel(description = "{{{description}}}"){{/description}} -{{#useBeanValidation}}@Validated{{/useBeanValidation}} -{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} -public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable {{#interfaceModels}}, {{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{^serializableModel}}{{#interfaceModels}}{{#@first}}implements {{/@first}}{{name}}{{^@last}}, {{/@last}}{{#@last}}{{/@last}}{{/interfaceModels}}{{/serializableModel}} { -{{#serializableModel}} - private static final long serialVersionUID = 1L; - -{{/serializableModel}} - {{#vars}} - {{#isEnum}} - {{^isContainer}} -{{>enumClass}} - {{/isContainer}} - {{/isEnum}} - {{#items.isEnum}} - {{#items}} - {{^isContainer}} -{{>enumClass}} - {{/isContainer}} - {{/items}} - {{/items.isEnum}} - {{#jackson}} - {{#vendorExtensions.x-is-discriminator-property}} - @JsonTypeId - {{/vendorExtensions.x-is-discriminator-property}} - {{^vendorExtensions.x-is-discriminator-property}} - @JsonProperty("{{baseName}}"){{#withXml}} - @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"){{/withXml}} - {{/vendorExtensions.x-is-discriminator-property}} - {{/jackson}} - {{#gson}} - @SerializedName("{{baseName}}") - {{/gson}} - {{#isContainer}} - {{#useBeanValidation}}@Valid{{/useBeanValidation}} - private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; - {{/isContainer}} - {{^isContainer}} - private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; - {{/isContainer}} - - {{/vars}} - {{#vars}} - public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { - this.{{name}} = {{name}}; - return this; - } - {{#isListContainer}} - - public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { - {{^required}} - if (this.{{name}} == null) { - this.{{name}} = {{{defaultValue}}}; - } - {{/required}} - this.{{name}}.add({{name}}Item); - return this; - } - {{/isListContainer}} - {{#isMapContainer}} - - public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { - {{^required}} - if (this.{{name}} == null) { - this.{{name}} = {{{defaultValue}}}; - } - {{/required}} - this.{{name}}.put(key, {{name}}Item); - return this; - } - {{/isMapContainer}} - - /** - {{#description}} - * {{{description}}} - {{/description}} - {{^description}} - * Get {{name}} - {{/description}} - {{#minimum}} - * minimum: {{minimum}} - {{/minimum}} - {{#maximum}} - * maximum: {{maximum}} - {{/maximum}} - * @return {{name}} - **/ - {{#vendorExtensions.extraAnnotation}} - {{{vendorExtensions.extraAnnotation}}} - {{/vendorExtensions.extraAnnotation}} - @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { - return {{name}}; - } - - public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { - this.{{name}} = {{name}}; - } - - {{/vars}} - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - }{{#hasVars}} - {{classname}} {{classVarName}} = ({{classname}}) o; - return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && - {{/hasMore}}{{/vars}}{{#parent}} && - super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} - return true;{{/hasVars}} - } - - @Override - public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class {{classname}} {\n"); - {{#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(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/src/main/resources/handlebars/JavaSpring2/project/build.properties b/src/main/resources/handlebars/JavaSpring2/project/build.properties deleted file mode 100644 index a8c2f849be..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=0.12.0 diff --git a/src/main/resources/handlebars/JavaSpring2/project/plugins.sbt b/src/main/resources/handlebars/JavaSpring2/project/plugins.sbt deleted file mode 100644 index 713b7f3e99..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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/src/main/resources/handlebars/JavaSpring2/queryParams.mustache b/src/main/resources/handlebars/JavaSpring2/queryParams.mustache deleted file mode 100644 index 007d82fb2d..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/returnTypes.mustache b/src/main/resources/handlebars/JavaSpring2/returnTypes.mustache deleted file mode 100644 index c8f7a56938..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/returnTypes.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/src/main/resources/handlebars/JavaSpring2/swaggerDocumentationConfig.mustache b/src/main/resources/handlebars/JavaSpring2/swaggerDocumentationConfig.mustache deleted file mode 100644 index a0b2cded91..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/swaggerDocumentationConfig.mustache +++ /dev/null @@ -1,56 +0,0 @@ -package {{configPackage}}; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -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.plugins.Docket; -{{#useOptional}} -import java.util.Optional; -{{/useOptional}} - -{{>generatedAnnotation}} -@Configuration -public class SwaggerDocumentationConfig { - - 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(){ - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("{{apiPackage}}")) - .build() - {{#java8}} - .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()); - } - -} diff --git a/src/main/resources/handlebars/JavaSpring2/typeInfoAnnotation.mustache b/src/main/resources/handlebars/JavaSpring2/typeInfoAnnotation.mustache deleted file mode 100644 index f2a2e1c88f..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/typeInfoAnnotation.mustache +++ /dev/null @@ -1,7 +0,0 @@ -{{#jackson}} -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) -@JsonSubTypes({ - {{#children}} - @JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/children}} -}){{/jackson}} diff --git a/src/main/resources/handlebars/JavaSpring2/xmlAnnotation.mustache b/src/main/resources/handlebars/JavaSpring2/xmlAnnotation.mustache deleted file mode 100644 index fd81a4cf5d..0000000000 --- a/src/main/resources/handlebars/JavaSpring2/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 diff --git a/src/main/resources/handlebars/aspnetcore/2.1/Program.mustache b/src/main/resources/handlebars/aspnetcore/2.1/Program.mustache index 49b1837ce6..21a504c8aa 100644 --- a/src/main/resources/handlebars/aspnetcore/2.1/Program.mustache +++ b/src/main/resources/handlebars/aspnetcore/2.1/Program.mustache @@ -24,6 +24,9 @@ namespace {{packageName}} /// IWebHostBuilder public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) - .UseStartup(); + .UseStartup(){{^serverUrl}};{{/serverUrl}} + {{#serverUrl}} + .UseUrls("{{serverUrl}}"); + {{/serverUrl}} } } diff --git a/src/main/resources/handlebars/aspnetcore/Program.mustache b/src/main/resources/handlebars/aspnetcore/Program.mustache index 52fdd13d05..9fd700c038 100644 --- a/src/main/resources/handlebars/aspnetcore/Program.mustache +++ b/src/main/resources/handlebars/aspnetcore/Program.mustache @@ -31,6 +31,9 @@ namespace {{packageName}} public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() + {{#serverUrl}} + .UseUrls("{{serverUrl}}") + {{/serverUrl}} .Build(); } } diff --git a/src/main/resources/handlebars/kotlin-client/api.mustache b/src/main/resources/handlebars/kotlin-client/api.mustache index 85d40b6478..046d24dedb 100644 --- a/src/main/resources/handlebars/kotlin-client/api.mustache +++ b/src/main/resources/handlebars/kotlin-client/api.mustache @@ -15,25 +15,26 @@ class {{classname}}(basePath: kotlin.String = "{{{basePath}}}") : ApiClient(base {{#operation}} {{#contents}} /** - * {{summary}} - * {{notes}} - {{#parameters}}* @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} - {{/parameters}}* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} - */{{#returnType}} + * {{summary}} + * {{notes}} + {{#parameters}} * @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + {{/parameters}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} + */{{#returnType}} @Suppress("UNCHECKED_CAST"){{/returnType}} - fun {{operationId}}({{#parameters}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/parameters}}) : {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} { + fun {{operationId}}({{#parameters}}{{paramName}}: {{{dataType}}}{{^required}}? = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/parameters}}): {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}} { + {{#or hasFormParams hasBodyParam}} val localVariableBody: kotlin.Any? = {{#hasBodyParam}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/hasBodyParam}}{{^hasBodyParam}}{{^hasFormParams}}null{{/hasFormParams}}{{#hasFormParams}}mapOf({{#formParams}}"{{{baseName}}}" to "${{paramName}}"{{#hasMore}}, {{/hasMore}}{{/formParams}}){{/hasFormParams}}{{/hasBodyParam}} - val localVariableQuery: MultiValueMap = {{^hasQueryParams}}mapOf(){{/hasQueryParams}}{{#hasQueryParams}}mapOf({{#queryParams}}"{{baseName}}" to {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf("${{paramName}}"){{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/queryParams}}){{/hasQueryParams}} - val localVariableHeaders: kotlin.collections.Map = mapOf({{#hasFormParams}}"Content-Type" to "multipart/form-data"{{/hasFormParams}}{{^hasHeaderParams}}){{/hasHeaderParams}}{{#hasHeaderParams}}{{#hasFormParams}}, {{/hasFormParams}}{{#headerParams}}"{{baseName}}" to {{#isContainer}}{{paramName}}.joinToString(separator = collectionDelimiter("{{collectionFormat}}"){{/isContainer}}{{^isContainer}}{{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/headerParams}}){{/hasHeaderParams}} + {{/or}} + {{#hasQueryParams}}val localVariableQuery: MultiValueMap = mapOf({{#queryParams}}"{{baseName}}" to {{#isContainer}}toMultiValue({{paramName}}.toList(), "{{collectionFormat}}"){{/isContainer}}{{^isContainer}}listOf("${{paramName}}"){{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/queryParams}}){{/hasQueryParams}} + {{#or hasFormParams hasHeaderParams}} + val localVariableHeaders: kotlin.collections.Map = mapOf({{#hasFormParams}}"Content-Type" to "multipart/form-data"{{/hasFormParams}}{{^hasHeaderParams}}){{/hasHeaderParams}}{{#hasHeaderParams}}{{#hasFormParams}}, {{/hasFormParams}}{{#headerParams}}"{{baseName}}" to {{#isContainer}}{{paramName}}.joinToString(separator = collectionDelimiter("{{collectionFormat}}"){{/isContainer}}{{^isContainer}}{{paramName}}{{/isContainer}}{{#hasMore}}, {{/hasMore}}{{/headerParams}}){{/hasHeaderParams}} + {{/or}} val localVariableConfig = RequestConfig( - RequestMethod.{{httpMethod}}, - "{{path}}"{{#pathParams}}.replace("{"+"{{baseName}}"+"}", "${{paramName}}"){{/pathParams}}, - query = localVariableQuery, - headers = localVariableHeaders + RequestMethod.{{httpMethod}}, + "{{path}}"{{#pathParams}}.replace("{" + "{{baseName}}" + "}", "${{paramName}}"){{/pathParams}}{{#hasQueryParams}}, query = localVariableQuery{{/hasQueryParams}}{{#or hasFormParams hasHeaderParams}}, headers = localVariableHeaders{{/or}} ) val response = request<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Any?{{/returnType}}>( - localVariableConfig, - localVariableBody + localVariableConfig{{#or hasFormParams hasHeaderParams}}, localVariableBody{{/or}} ) return when (response.responseType) { @@ -49,4 +50,4 @@ class {{classname}}(basePath: kotlin.String = "{{{basePath}}}") : ApiClient(base {{/contents}} {{/operation}} } -{{/operations}} +{{/operations}} \ No newline at end of file diff --git a/src/main/resources/handlebars/swift4/modelInlineEnumDeclaration.mustache b/src/main/resources/handlebars/swift4/modelInlineEnumDeclaration.mustache index 6ffe280570..fe8e08a684 100644 --- a/src/main/resources/handlebars/swift4/modelInlineEnumDeclaration.mustache +++ b/src/main/resources/handlebars/swift4/modelInlineEnumDeclaration.mustache @@ -1,3 +1,3 @@ public enum {{enumName}}: {{#isNot this 'container'}}{{datatype}}{{/isNot}}{{#is this 'container'}}String{{/is}}, Codable { {{#allowableValues}}{{#enumVars}} case {{name}} = {{#is ../../this 'container'}}"{{/is}}{{#is ../../this 'string'}}"{{/is}}{{{value}}}{{#is ../../this 'string'}}"{{/is}}{{#is ../../this 'container'}}"{{/is}}{{/enumVars}}{{/allowableValues}} - } \ No newline at end of file + } diff --git a/src/main/resources/handlebars/swift4/modelObject.mustache b/src/main/resources/handlebars/swift4/modelObject.mustache index b2517bed82..4097bce695 100644 --- a/src/main/resources/handlebars/swift4/modelObject.mustache +++ b/src/main/resources/handlebars/swift4/modelObject.mustache @@ -1,7 +1,8 @@ public struct {{classname}}: Codable { -{{#allVars}}{{#is this 'enum'}}{{> modelInlineEnumDeclaration}}{{/is}}{{/allVars}}{{#allVars}}{{#is this 'enum'}} {{#description}}/** {{description}} */ +{{#allVars}}{{#is this 'enum'}}{{> modelInlineEnumDeclaration}} +{{/is}}{{/allVars}}{{#allVars}}{{#is this 'enum'}} {{#description}}/** {{description}} */ {{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{/is}} {{#isNot this 'enum'}} {{#description}}/** {{description}} */ {{/description}}public var {{name}}: {{{datatype}}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#objcCompatible}}{{#vendorExtensions.x-swift-optional-scalar}} @@ -11,7 +12,7 @@ public struct {{classname}}: Codable { } }{{/vendorExtensions.x-swift-optional-scalar}}{{/objcCompatible}} {{/isNot}}{{/allVars}}{{#has this 'vars'}} - public init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#has this 'more'}}, {{/has}}{{/allVars}}) { {{#allVars}} + public init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{^required}}? = nil{{/required}}{{#has this 'more'}}, {{/has}}{{/allVars}}) { {{#allVars}} self.{{name}} = {{name}}{{/allVars}} } {{/has~}}{{#additionalPropertiesType}} diff --git a/src/main/resources/handlebars/typescript-angular/npmignore b/src/main/resources/handlebars/typescript-angular/npmignore new file mode 100644 index 0000000000..7e981c47c9 --- /dev/null +++ b/src/main/resources/handlebars/typescript-angular/npmignore @@ -0,0 +1,5 @@ +wwwroot/*.js +node +node_modules +typings +dist diff --git a/src/main/resources/handlebars/typescript-angular/package.mustache b/src/main/resources/handlebars/typescript-angular/package.mustache index 7536244d51..fcbfff0010 100644 --- a/src/main/resources/handlebars/typescript-angular/package.mustache +++ b/src/main/resources/handlebars/typescript-angular/package.mustache @@ -22,8 +22,8 @@ }, {{/useNgPackagr}} "peerDependencies": { - "@angular/core": "^{{ngVersion}}", - "@angular/http": "^{{ngVersion}}", + "@angular/core": "^{{ngVersion}}",{{#useHttpClientPackage}} + "@angular/http": "^{{ngVersion}}",{{/useHttpClientPackage}} "@angular/common": "^{{ngVersion}}", "@angular/compiler": "^{{ngVersion}}", "core-js": "^2.4.0", @@ -34,16 +34,16 @@ }, "devDependencies": { "@angular/compiler-cli": "^{{ngVersion}}", - "@angular/core": "^{{ngVersion}}", - "@angular/http": "^{{ngVersion}}", + "@angular/core": "^{{ngVersion}}",{{#useHttpClientPackage}} + "@angular/http": "^{{ngVersion}}",{{/useHttpClientPackage}} "@angular/common": "^{{ngVersion}}", "@angular/compiler": "^{{ngVersion}}", "@angular/platform-browser": "^{{ngVersion}}",{{#useNgPackagr}} - "ng-packagr": {{#useOldNgPackagr}}"^1.6.0"{{/useOldNgPackagr}}{{^useOldNgPackagr}}{{#useRxJS6}}"5.3.0"{{/useRxJS6}}{{^useRxJS6}}"^2.4.1"{{/useRxJS6}}{{/useOldNgPackagr}},{{/useNgPackagr}} + "ng-packagr": {{#useOldNgPackagr}}"^1.6.0"{{/useOldNgPackagr}}{{^useOldNgPackagr}}{{#useRxJS6}}"5.5.1"{{/useRxJS6}}{{^useRxJS6}}"^2.4.1"{{/useRxJS6}}{{/useOldNgPackagr}},{{/useNgPackagr}} "reflect-metadata": "^0.1.3", "rxjs": "{{#useRxJS6}}~6.3.3{{/useRxJS6}}{{^useRxJS6}}^5.4.0{{/useRxJS6}}", "zone.js": "^0.7.6", - "typescript": "^2.1.5" + "typescript": "{{#useNgPackagr}}~3.4.5{{/useNgPackagr}}{{^useNgPackagr}}^2.1.5{{/useNgPackagr}}" }{{#npmRepository}},{{/npmRepository}} {{#npmRepository}} "publishConfig": { diff --git a/src/main/resources/mustache/Java/build.gradle.mustache b/src/main/resources/mustache/Java/build.gradle.mustache index 6ceed67575..0918c86006 100644 --- a/src/main/resources/mustache/Java/build.gradle.mustache +++ b/src/main/resources/mustache/Java/build.gradle.mustache @@ -121,7 +121,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.17" - jackson_version = "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" + jackson_version = "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" jersey_version = "1.19.4" jodatime_version = "2.9.9" junit_version = "4.12" diff --git a/src/main/resources/mustache/Java/libraries/feign/build.gradle.mustache b/src/main/resources/mustache/Java/libraries/feign/build.gradle.mustache index bb928c55cd..f25b668772 100644 --- a/src/main/resources/mustache/Java/libraries/feign/build.gradle.mustache +++ b/src/main/resources/mustache/Java/libraries/feign/build.gradle.mustache @@ -101,7 +101,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.9" - jackson_version = "2.9.9" + jackson_version = "2.9.10" {{#threetenbp}} threepane_version = "2.6.4" {{/threetenbp}} diff --git a/src/main/resources/mustache/Java/libraries/feign/build.sbt.mustache b/src/main/resources/mustache/Java/libraries/feign/build.sbt.mustache index f639b1c502..c73aaea8d5 100644 --- a/src/main/resources/mustache/Java/libraries/feign/build.sbt.mustache +++ b/src/main/resources/mustache/Java/libraries/feign/build.sbt.mustache @@ -14,10 +14,10 @@ lazy val root = (project in file(".")). "io.github.openfeign" % "feign-jackson" % "9.4.0" % "compile", "io.github.openfeign" % "feign-slf4j" % "9.4.0" % "compile", "io.github.openfeign.form" % "feign-form" % "2.1.0" % "compile", - "com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile", - "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile", - "com.fasterxml.jackson.datatype" % "jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}" % "2.9.9" % "compile", + "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", + "com.fasterxml.jackson.datatype" % "jackson-datatype-{{^java8}}joda{{/java8}}{{#java8}}jsr310{{/java8}}" % "2.9.10" % "compile", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile", "com.brsanthu" % "migbase64" % "2.2" % "compile", "junit" % "junit" % "4.12" % "test", diff --git a/src/main/resources/mustache/Java/libraries/feign/pom.mustache b/src/main/resources/mustache/Java/libraries/feign/pom.mustache index aa1dc171df..40879438a1 100644 --- a/src/main/resources/mustache/Java/libraries/feign/pom.mustache +++ b/src/main/resources/mustache/Java/libraries/feign/pom.mustache @@ -297,7 +297,7 @@ 1.5.18 9.4.0 2.1.0 - 2.9.9 + 2.9.10 {{#threetenbp}} 2.6.4 {{/threetenbp}} diff --git a/src/main/resources/mustache/Java/libraries/google-api-client/build.gradle.mustache b/src/main/resources/mustache/Java/libraries/google-api-client/build.gradle.mustache index 889131cc1a..23de2e62f2 100644 --- a/src/main/resources/mustache/Java/libraries/google-api-client/build.gradle.mustache +++ b/src/main/resources/mustache/Java/libraries/google-api-client/build.gradle.mustache @@ -107,7 +107,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.17" - jackson_version = "2.9.9" + jackson_version = "2.9.10" google_api_client_version = "1.23.0" jersey_common_version = "2.25.1" jodatime_version = "2.9.9" diff --git a/src/main/resources/mustache/Java/libraries/google-api-client/build.sbt.mustache b/src/main/resources/mustache/Java/libraries/google-api-client/build.sbt.mustache index 3212a4ab63..28987e37a5 100644 --- a/src/main/resources/mustache/Java/libraries/google-api-client/build.sbt.mustache +++ b/src/main/resources/mustache/Java/libraries/google-api-client/build.sbt.mustache @@ -12,20 +12,20 @@ lazy val root = (project in file(".")). "io.swagger" % "swagger-annotations" % "1.5.17", "com.google.api-client" % "google-api-client" % "1.23.0", "org.glassfish.jersey.core" % "jersey-common" % "2.25.1", - "com.fasterxml.jackson.core" % "jackson-core" % "2.9.9" % "compile", - "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.9" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9" % "compile", + "com.fasterxml.jackson.core" % "jackson-core" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.10" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.10" % "compile", {{#withXml}} - "com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.9.9" % "compile", + "com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.9.10" % "compile", {{/withXml}} {{#joda}} - "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.9" % "compile", + "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.10" % "compile", {{/joda}} {{#java8}} - "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.9" % "compile", + "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.10" % "compile", {{/java8}} {{#threetenbp}} - "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile", + "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.10" % "compile", {{/threetenbp}} "junit" % "junit" % "4.12" % "test", "com.novocode" % "junit-interface" % "0.10" % "test" diff --git a/src/main/resources/mustache/Java/libraries/google-api-client/pom.mustache b/src/main/resources/mustache/Java/libraries/google-api-client/pom.mustache index 78713c63c4..8d32465494 100644 --- a/src/main/resources/mustache/Java/libraries/google-api-client/pom.mustache +++ b/src/main/resources/mustache/Java/libraries/google-api-client/pom.mustache @@ -286,7 +286,7 @@ 1.5.17 1.23.0 2.25.1 - 2.9.9 + 2.9.10 {{#joda}} 2.9.9 {{/joda}} diff --git a/src/main/resources/mustache/Java/libraries/jersey2/build.gradle.mustache b/src/main/resources/mustache/Java/libraries/jersey2/build.gradle.mustache index fd43b98073..61bce0d245 100644 --- a/src/main/resources/mustache/Java/libraries/jersey2/build.gradle.mustache +++ b/src/main/resources/mustache/Java/libraries/jersey2/build.gradle.mustache @@ -106,7 +106,7 @@ if(hasProperty('target') && target == 'android') { ext { swagger_annotations_version = "1.5.17" - jackson_version = "2.9.9" + jackson_version = "2.9.10" {{#supportJava6}} jersey_version = "2.6" commons_io_version=2.5 diff --git a/src/main/resources/mustache/Java/libraries/jersey2/build.sbt.mustache b/src/main/resources/mustache/Java/libraries/jersey2/build.sbt.mustache index 59b49e501b..32ada4a514 100644 --- a/src/main/resources/mustache/Java/libraries/jersey2/build.sbt.mustache +++ b/src/main/resources/mustache/Java/libraries/jersey2/build.sbt.mustache @@ -13,14 +13,14 @@ lazy val root = (project in file(".")). "org.glassfish.jersey.core" % "jersey-client" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}}, "org.glassfish.jersey.media" % "jersey-media-multipart" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}}, "org.glassfish.jersey.media" % "jersey-media-json-jackson" % {{#supportJava6}}"2.6"{{/supportJava6}}{{^supportJava6}}"2.25.1"{{/supportJava6}}, - "com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", - "com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", - "com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", + "com.fasterxml.jackson.core" % "jackson-core" % "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", + "com.fasterxml.jackson.core" % "jackson-annotations" % "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", + "com.fasterxml.jackson.core" % "jackson-databind" % "{{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" % "compile", {{#joda}} - "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.9" % "compile", + "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.10" % "compile", {{/joda}} {{#java8}} - "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.9" % "compile", + "com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.9.10" % "compile", {{/java8}} {{#threetenbp}} "com.github.joschi.jackson" % "jackson-datatype-threetenbp" % "2.6.4" % "compile", diff --git a/src/main/resources/mustache/Java/libraries/jersey2/pom.mustache b/src/main/resources/mustache/Java/libraries/jersey2/pom.mustache index 2bcb56b5ba..cb8cc23b8c 100644 --- a/src/main/resources/mustache/Java/libraries/jersey2/pom.mustache +++ b/src/main/resources/mustache/Java/libraries/jersey2/pom.mustache @@ -323,7 +323,7 @@ 2.5 3.6 {{/supportJava6}} - {{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} + {{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} 1.0.0 4.12 diff --git a/src/main/resources/mustache/Java/pojo.mustache b/src/main/resources/mustache/Java/pojo.mustache index 75ffc4e3b6..24cf5c421c 100644 --- a/src/main/resources/mustache/Java/pojo.mustache +++ b/src/main/resources/mustache/Java/pojo.mustache @@ -4,7 +4,7 @@ {{#description}}{{#useOas2}}@ApiModel{{/useOas2}}{{^useOas2}}@Schema{{/useOas2}}(description = "{{{description}}}"){{/description}} {{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} -public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{#interfaceModels}}{{#@first}}, {{/@first}}{{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable{{#interfaceModels}}, {{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{^serializableModel}}{{#interfaceModels}}{{#@first}}implements {{/@first}}{{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{/parcelableModel}}{ +public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{#serializableModel}}, Serializable {{/serializableModel}}{{#interfaceModels}}{{#@first}}, {{/@first}}{{classname}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/parcelableModel}}{{^parcelableModel}}{{#serializableModel}}implements Serializable{{#interfaceModels}}, {{classname}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{^serializableModel}}{{#interfaceModels}}{{#@first}}implements {{/@first}}{{classname}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{/parcelableModel}}{ {{#serializableModel}} private static final long serialVersionUID = 1L; @@ -146,7 +146,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela {{#vendorExtensions.extraAnnotation}} {{{vendorExtensions.extraAnnotation}}} {{/vendorExtensions.extraAnnotation}} - public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { + public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } {{^isReadOnly}} diff --git a/src/main/resources/mustache/Java/pom.mustache b/src/main/resources/mustache/Java/pom.mustache index 2fc8d89baa..3b5fbacb51 100644 --- a/src/main/resources/mustache/Java/pom.mustache +++ b/src/main/resources/mustache/Java/pom.mustache @@ -329,7 +329,7 @@ 2.5 3.6 {{/supportJava6}} - {{^threetenbp}}2.9.9{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} + {{^threetenbp}}2.9.10{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}} 1.0.0 4.12 diff --git a/src/main/resources/mustache/JavaInflector/pojo.mustache b/src/main/resources/mustache/JavaInflector/pojo.mustache index d53f2dce78..9c90816a31 100644 --- a/src/main/resources/mustache/JavaInflector/pojo.mustache +++ b/src/main/resources/mustache/JavaInflector/pojo.mustache @@ -43,7 +43,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") @JsonProperty("{{baseName}}") - public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { + public {{{datatypeWithEnum}}}{{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/mustache/JavaJaxRS/cxf-cdi/pojo.mustache b/src/main/resources/mustache/JavaJaxRS/cxf-cdi/pojo.mustache index 6b5db770d4..40c7f13416 100644 --- a/src/main/resources/mustache/JavaJaxRS/cxf-cdi/pojo.mustache +++ b/src/main/resources/mustache/JavaJaxRS/cxf-cdi/pojo.mustache @@ -33,7 +33,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") @JsonProperty("{{baseName}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/mustache/JavaJaxRS/cxf/pojo.mustache b/src/main/resources/mustache/JavaJaxRS/cxf/pojo.mustache index 659400f409..5c85bd9708 100644 --- a/src/main/resources/mustache/JavaJaxRS/cxf/pojo.mustache +++ b/src/main/resources/mustache/JavaJaxRS/cxf/pojo.mustache @@ -65,16 +65,16 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#interfa {{#vendorExtensions.extraAnnotation}} {{{vendorExtensions.extraAnnotation}}} {{/vendorExtensions.extraAnnotation}} -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#isEnum}}{{^isListContainer}}{{^isMapContainer}}public {{datatype}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} {{#isEnum}}{{^isListContainer}}{{^isMapContainer}}public {{datatype}} {{getter}}() { if ({{name}} == null) { return null; } return {{name}}.value(); - }{{/isMapContainer}}{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isListContainer}}public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { + }{{/isMapContainer}}{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isListContainer}}public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; - }{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isMapContainer}}public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { + }{{/isListContainer}}{{/isEnum}}{{#isEnum}}{{#isMapContainer}}public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; - }{{/isMapContainer}}{{/isEnum}}{{^isEnum}}public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { + }{{/isMapContainer}}{{/isEnum}}{{^isEnum}}public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; }{{/isEnum}} diff --git a/src/main/resources/mustache/JavaJaxRS/resteasy/eap/gradle.mustache b/src/main/resources/mustache/JavaJaxRS/resteasy/eap/gradle.mustache index df8a82b461..63c6384938 100644 --- a/src/main/resources/mustache/JavaJaxRS/resteasy/eap/gradle.mustache +++ b/src/main/resources/mustache/JavaJaxRS/resteasy/eap/gradle.mustache @@ -19,11 +19,11 @@ dependencies { providedCompile 'javax.validation:validation-api:1.1.0.Final' {{/useBeanValidation}} {{^java8}} - compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.9' + compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.10' compile 'joda-time:joda-time:2.7' {{/java8}} {{#java8}} - compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.9' + compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.10' {{/java8}} testCompile 'junit:junit:4.12', 'org.hamcrest:hamcrest-core:1.3' diff --git a/src/main/resources/mustache/JavaJaxRS/resteasy/eap/pojo.mustache b/src/main/resources/mustache/JavaJaxRS/resteasy/eap/pojo.mustache index 8ad5be2e3c..e5969aa716 100644 --- a/src/main/resources/mustache/JavaJaxRS/resteasy/eap/pojo.mustache +++ b/src/main/resources/mustache/JavaJaxRS/resteasy/eap/pojo.mustache @@ -28,7 +28,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") @JsonProperty("{{baseName}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/mustache/JavaJaxRS/resteasy/eap/pom.mustache b/src/main/resources/mustache/JavaJaxRS/resteasy/eap/pom.mustache index 28654ccf0a..44d5452eb0 100644 --- a/src/main/resources/mustache/JavaJaxRS/resteasy/eap/pom.mustache +++ b/src/main/resources/mustache/JavaJaxRS/resteasy/eap/pom.mustache @@ -187,30 +187,30 @@ com.fasterxml.jackson.datatype jackson-datatype-joda - 2.9.9 + 2.9.10 {{/java8}} {{#java8}} com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.9.9 + 2.9.10 {{/java8}} com.fasterxml.jackson.core jackson-databind - 2.9.9 + 2.9.10 com.fasterxml.jackson.core jackson-core - 2.9.9 + 2.9.10 com.fasterxml.jackson.core jackson-annotations - 2.9.9 + 2.9.10 org.apache.httpcomponents diff --git a/src/main/resources/mustache/JavaJaxRS/resteasy/pojo.mustache b/src/main/resources/mustache/JavaJaxRS/resteasy/pojo.mustache index 90e7cfda28..b1779bece1 100644 --- a/src/main/resources/mustache/JavaJaxRS/resteasy/pojo.mustache +++ b/src/main/resources/mustache/JavaJaxRS/resteasy/pojo.mustache @@ -28,7 +28,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") @JsonProperty("{{baseName}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/mustache/JavaJaxRS/spec/pojo.mustache b/src/main/resources/mustache/JavaJaxRS/spec/pojo.mustache index 8ea0a04120..06b8a1e440 100644 --- a/src/main/resources/mustache/JavaJaxRS/spec/pojo.mustache +++ b/src/main/resources/mustache/JavaJaxRS/spec/pojo.mustache @@ -31,7 +31,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali {{#vendorExtensions.extraAnnotation}}{{{vendorExtensions.extraAnnotation}}}{{/vendorExtensions.extraAnnotation}} @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") @JsonProperty("{{baseName}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}; } public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { diff --git a/src/main/resources/mustache/JavaSpring/api.mustache b/src/main/resources/mustache/JavaSpring/api.mustache deleted file mode 100644 index 7551be6b6f..0000000000 --- a/src/main/resources/mustache/JavaSpring/api.mustache +++ /dev/null @@ -1,138 +0,0 @@ -/** - * NOTE: This class is auto generated by the swagger code generator program ({{{generatorVersion}}}). - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -{{#jdk8-no-delegate}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/jdk8-no-delegate}} -import io.swagger.annotations.*; -{{#jdk8-no-delegate}} -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -{{/jdk8-no-delegate}} -import org.springframework.http.ResponseEntity; -{{#useBeanValidation}} -import org.springframework.validation.annotation.Validated; -{{/useBeanValidation}} -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -{{#jdk8-no-delegate}} -import javax.servlet.http.HttpServletRequest; -{{/jdk8-no-delegate}} -{{#useBeanValidation}} -import javax.validation.Valid; -import javax.validation.constraints.*; -{{/useBeanValidation}} -{{#jdk8-no-delegate}} -import java.io.IOException; -{{/jdk8-no-delegate}} -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}} -@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") -{{#operations}} -public interface {{classname}} { -{{#jdk8}} - - {{^isDelegate}} - Logger log = LoggerFactory.getLogger({{classname}}.class); - - default Optional getObjectMapper() { - return Optional.empty(); - } - - default Optional getRequest() { - return Optional.empty(); - } - - default Optional getAcceptHeader() { - return getRequest().map(r -> r.getHeader("Accept")); - } - {{/isDelegate}} - {{#isDelegate}} - {{classname}}Delegate getDelegate(); - {{/isDelegate}} -{{/jdk8}} -{{#operation}} -{{#contents}} - - @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { - {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { - {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, - {{/hasMore}}{{/scopes}} - }{{/isOAuth}}){{#hasMore}}, - {{/hasMore}}{{/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}}){{#hasMore}},{{/hasMore}}{{/responses}} }) - {{#implicitHeaders}} - @ApiImplicitParams({ - {{#headerParams}} - {{>implicitHeader}} - {{/headerParams}} - }) - {{/implicitHeaders}} - @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}}{{#hasProduces}} - produces = "{{{vendorExtensions.x-accepts}}}", {{/hasProduces}}{{#hasConsumes}} - consumes = "{{{vendorExtensions.x-contentType}}}",{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} - produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} - consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} - method = RequestMethod.{{httpMethod}}) - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { - {{#delegate-method}} - return {{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - } - - // Override this method - default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { - {{/delegate-method}} - {{^isDelegate}} - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - {{#examples}} - if (getAcceptHeader().get().contains("{{{contentType}}}")) { - try { - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; - } - } - {{/examples}} - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); - } - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - {{/isDelegate}} - {{#isDelegate}} - return getDelegate().{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - {{/isDelegate}} - }{{/jdk8}} - -{{/contents}} -{{/operation}} -} -{{/operations}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/apiController.mustache b/src/main/resources/mustache/JavaSpring/apiController.mustache deleted file mode 100644 index ab8eb2d9bc..0000000000 --- a/src/main/resources/mustache/JavaSpring/apiController.mustache +++ /dev/null @@ -1,150 +0,0 @@ -package {{package}}; - -{{^jdk8}} -{{#imports}}import {{import}}; -{{/imports}} -{{/jdk8}} -{{^isDelegate}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/isDelegate}} -{{^jdk8}} -import io.swagger.annotations.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -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; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - - {{#useBeanValidation}} -import javax.validation.constraints.*; -import javax.validation.Valid; - {{/useBeanValidation}} -{{/jdk8}} -{{^isDelegate}} -import javax.servlet.http.HttpServletRequest; - {{#jdk8}} -import java.util.Optional; - {{/jdk8}} -{{/isDelegate}} -{{^jdk8-no-delegate}} - {{#useOptional}} -import java.util.Optional; - {{/useOptional}} -{{/jdk8-no-delegate}} -{{^jdk8}} - {{^isDelegate}} -import java.io.IOException; - {{/isDelegate}} -import java.util.List; -import java.util.Map; - {{#async}} -import java.util.concurrent.Callable; - {{/async}} -{{/jdk8}} -{{>generatedAnnotation}} -@Controller -{{#operations}} -public class {{classname}}Controller implements {{classname}} { - -{{#isDelegate}} - private final {{classname}}Delegate delegate; - - @org.springframework.beans.factory.annotation.Autowired - public {{classname}}Controller({{classname}}Delegate delegate) { - this.delegate = delegate; - } - {{#jdk8}} - - @Override - public {{classname}}Delegate getDelegate() { - return delegate; - } - {{/jdk8}} -{{/isDelegate}} -{{^isDelegate}} - {{^jdk8}} - private static final Logger log = LoggerFactory.getLogger({{classname}}Controller.class); - - {{/jdk8}} - private final ObjectMapper objectMapper; - - private final HttpServletRequest request; - - @org.springframework.beans.factory.annotation.Autowired - public {{classname}}Controller(ObjectMapper objectMapper, HttpServletRequest request) { - this.objectMapper = objectMapper; - this.request = request; - } - {{#jdk8}} - - @Override - public Optional getObjectMapper() { - return Optional.ofNullable(objectMapper); - } - - @Override - public Optional getRequest() { - return Optional.ofNullable(request); - } - {{/jdk8}} - -{{/isDelegate}} -{{^jdk8}} -{{#operation}} -{{#contents}} - public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { - {{^isDelegate}} - {{^async}} - String accept = request.getHeader("Accept"); - {{#examples}} - if (accept != null && accept.contains("{{{contentType}}}")) { - try { - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - {{/examples}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED); - {{/async}} - {{#async}} - return new CallablereturnTypes}}>>() { - @Override - public ResponseEntity<{{>returnTypes}}> call() { - String accept = request.getHeader("Accept"); - {{#examples}} - if (accept != null && accept.contains("{{{contentType}}}")) { - try { - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - {{/examples}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED); - } - }; - {{/async}} - {{/isDelegate}} - {{#isDelegate}} - return delegate.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - {{/isDelegate}} - } - -{{/contents}} -{{/operation}} -{{/jdk8}} -} -{{/operations}} diff --git a/src/main/resources/mustache/JavaSpring/apiDelegate.mustache b/src/main/resources/mustache/JavaSpring/apiDelegate.mustache deleted file mode 100644 index c75596caea..0000000000 --- a/src/main/resources/mustache/JavaSpring/apiDelegate.mustache +++ /dev/null @@ -1,88 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -{{#jdk8}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/jdk8}} -import io.swagger.annotations.*; -{{#jdk8}} -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -{{/jdk8}} -import org.springframework.http.ResponseEntity; -import org.springframework.web.multipart.MultipartFile; -{{#jdk8}} -import java.io.IOException; -{{/jdk8}} - -{{#jdk8}} -import javax.servlet.http.HttpServletRequest; -{{/jdk8}} -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}} - - Logger log = LoggerFactory.getLogger({{classname}}.class); - - default Optional getObjectMapper() { - return Optional.empty(); - } - - default Optional getRequest() { - return Optional.empty(); - } - - default Optional getAcceptHeader() { - return getRequest().map(r -> r.getHeader("Accept")); - } -{{/jdk8}} - -{{#operation}} -{{#contents}} - /** - * @see {{classname}}#{{operationId}} - */ - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, - {{/hasMore}}{{/parameters}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - {{#examples}} - if (getAcceptHeader().get().contains("{{{contentType}}}")) { - try { - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; - } - } - {{/examples}} - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); - } - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - }{{/jdk8}} - -{{/contents}} -{{/operation}} -} -{{/operations}} diff --git a/src/main/resources/mustache/JavaSpring/apiException.mustache b/src/main/resources/mustache/JavaSpring/apiException.mustache deleted file mode 100644 index f616114770..0000000000 --- a/src/main/resources/mustache/JavaSpring/apiException.mustache +++ /dev/null @@ -1,10 +0,0 @@ -package {{apiPackage}}; - -{{>generatedAnnotation}} -public class ApiException extends Exception{ - private int code; - public ApiException (int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/src/main/resources/mustache/JavaSpring/apiOriginFilter.mustache b/src/main/resources/mustache/JavaSpring/apiOriginFilter.mustache deleted file mode 100644 index 5cf72a7dc4..0000000000 --- a/src/main/resources/mustache/JavaSpring/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/src/main/resources/mustache/JavaSpring/apiResponseMessage.mustache b/src/main/resources/mustache/JavaSpring/apiResponseMessage.mustache deleted file mode 100644 index 17b155f3b6..0000000000 --- a/src/main/resources/mustache/JavaSpring/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/src/main/resources/mustache/JavaSpring/application.mustache b/src/main/resources/mustache/JavaSpring/application.mustache deleted file mode 100644 index e686a5a0c3..0000000000 --- a/src/main/resources/mustache/JavaSpring/application.mustache +++ /dev/null @@ -1,5 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -server.contextPath={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} -server.port={{serverPort}} -spring.jackson.date-format={{basePackage}}.RFC3339DateFormat -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/application.properties b/src/main/resources/mustache/JavaSpring/application.properties deleted file mode 100644 index 8d3a7a8292..0000000000 --- a/src/main/resources/mustache/JavaSpring/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -#server.port=8090 diff --git a/src/main/resources/mustache/JavaSpring/beanValidation.mustache b/src/main/resources/mustache/JavaSpring/beanValidation.mustache deleted file mode 100644 index 3e4ef612a4..0000000000 --- a/src/main/resources/mustache/JavaSpring/beanValidation.mustache +++ /dev/null @@ -1,6 +0,0 @@ -{{#required}} - @NotNull -{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}} - @Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{#isNotContainer}}{{^isPrimitiveType}} - @Valid{{/isPrimitiveType}}{{/isNotContainer}} -{{>beanValidationCore}} diff --git a/src/main/resources/mustache/JavaSpring/beanValidationCore.mustache b/src/main/resources/mustache/JavaSpring/beanValidationCore.mustache deleted file mode 100644 index 29d043cc77..0000000000 --- a/src/main/resources/mustache/JavaSpring/beanValidationCore.mustache +++ /dev/null @@ -1,20 +0,0 @@ -{{#pattern}}@Pattern(regexp="{{{pattern}}}"{{#vendorExtensions.x-pattern-message}}, message="{{vendorExtensions.x-pattern-message}}"{{/vendorExtensions.x-pattern-message}}) {{/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}}{{! -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("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}") {{/maximum}}{{/isLong}}{{/isInteger}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/beanValidationPathParams.mustache b/src/main/resources/mustache/JavaSpring/beanValidationPathParams.mustache deleted file mode 100644 index 051bd53c0a..0000000000 --- a/src/main/resources/mustache/JavaSpring/beanValidationPathParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/beanValidationQueryParams.mustache b/src/main/resources/mustache/JavaSpring/beanValidationQueryParams.mustache deleted file mode 100644 index 9cca8cb887..0000000000 --- a/src/main/resources/mustache/JavaSpring/beanValidationQueryParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#required}}@NotNull {{/required}}{{>beanValidationCore}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/bodyParams.mustache b/src/main/resources/mustache/JavaSpring/bodyParams.mustache deleted file mode 100644 index 7fef9ad2b6..0000000000 --- a/src/main/resources/mustache/JavaSpring/bodyParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/customInstantDeserializer.mustache b/src/main/resources/mustache/JavaSpring/customInstantDeserializer.mustache deleted file mode 100644 index b7b8e251bd..0000000000 --- a/src/main/resources/mustache/JavaSpring/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.DateTimeUtils; -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.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.timeZoneToZoneId(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/src/main/resources/mustache/JavaSpring/enumClass.mustache b/src/main/resources/mustache/JavaSpring/enumClass.mustache deleted file mode 100644 index c5c3143cb9..0000000000 --- a/src/main/resources/mustache/JavaSpring/enumClass.mustache +++ /dev/null @@ -1,44 +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; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { - for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } diff --git a/src/main/resources/mustache/JavaSpring/enumOuterClass.mustache b/src/main/resources/mustache/JavaSpring/enumOuterClass.mustache deleted file mode 100644 index 76c2cbf5a7..0000000000 --- a/src/main/resources/mustache/JavaSpring/enumOuterClass.mustache +++ /dev/null @@ -1,42 +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; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { - for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } -} diff --git a/src/main/resources/mustache/JavaSpring/exampleReturnTypes.mustache b/src/main/resources/mustache/JavaSpring/exampleReturnTypes.mustache deleted file mode 100644 index 395e3889c2..0000000000 --- a/src/main/resources/mustache/JavaSpring/exampleReturnTypes.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/formParams.mustache b/src/main/resources/mustache/JavaSpring/formParams.mustache deleted file mode 100644 index 7305792be1..0000000000 --- a/src/main/resources/mustache/JavaSpring/formParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/generatedAnnotation.mustache b/src/main/resources/mustache/JavaSpring/generatedAnnotation.mustache deleted file mode 100644 index ad17a426e9..0000000000 --- a/src/main/resources/mustache/JavaSpring/generatedAnnotation.mustache +++ /dev/null @@ -1,3 +0,0 @@ -{{^hideGenerationTimestamp}} -@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") -{{/hideGenerationTimestamp}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/headerParams.mustache b/src/main/resources/mustache/JavaSpring/headerParams.mustache deleted file mode 100644 index 89645c9436..0000000000 --- a/src/main/resources/mustache/JavaSpring/headerParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/implicitHeader.mustache b/src/main/resources/mustache/JavaSpring/implicitHeader.mustache deleted file mode 100644 index 64d7af2080..0000000000 --- a/src/main/resources/mustache/JavaSpring/implicitHeader.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isHeaderParam}}@ApiImplicitParam(name = "{{{paramName}}}", value = "{{{description}}}", {{#required}}required=true,{{/required}} dataType = "{{{dataType}}}", paramType = "header"){{#hasMore}},{{/hasMore}}{{/isHeaderParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/interface.mustache b/src/main/resources/mustache/JavaSpring/interface.mustache deleted file mode 100644 index becc0c5549..0000000000 --- a/src/main/resources/mustache/JavaSpring/interface.mustache +++ /dev/null @@ -1,6 +0,0 @@ -/** -* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} -*/ -public interface {{{classname}}} { - -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/README.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-boot/README.mustache deleted file mode 100644 index 02d932b8ac..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/README.mustache +++ /dev/null @@ -1,45 +0,0 @@ -{{^interfaceOnly}}# Swagger generated server - -Spring Boot Server - - -## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. -This is an example of building a swagger-enabled server in Java using the SpringBoot framework. - -The underlying library integrating swagger to SpringBoot is [springfox](https://github.com/springfox/springfox) - -Start your server as an simple java application - -You can view the api documentation in swagger-ui by pointing to -http://localhost:8080/ - -Change default port value in application.properties{{/interfaceOnly}}{{#interfaceOnly}} -# Swagger generated API stub - -Spring Framework stub - - -## Overview -This code was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), 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/src/main/resources/mustache/JavaSpring/libraries/spring-boot/RFC3339DateFormat.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-boot/RFC3339DateFormat.mustache deleted file mode 100644 index d5dff8ac63..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/RFC3339DateFormat.mustache +++ /dev/null @@ -1,22 +0,0 @@ -package {{basePackage}}; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - - -public class RFC3339DateFormat extends ISO8601DateFormat { - - private static final long serialVersionUID = 1L; - - // Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/api_test.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-boot/api_test.mustache deleted file mode 100644 index 6558eb235c..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/api_test.mustache +++ /dev/null @@ -1,45 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import java.util.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.junit.Assert.assertEquals; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class {{classname}}ControllerIntegrationTest { - - @Autowired - private {{classname}} api; - - {{#operations}} - {{#operation}} - {{#contents}} - @Test - public void {{operationId}}Test() throws Exception { - {{#parameters}} - {{^isFile}} - {{{dataType}}} {{paramName}} = {{{example}}}; - {{/isFile}} - {{#isFile}} - org.springframework.web.multipart.MultipartFile {{paramName}} = null; - {{/isFile}} - {{/parameters}} - ResponseEntity<{{>returnTypes}}> responseEntity = api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); - } - - {{/contents}} - {{/operation}} - {{/operations}} -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/homeController.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-boot/homeController.mustache deleted file mode 100644 index 91a07d5efb..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/homeController.mustache +++ /dev/null @@ -1,16 +0,0 @@ -package {{configPackage}}; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * Home redirection to swagger api documentation - */ -@Controller -public class HomeController { - @RequestMapping(value = "/") - public String index() { - System.out.println("swagger-ui.html"); - return "redirect:swagger-ui.html"; - } -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/jacksonConfiguration.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-boot/jacksonConfiguration.mustache deleted file mode 100644 index e96aa772c6..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/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/src/main/resources/mustache/JavaSpring/libraries/spring-boot/pom.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-boot/pom.mustache deleted file mode 100644 index da72c2bb8d..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/pom.mustache +++ /dev/null @@ -1,102 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - 2.9.2 - - - org.springframework.boot - spring-boot-starter-parent - 1.5.22.RELEASE - - - src/main/java - {{^interfaceOnly}} - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - {{/interfaceOnly}} - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - {{#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.6.4 - - {{/threetenbp}} -{{#useBeanValidation}} - - - javax.validation - validation-api - -{{/useBeanValidation}} - - - org.springframework.boot - spring-boot-starter-test - test - - - diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/swagger2SpringBoot.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-boot/swagger2SpringBoot.mustache deleted file mode 100644 index d329e337fb..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-boot/swagger2SpringBoot.mustache +++ /dev/null @@ -1,36 +0,0 @@ -package {{basePackage}}; - -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.ComponentScan; - -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@SpringBootApplication -@EnableSwagger2 -@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"}) -public class Swagger2SpringBoot 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(Swagger2SpringBoot.class).run(args); - } - - class ExitException extends RuntimeException implements ExitCodeGenerator { - private static final long serialVersionUID = 1L; - - @Override - public int getExitCode() { - return 10; - } - - } -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/Application.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/Application.mustache deleted file mode 100644 index 372b8da31e..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/Application.mustache +++ /dev/null @@ -1,20 +0,0 @@ -package io.swagger; - -import feign.Logger; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -@EnableFeignClients -public class Application { - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).run(args); - } - - @Bean - Logger.Level feignLoggerLevel() { - return Logger.Level.FULL; - } -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/README.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/README.mustache deleted file mode 100644 index 3130b07017..0000000000 --- a/src/main/resources/mustache/JavaSpring/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}} -# Swagger generated API stub - -Spring Framework stub - - -## Overview -This code was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), 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/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/apiClient.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/apiClient.mustache deleted file mode 100644 index 52fedbea77..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/apiClient.mustache +++ /dev/null @@ -1,10 +0,0 @@ -package {{package}}; - -import org.springframework.cloud.netflix.feign.FeignClient; -import {{configPackage}}.ClientConfiguration; - -{{=<% %>=}} -@FeignClient(name="${<%title%>.name:<%title%>}", url="${<%title%>.url:<%basePath%>}", configuration = ClientConfiguration.class) -<%={{ }}=%> -public interface {{classname}}Client extends {{classname}} { -} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/apiKeyRequestInterceptor.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/apiKeyRequestInterceptor.mustache deleted file mode 100644 index a7835fc983..0000000000 --- a/src/main/resources/mustache/JavaSpring/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/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/api_test.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/api_test.mustache deleted file mode 100644 index 0723a652b4..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/api_test.mustache +++ /dev/null @@ -1,45 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -import io.swagger.Application; - -import java.util.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import static org.junit.Assert.assertEquals; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = Application.class) -public class {{classname}}Test { - -@Autowired -private {{classname}} api; - -{{#operations}} -{{#operation}} -{{#contents}} - @Test - public void {{operationId}}Test() throws Exception { - {{#parameters}} - {{^isFile}} - {{{dataType}}} {{paramName}} = {{{example}}}; - {{/isFile}} - {{#isFile}} - org.springframework.web.multipart.MultipartFile {{paramName}} = null; - {{/isFile}} - {{/parameters}} - api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - // todo: add verifications - } -{{/contents}} -{{/operation}} -{{/operations}} -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/clientConfiguration.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/clientConfiguration.mustache deleted file mode 100644 index 3e86330c91..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/clientConfiguration.mustache +++ /dev/null @@ -1,105 +0,0 @@ -package {{configPackage}}; - -import feign.Logger; -import feign.auth.BasicAuthRequestInterceptor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; -import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; -import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; -import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; -import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails; -import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails; -import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails; -import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; -import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; - -@Configuration -@EnableConfigurationProperties -public class ClientConfiguration { - -{{#authMethods}} - {{#isBasic}} - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.username:}")<%={{ }}=%> - private String {{{name}}}Username; - - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.password:}")<%={{ }}=%> - private String {{{name}}}Password; - - @Bean - @ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.username") - public BasicAuthRequestInterceptor {{{name}}}RequestInterceptor() { - return new BasicAuthRequestInterceptor(this.{{{name}}}Username, this.{{{name}}}Password); - } - - {{/isBasic}} - {{#isApiKey}} - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.key:}")<%={{ }}=%> - private String {{{name}}}Key; - - @Bean - @ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.key") - public ApiKeyRequestInterceptor {{{name}}}RequestInterceptor() { - return new ApiKeyRequestInterceptor({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{{keyParamName}}}", this.{{{name}}}Key); - } - - {{/isApiKey}} - {{#isOAuth}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor() { - return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), {{{name}}}ResourceDetails()); - } - - {{#isCode}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public AuthorizationCodeResourceDetails {{{name}}}ResourceDetails() { - AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - details.setUserAuthorizationUri("{{{authorizationUrl}}}"); - return details; - } - - {{/isCode}} - {{#isPassword}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ResourceOwnerPasswordResourceDetails {{{name}}}ResourceDetails() { - ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - return details; - } - - {{/isPassword}} - {{#isApplication}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ClientCredentialsResourceDetails {{{name}}}ResourceDetails() { - ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - return details; - } - - {{/isApplication}} - {{#isImplicit}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ImplicitResourceDetails {{{name}}}ResourceDetails() { - ImplicitResourceDetails details = new ImplicitResourceDetails(); - details.setUserAuthorizationUri("{{{authorizationUrl}}}"); - return details; - } - - {{/isImplicit}} - {{/isOAuth}} -{{/authMethods}} -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/formParams.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/formParams.mustache deleted file mode 100644 index bd2cb8bb64..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/formParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestParam("{{baseName}}") MultipartFile {{paramName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/jacksonConfiguration.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/jacksonConfiguration.mustache deleted file mode 100644 index e96aa772c6..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/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/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/pom.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/pom.mustache deleted file mode 100644 index 9efcee55a5..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-cloud/pom.mustache +++ /dev/null @@ -1,99 +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 - - - org.springframework.boot - spring-boot-starter-parent - 1.5.4.RELEASE - - - src/main/java - - - - - - org.springframework.cloud - spring-cloud-starter-parent - Dalston.SR1 - pom - import - - - - - - - io.swagger - swagger-annotations - ${swagger-core-version} - - - org.springframework.cloud - spring-cloud-starter-feign - - - org.springframework.cloud - spring-cloud-security - - - org.springframework.security.oauth - spring-security-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 - 2.6.4 - - {{/threetenbp}} -{{#useBeanValidation}} - - - javax.validation - validation-api - 1.1.0.Final - provided - -{{/useBeanValidation}} - - org.springframework.boot - spring-boot-starter-test - test - - - diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/README.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/README.mustache deleted file mode 100644 index 1354151afb..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/README.mustache +++ /dev/null @@ -1,12 +0,0 @@ -# Swagger generated server - -Spring MVC Server - - -## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the Spring MVC framework. - -The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox) - -You can view the server in swagger-ui by pointing to -http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}/swagger-ui.html \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/RFC3339DateFormat.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/RFC3339DateFormat.mustache deleted file mode 100644 index 597120b5b2..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/RFC3339DateFormat.mustache +++ /dev/null @@ -1,22 +0,0 @@ -package {{configPackage}}; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - - -public class RFC3339DateFormat extends ISO8601DateFormat { - - private static final long serialVersionUID = 1L; - - // Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/api_test.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/api_test.mustache deleted file mode 100644 index 52f7248870..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/api_test.mustache +++ /dev/null @@ -1,33 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import java.util.*; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; - -import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; - -/** - * Test class to verify that GET endpoints on generated project are reached. - */ -public class {{classname}}ControllerIT { - - {{#operations}} - {{#operation}} - {{#vendorExtensions.x-is-get-method}} - @Test - public void {{operationId}}Test() throws Exception { - final String requestURL = "http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}{{testPath}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{paramName}}={{testExample}}{{#hasMore}}&{{/hasMore}}{{/queryParams}}"; - final HttpClient client = HttpClientBuilder.create().build(); - final HttpResponse response = client.execute(new HttpGet(requestURL)); - assertEquals(response.getStatusLine().getStatusCode(), 501); - } - {{/vendorExtensions.x-is-get-method}} - {{/operation}} - {{/operations}} -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/pom.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/pom.mustache deleted file mode 100644 index bd4245633c..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/pom.mustache +++ /dev/null @@ -1,205 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - src/main/java - - - org.apache.maven.plugins - maven-war-plugin - 3.1.0 - - - maven-failsafe-plugin - 2.18.1 - - - - integration-test - verify - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty-version} - - - {{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} - - target/${project.artifactId}-${project.version} - 8079 - stopit - 10 - - 8002 - 60000 - - - - - start-jetty - pre-integration-test - - start - - - 0 - true - - - - stop-jetty - post-integration-test - - stop - - - - - - - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - - - - - org.springframework - spring-core - ${spring-version} - - - org.springframework - spring-webmvc - ${spring-version} - - - org.springframework - spring-web - ${spring-version} - - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - com.fasterxml.jackson.core - jackson-annotations - - - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - {{#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}} - - - junit - junit - ${junit-version} - test - - - javax.servlet - servlet-api - ${servlet-api-version} - -{{#useBeanValidation}} - - - javax.validation - validation-api - 1.1.0.Final - provided - -{{/useBeanValidation}} - - org.testng - testng - 6.8.8 - test - - - junit - junit - - - snakeyaml - org.yaml - - - bsh - org.beanshell - - - - - - org.apache.httpcomponents - httpclient - 4.5.2 - test - - - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - 9.2.15.v20160210 - 1.7.21 - 4.12 - 2.5 - 2.7.0 - 2.8.9 - 2.6.4 - 4.3.9.RELEASE - - diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/swaggerUiConfiguration.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/swaggerUiConfiguration.mustache deleted file mode 100644 index 563a76915f..0000000000 --- a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/swaggerUiConfiguration.mustache +++ /dev/null @@ -1,89 +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}} -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Bean; -import org.springframework.http.converter.HttpMessageConverter; -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 springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.util.List; - -{{>generatedAnnotation}} -@Configuration -@ComponentScan(basePackages = "{{apiPackage}}") -@EnableWebMvc -@EnableSwagger2 //Loads the spring beans required by the framework -@PropertySource("classpath:swagger.properties") -@Import(SwaggerDocumentationConfig.class) -public class SwaggerUiConfiguration 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 addResourceHandlers(ResourceHandlerRegistry registry) { - if (!registry.hasMappingForPattern("/webjars/**")) { - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - if (!registry.hasMappingForPattern("/**")) { - registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); - } - } - - @Bean - public Jackson2ObjectMapperBuilder builder() { - Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() - .indentOutput(true) - .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .dateFormat(new RFC3339DateFormat()); - return builder; - } - - @Override - public void configureMessageConverters(List> converters) { - converters.add(new MappingJackson2HttpMessageConverter(objectMapper())); - super.configureMessageConverters(converters); - } - - @Bean - public ObjectMapper objectMapper(){ - return builder().build(); - } -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/webApplication.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/webApplication.mustache deleted file mode 100644 index 9c31004d13..0000000000 --- a/src/main/resources/mustache/JavaSpring/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[] { SwaggerUiConfiguration.class }; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[] { WebMvcConfiguration.class }; - } - - @Override - protected String[] getServletMappings() { - return new String[] { "/" }; - } -} diff --git a/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/webMvcConfiguration.mustache b/src/main/resources/mustache/JavaSpring/libraries/spring-mvc/webMvcConfiguration.mustache deleted file mode 100644 index d60c126316..0000000000 --- a/src/main/resources/mustache/JavaSpring/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/src/main/resources/mustache/JavaSpring/model.mustache b/src/main/resources/mustache/JavaSpring/model.mustache deleted file mode 100644 index 4c471ff2b7..0000000000 --- a/src/main/resources/mustache/JavaSpring/model.mustache +++ /dev/null @@ -1,40 +0,0 @@ -package {{package}}; - -{{^x-is-composed-model}} -import java.util.Objects; -{{#imports}}import {{import}}; -{{/imports}} -{{#serializableModel}} -import java.io.Serializable; -{{/serializableModel}} -{{#useBeanValidation}} -import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.*; -{{/useBeanValidation}} -{{#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}} -{{/x-is-composed-model}} - -{{#models}} -{{#model}} -{{#vendorExtensions.x-is-composed-model}} -{{>interface}} -{{/vendorExtensions.x-is-composed-model}} -{{^vendorExtensions.x-is-composed-model}} -{{#isEnum}} -{{>enumOuterClass}} -{{/isEnum}} -{{^isEnum}} -{{>pojo}} -{{/isEnum}} -{{/vendorExtensions.x-is-composed-model}} -{{/model}} -{{/models}} diff --git a/src/main/resources/mustache/JavaSpring/notFoundException.mustache b/src/main/resources/mustache/JavaSpring/notFoundException.mustache deleted file mode 100644 index 40c25c5ea5..0000000000 --- a/src/main/resources/mustache/JavaSpring/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/src/main/resources/mustache/JavaSpring/optionalDataType.mustache b/src/main/resources/mustache/JavaSpring/optionalDataType.mustache deleted file mode 100644 index 976950e27e..0000000000 --- a/src/main/resources/mustache/JavaSpring/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/src/main/resources/mustache/JavaSpring/pathParams.mustache b/src/main/resources/mustache/JavaSpring/pathParams.mustache deleted file mode 100644 index e433fa121a..0000000000 --- a/src/main/resources/mustache/JavaSpring/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}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/pojo.mustache b/src/main/resources/mustache/JavaSpring/pojo.mustache deleted file mode 100644 index f93000386f..0000000000 --- a/src/main/resources/mustache/JavaSpring/pojo.mustache +++ /dev/null @@ -1,140 +0,0 @@ -/** - * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} - */{{#description}} -@ApiModel(description = "{{{description}}}"){{/description}} -{{#useBeanValidation}}@Validated{{/useBeanValidation}} -{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} -public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable {{#interfaceModels}}, {{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{^serializableModel}}{{#interfaceModels}}{{#@first}}implements {{/@first}}{{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}} { -{{#serializableModel}} - private static final long serialVersionUID = 1L; - -{{/serializableModel}} - {{#vars}} - {{#isEnum}} - {{^isContainer}} -{{>enumClass}} - {{/isContainer}} - {{/isEnum}} - {{#items.isEnum}} - {{#items}} - {{^isContainer}} -{{>enumClass}} - {{/isContainer}} - {{/items}} - {{/items.isEnum}} - {{#jackson}} - @JsonProperty("{{baseName}}"){{#withXml}} - @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"){{/withXml}} - {{/jackson}} - {{#gson}} - @SerializedName("{{baseName}}") - {{/gson}} - {{#isContainer}} - {{#useBeanValidation}}@Valid{{/useBeanValidation}} - private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; - {{/isContainer}} - {{^isContainer}} - private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; - {{/isContainer}} - - {{/vars}} - {{#vars}} - public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { - this.{{name}} = {{name}}; - return this; - } - {{#isListContainer}} - - public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { - {{^required}} - if (this.{{name}} == null) { - this.{{name}} = {{{defaultValue}}}; - } - {{/required}} - this.{{name}}.add({{name}}Item); - return this; - } - {{/isListContainer}} - {{#isMapContainer}} - - public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { - {{^required}} - if (this.{{name}} == null) { - this.{{name}} = {{{defaultValue}}}; - } - {{/required}} - this.{{name}}.put(key, {{name}}Item); - return this; - } - {{/isMapContainer}} - - /** - {{#description}} - * {{{description}}} - {{/description}} - {{^description}} - * Get {{name}} - {{/description}} - {{#minimum}} - * minimum: {{minimum}} - {{/minimum}} - {{#maximum}} - * maximum: {{maximum}} - {{/maximum}} - * @return {{name}} - **/ - {{#vendorExtensions.extraAnnotation}} - {{{vendorExtensions.extraAnnotation}}} - {{/vendorExtensions.extraAnnotation}} - @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { - return {{name}}; - } - - public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { - this.{{name}} = {{name}}; - } - - {{/vars}} - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - }{{#hasVars}} - {{classname}} {{classVarName}} = ({{classname}}) o; - return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && - {{/hasMore}}{{/vars}}{{#parent}} && - super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} - return true;{{/hasVars}} - } - - @Override - public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class {{classname}} {\n"); - {{#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(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/src/main/resources/mustache/JavaSpring/project/build.properties b/src/main/resources/mustache/JavaSpring/project/build.properties deleted file mode 100644 index a8c2f849be..0000000000 --- a/src/main/resources/mustache/JavaSpring/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=0.12.0 diff --git a/src/main/resources/mustache/JavaSpring/project/plugins.sbt b/src/main/resources/mustache/JavaSpring/project/plugins.sbt deleted file mode 100644 index 713b7f3e99..0000000000 --- a/src/main/resources/mustache/JavaSpring/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/src/main/resources/mustache/JavaSpring/queryParams.mustache b/src/main/resources/mustache/JavaSpring/queryParams.mustache deleted file mode 100644 index 182152c6e5..0000000000 --- a/src/main/resources/mustache/JavaSpring/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}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/returnTypes.mustache b/src/main/resources/mustache/JavaSpring/returnTypes.mustache deleted file mode 100644 index c8f7a56938..0000000000 --- a/src/main/resources/mustache/JavaSpring/returnTypes.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring/swaggerDocumentationConfig.mustache b/src/main/resources/mustache/JavaSpring/swaggerDocumentationConfig.mustache deleted file mode 100644 index a0b2cded91..0000000000 --- a/src/main/resources/mustache/JavaSpring/swaggerDocumentationConfig.mustache +++ /dev/null @@ -1,56 +0,0 @@ -package {{configPackage}}; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -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.plugins.Docket; -{{#useOptional}} -import java.util.Optional; -{{/useOptional}} - -{{>generatedAnnotation}} -@Configuration -public class SwaggerDocumentationConfig { - - 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(){ - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("{{apiPackage}}")) - .build() - {{#java8}} - .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()); - } - -} diff --git a/src/main/resources/mustache/JavaSpring/typeInfoAnnotation.mustache b/src/main/resources/mustache/JavaSpring/typeInfoAnnotation.mustache deleted file mode 100644 index f2a2e1c88f..0000000000 --- a/src/main/resources/mustache/JavaSpring/typeInfoAnnotation.mustache +++ /dev/null @@ -1,7 +0,0 @@ -{{#jackson}} -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) -@JsonSubTypes({ - {{#children}} - @JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/children}} -}){{/jackson}} diff --git a/src/main/resources/mustache/JavaSpring/xmlAnnotation.mustache b/src/main/resources/mustache/JavaSpring/xmlAnnotation.mustache deleted file mode 100644 index fd81a4cf5d..0000000000 --- a/src/main/resources/mustache/JavaSpring/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 diff --git a/src/main/resources/mustache/JavaSpring2/api.mustache b/src/main/resources/mustache/JavaSpring2/api.mustache deleted file mode 100644 index 7551be6b6f..0000000000 --- a/src/main/resources/mustache/JavaSpring2/api.mustache +++ /dev/null @@ -1,138 +0,0 @@ -/** - * NOTE: This class is auto generated by the swagger code generator program ({{{generatorVersion}}}). - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -{{#jdk8-no-delegate}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/jdk8-no-delegate}} -import io.swagger.annotations.*; -{{#jdk8-no-delegate}} -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -{{/jdk8-no-delegate}} -import org.springframework.http.ResponseEntity; -{{#useBeanValidation}} -import org.springframework.validation.annotation.Validated; -{{/useBeanValidation}} -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -{{#jdk8-no-delegate}} -import javax.servlet.http.HttpServletRequest; -{{/jdk8-no-delegate}} -{{#useBeanValidation}} -import javax.validation.Valid; -import javax.validation.constraints.*; -{{/useBeanValidation}} -{{#jdk8-no-delegate}} -import java.io.IOException; -{{/jdk8-no-delegate}} -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}} -@Api(value = "{{{baseName}}}", description = "the {{{baseName}}} API") -{{#operations}} -public interface {{classname}} { -{{#jdk8}} - - {{^isDelegate}} - Logger log = LoggerFactory.getLogger({{classname}}.class); - - default Optional getObjectMapper() { - return Optional.empty(); - } - - default Optional getRequest() { - return Optional.empty(); - } - - default Optional getAcceptHeader() { - return getRequest().map(r -> r.getHeader("Accept")); - } - {{/isDelegate}} - {{#isDelegate}} - {{classname}}Delegate getDelegate(); - {{/isDelegate}} -{{/jdk8}} -{{#operation}} -{{#contents}} - - @ApiOperation(value = "{{{summary}}}", nickname = "{{{operationId}}}", notes = "{{{notes}}}"{{#returnBaseType}}, response = {{{returnBaseType}}}.class{{/returnBaseType}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { - {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { - {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, - {{/hasMore}}{{/scopes}} - }{{/isOAuth}}){{#hasMore}}, - {{/hasMore}}{{/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}}){{#hasMore}},{{/hasMore}}{{/responses}} }) - {{#implicitHeaders}} - @ApiImplicitParams({ - {{#headerParams}} - {{>implicitHeader}} - {{/headerParams}} - }) - {{/implicitHeaders}} - @RequestMapping(value = "{{{path}}}",{{#singleContentTypes}}{{#hasProduces}} - produces = "{{{vendorExtensions.x-accepts}}}", {{/hasProduces}}{{#hasConsumes}} - consumes = "{{{vendorExtensions.x-contentType}}}",{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} - produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}} - consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}} - method = RequestMethod.{{httpMethod}}) - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { - {{#delegate-method}} - return {{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - } - - // Override this method - default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { - {{/delegate-method}} - {{^isDelegate}} - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - {{#examples}} - if (getAcceptHeader().get().contains("{{{contentType}}}")) { - try { - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; - } - } - {{/examples}} - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); - } - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - {{/isDelegate}} - {{#isDelegate}} - return getDelegate().{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - {{/isDelegate}} - }{{/jdk8}} - -{{/contents}} -{{/operation}} -} -{{/operations}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/apiController.mustache b/src/main/resources/mustache/JavaSpring2/apiController.mustache deleted file mode 100644 index ab8eb2d9bc..0000000000 --- a/src/main/resources/mustache/JavaSpring2/apiController.mustache +++ /dev/null @@ -1,150 +0,0 @@ -package {{package}}; - -{{^jdk8}} -{{#imports}}import {{import}}; -{{/imports}} -{{/jdk8}} -{{^isDelegate}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/isDelegate}} -{{^jdk8}} -import io.swagger.annotations.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -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; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - - {{#useBeanValidation}} -import javax.validation.constraints.*; -import javax.validation.Valid; - {{/useBeanValidation}} -{{/jdk8}} -{{^isDelegate}} -import javax.servlet.http.HttpServletRequest; - {{#jdk8}} -import java.util.Optional; - {{/jdk8}} -{{/isDelegate}} -{{^jdk8-no-delegate}} - {{#useOptional}} -import java.util.Optional; - {{/useOptional}} -{{/jdk8-no-delegate}} -{{^jdk8}} - {{^isDelegate}} -import java.io.IOException; - {{/isDelegate}} -import java.util.List; -import java.util.Map; - {{#async}} -import java.util.concurrent.Callable; - {{/async}} -{{/jdk8}} -{{>generatedAnnotation}} -@Controller -{{#operations}} -public class {{classname}}Controller implements {{classname}} { - -{{#isDelegate}} - private final {{classname}}Delegate delegate; - - @org.springframework.beans.factory.annotation.Autowired - public {{classname}}Controller({{classname}}Delegate delegate) { - this.delegate = delegate; - } - {{#jdk8}} - - @Override - public {{classname}}Delegate getDelegate() { - return delegate; - } - {{/jdk8}} -{{/isDelegate}} -{{^isDelegate}} - {{^jdk8}} - private static final Logger log = LoggerFactory.getLogger({{classname}}Controller.class); - - {{/jdk8}} - private final ObjectMapper objectMapper; - - private final HttpServletRequest request; - - @org.springframework.beans.factory.annotation.Autowired - public {{classname}}Controller(ObjectMapper objectMapper, HttpServletRequest request) { - this.objectMapper = objectMapper; - this.request = request; - } - {{#jdk8}} - - @Override - public Optional getObjectMapper() { - return Optional.ofNullable(objectMapper); - } - - @Override - public Optional getRequest() { - return Optional.ofNullable(request); - } - {{/jdk8}} - -{{/isDelegate}} -{{^jdk8}} -{{#operation}} -{{#contents}} - public {{#async}}Callable<{{/async}}ResponseEntity<{{>returnTypes}}>{{#async}}>{{/async}} {{operationId}}({{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/parameters}}) { - {{^isDelegate}} - {{^async}} - String accept = request.getHeader("Accept"); - {{#examples}} - if (accept != null && accept.contains("{{{contentType}}}")) { - try { - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - {{/examples}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED); - {{/async}} - {{#async}} - return new CallablereturnTypes}}>>() { - @Override - public ResponseEntity<{{>returnTypes}}> call() { - String accept = request.getHeader("Accept"); - {{#examples}} - if (accept != null && accept.contains("{{{contentType}}}")) { - try { - return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED); - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.INTERNAL_SERVER_ERROR); - } - } - - {{/examples}} - return new ResponseEntity<{{>returnTypes}}>(HttpStatus.NOT_IMPLEMENTED); - } - }; - {{/async}} - {{/isDelegate}} - {{#isDelegate}} - return delegate.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - {{/isDelegate}} - } - -{{/contents}} -{{/operation}} -{{/jdk8}} -} -{{/operations}} diff --git a/src/main/resources/mustache/JavaSpring2/apiDelegate.mustache b/src/main/resources/mustache/JavaSpring2/apiDelegate.mustache deleted file mode 100644 index c75596caea..0000000000 --- a/src/main/resources/mustache/JavaSpring2/apiDelegate.mustache +++ /dev/null @@ -1,88 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -{{#jdk8}} -import com.fasterxml.jackson.databind.ObjectMapper; -{{/jdk8}} -import io.swagger.annotations.*; -{{#jdk8}} -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -{{/jdk8}} -import org.springframework.http.ResponseEntity; -import org.springframework.web.multipart.MultipartFile; -{{#jdk8}} -import java.io.IOException; -{{/jdk8}} - -{{#jdk8}} -import javax.servlet.http.HttpServletRequest; -{{/jdk8}} -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}} - - Logger log = LoggerFactory.getLogger({{classname}}.class); - - default Optional getObjectMapper() { - return Optional.empty(); - } - - default Optional getRequest() { - return Optional.empty(); - } - - default Optional getAcceptHeader() { - return getRequest().map(r -> r.getHeader("Accept")); - } -{{/jdk8}} - -{{#operation}} -{{#contents}} - /** - * @see {{classname}}#{{operationId}} - */ - {{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#parameters}}{{^isFile}} {{>optionalDataType}} {{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}}, - {{/hasMore}}{{/parameters}}){{^jdk8}};{{/jdk8}}{{#jdk8}} { - if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { - {{#examples}} - if (getAcceptHeader().get().contains("{{{contentType}}}")) { - try { - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(getObjectMapper().get().readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - } catch (IOException e) { - log.error("Couldn't serialize response for content type {{{contentType}}}", e); - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR){{#async}}){{/async}}; - } - } - {{/examples}} - } else { - log.warn("ObjectMapper or HttpServletRequest not configured in default {{classname}} interface so no example is generated"); - } - return {{#async}}CompletableFuture.completedFuture({{/async}}new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED){{#async}}){{/async}}; - }{{/jdk8}} - -{{/contents}} -{{/operation}} -} -{{/operations}} diff --git a/src/main/resources/mustache/JavaSpring2/apiException.mustache b/src/main/resources/mustache/JavaSpring2/apiException.mustache deleted file mode 100644 index f616114770..0000000000 --- a/src/main/resources/mustache/JavaSpring2/apiException.mustache +++ /dev/null @@ -1,10 +0,0 @@ -package {{apiPackage}}; - -{{>generatedAnnotation}} -public class ApiException extends Exception{ - private int code; - public ApiException (int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/src/main/resources/mustache/JavaSpring2/apiOriginFilter.mustache b/src/main/resources/mustache/JavaSpring2/apiOriginFilter.mustache deleted file mode 100644 index 5cf72a7dc4..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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/src/main/resources/mustache/JavaSpring2/apiResponseMessage.mustache b/src/main/resources/mustache/JavaSpring2/apiResponseMessage.mustache deleted file mode 100644 index 17b155f3b6..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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/src/main/resources/mustache/JavaSpring2/application.mustache b/src/main/resources/mustache/JavaSpring2/application.mustache deleted file mode 100644 index cf9520a7e7..0000000000 --- a/src/main/resources/mustache/JavaSpring2/application.mustache +++ /dev/null @@ -1,5 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -server.servlet.context-path={{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} -server.port={{serverPort}} -spring.jackson.date-format={{basePackage}}.RFC3339DateFormat -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false diff --git a/src/main/resources/mustache/JavaSpring2/application.properties b/src/main/resources/mustache/JavaSpring2/application.properties deleted file mode 100644 index 8d3a7a8292..0000000000 --- a/src/main/resources/mustache/JavaSpring2/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -springfox.documentation.swagger.v2.path=/api-docs -#server.port=8090 diff --git a/src/main/resources/mustache/JavaSpring2/beanValidation.mustache b/src/main/resources/mustache/JavaSpring2/beanValidation.mustache deleted file mode 100644 index 3e4ef612a4..0000000000 --- a/src/main/resources/mustache/JavaSpring2/beanValidation.mustache +++ /dev/null @@ -1,6 +0,0 @@ -{{#required}} - @NotNull -{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}} - @Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{#isNotContainer}}{{^isPrimitiveType}} - @Valid{{/isPrimitiveType}}{{/isNotContainer}} -{{>beanValidationCore}} diff --git a/src/main/resources/mustache/JavaSpring2/beanValidationCore.mustache b/src/main/resources/mustache/JavaSpring2/beanValidationCore.mustache deleted file mode 100644 index 29d043cc77..0000000000 --- a/src/main/resources/mustache/JavaSpring2/beanValidationCore.mustache +++ /dev/null @@ -1,20 +0,0 @@ -{{#pattern}}@Pattern(regexp="{{{pattern}}}"{{#vendorExtensions.x-pattern-message}}, message="{{vendorExtensions.x-pattern-message}}"{{/vendorExtensions.x-pattern-message}}) {{/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}}{{! -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("{{minimum}}"){{/minimum}}{{#maximum}} @DecimalMax("{{maximum}}") {{/maximum}}{{/isLong}}{{/isInteger}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/beanValidationPathParams.mustache b/src/main/resources/mustache/JavaSpring2/beanValidationPathParams.mustache deleted file mode 100644 index 051bd53c0a..0000000000 --- a/src/main/resources/mustache/JavaSpring2/beanValidationPathParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/beanValidationQueryParams.mustache b/src/main/resources/mustache/JavaSpring2/beanValidationQueryParams.mustache deleted file mode 100644 index 9cca8cb887..0000000000 --- a/src/main/resources/mustache/JavaSpring2/beanValidationQueryParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#required}}@NotNull {{/required}}{{>beanValidationCore}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/bodyParams.mustache b/src/main/resources/mustache/JavaSpring2/bodyParams.mustache deleted file mode 100644 index 7fef9ad2b6..0000000000 --- a/src/main/resources/mustache/JavaSpring2/bodyParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}} {{^isContainer}}{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestBody {{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/customInstantDeserializer.mustache b/src/main/resources/mustache/JavaSpring2/customInstantDeserializer.mustache deleted file mode 100644 index b7b8e251bd..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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.DateTimeUtils; -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.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.timeZoneToZoneId(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/src/main/resources/mustache/JavaSpring2/enumClass.mustache b/src/main/resources/mustache/JavaSpring2/enumClass.mustache deleted file mode 100644 index c5c3143cb9..0000000000 --- a/src/main/resources/mustache/JavaSpring2/enumClass.mustache +++ /dev/null @@ -1,44 +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; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { - for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - } diff --git a/src/main/resources/mustache/JavaSpring2/enumOuterClass.mustache b/src/main/resources/mustache/JavaSpring2/enumOuterClass.mustache deleted file mode 100644 index 76c2cbf5a7..0000000000 --- a/src/main/resources/mustache/JavaSpring2/enumOuterClass.mustache +++ /dev/null @@ -1,42 +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; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { - for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } -} diff --git a/src/main/resources/mustache/JavaSpring2/exampleReturnTypes.mustache b/src/main/resources/mustache/JavaSpring2/exampleReturnTypes.mustache deleted file mode 100644 index 395e3889c2..0000000000 --- a/src/main/resources/mustache/JavaSpring2/exampleReturnTypes.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/formParams.mustache b/src/main/resources/mustache/JavaSpring2/formParams.mustache deleted file mode 100644 index 7305792be1..0000000000 --- a/src/main/resources/mustache/JavaSpring2/formParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart("file") MultipartFile {{baseName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/generatedAnnotation.mustache b/src/main/resources/mustache/JavaSpring2/generatedAnnotation.mustache deleted file mode 100644 index ad17a426e9..0000000000 --- a/src/main/resources/mustache/JavaSpring2/generatedAnnotation.mustache +++ /dev/null @@ -1,3 +0,0 @@ -{{^hideGenerationTimestamp}} -@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") -{{/hideGenerationTimestamp}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/headerParams.mustache b/src/main/resources/mustache/JavaSpring2/headerParams.mustache deleted file mode 100644 index 89645c9436..0000000000 --- a/src/main/resources/mustache/JavaSpring2/headerParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{#-last}}{{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestHeader(value="{{baseName}}", required={{#required}}true{{/required}}{{^required}}false{{/required}}) {{>optionalDataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/implicitHeader.mustache b/src/main/resources/mustache/JavaSpring2/implicitHeader.mustache deleted file mode 100644 index 64d7af2080..0000000000 --- a/src/main/resources/mustache/JavaSpring2/implicitHeader.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isHeaderParam}}@ApiImplicitParam(name = "{{{paramName}}}", value = "{{{description}}}", {{#required}}required=true,{{/required}} dataType = "{{{dataType}}}", paramType = "header"){{#hasMore}},{{/hasMore}}{{/isHeaderParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/interface.mustache b/src/main/resources/mustache/JavaSpring2/interface.mustache deleted file mode 100644 index becc0c5549..0000000000 --- a/src/main/resources/mustache/JavaSpring2/interface.mustache +++ /dev/null @@ -1,6 +0,0 @@ -/** -* {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} -*/ -public interface {{{classname}}} { - -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/README.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/README.mustache deleted file mode 100644 index 02d932b8ac..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/README.mustache +++ /dev/null @@ -1,45 +0,0 @@ -{{^interfaceOnly}}# Swagger generated server - -Spring Boot Server - - -## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. -This is an example of building a swagger-enabled server in Java using the SpringBoot framework. - -The underlying library integrating swagger to SpringBoot is [springfox](https://github.com/springfox/springfox) - -Start your server as an simple java application - -You can view the api documentation in swagger-ui by pointing to -http://localhost:8080/ - -Change default port value in application.properties{{/interfaceOnly}}{{#interfaceOnly}} -# Swagger generated API stub - -Spring Framework stub - - -## Overview -This code was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), 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/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/RFC3339DateFormat.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/RFC3339DateFormat.mustache deleted file mode 100644 index d5dff8ac63..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/RFC3339DateFormat.mustache +++ /dev/null @@ -1,22 +0,0 @@ -package {{basePackage}}; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - - -public class RFC3339DateFormat extends ISO8601DateFormat { - - private static final long serialVersionUID = 1L; - - // Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/api_test.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/api_test.mustache deleted file mode 100644 index 6558eb235c..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/api_test.mustache +++ /dev/null @@ -1,45 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import java.util.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.junit.Assert.assertEquals; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class {{classname}}ControllerIntegrationTest { - - @Autowired - private {{classname}} api; - - {{#operations}} - {{#operation}} - {{#contents}} - @Test - public void {{operationId}}Test() throws Exception { - {{#parameters}} - {{^isFile}} - {{{dataType}}} {{paramName}} = {{{example}}}; - {{/isFile}} - {{#isFile}} - org.springframework.web.multipart.MultipartFile {{paramName}} = null; - {{/isFile}} - {{/parameters}} - ResponseEntity<{{>returnTypes}}> responseEntity = api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); - } - - {{/contents}} - {{/operation}} - {{/operations}} -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/homeController.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/homeController.mustache deleted file mode 100644 index 91a07d5efb..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/homeController.mustache +++ /dev/null @@ -1,16 +0,0 @@ -package {{configPackage}}; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * Home redirection to swagger api documentation - */ -@Controller -public class HomeController { - @RequestMapping(value = "/") - public String index() { - System.out.println("swagger-ui.html"); - return "redirect:swagger-ui.html"; - } -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/jacksonConfiguration.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/jacksonConfiguration.mustache deleted file mode 100644 index e96aa772c6..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/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/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/pom.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/pom.mustache deleted file mode 100644 index cc40757b88..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/pom.mustache +++ /dev/null @@ -1,102 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - 2.9.2 - - - org.springframework.boot - spring-boot-starter-parent - 2.1.7.RELEASE - - - src/main/java - {{^interfaceOnly}} - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - {{/interfaceOnly}} - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - {{#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.6.4 - - {{/threetenbp}} -{{#useBeanValidation}} - - - javax.validation - validation-api - -{{/useBeanValidation}} - - - org.springframework.boot - spring-boot-starter-test - test - - - diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/swagger2SpringBoot.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/swagger2SpringBoot.mustache deleted file mode 100644 index d329e337fb..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-boot/swagger2SpringBoot.mustache +++ /dev/null @@ -1,36 +0,0 @@ -package {{basePackage}}; - -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.ComponentScan; - -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@SpringBootApplication -@EnableSwagger2 -@ComponentScan(basePackages = { "{{basePackage}}", "{{apiPackage}}" , "{{configPackage}}"}) -public class Swagger2SpringBoot 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(Swagger2SpringBoot.class).run(args); - } - - class ExitException extends RuntimeException implements ExitCodeGenerator { - private static final long serialVersionUID = 1L; - - @Override - public int getExitCode() { - return 10; - } - - } -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/Application.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/Application.mustache deleted file mode 100644 index 372b8da31e..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/Application.mustache +++ /dev/null @@ -1,20 +0,0 @@ -package io.swagger; - -import feign.Logger; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cloud.netflix.feign.EnableFeignClients; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -@EnableFeignClients -public class Application { - public static void main(String[] args) { - new SpringApplicationBuilder(Application.class).run(args); - } - - @Bean - Logger.Level feignLoggerLevel() { - return Logger.Level.FULL; - } -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/README.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/README.mustache deleted file mode 100644 index 3130b07017..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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}} -# Swagger generated API stub - -Spring Framework stub - - -## Overview -This code was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), 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/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/apiClient.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/apiClient.mustache deleted file mode 100644 index 52fedbea77..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/apiClient.mustache +++ /dev/null @@ -1,10 +0,0 @@ -package {{package}}; - -import org.springframework.cloud.netflix.feign.FeignClient; -import {{configPackage}}.ClientConfiguration; - -{{=<% %>=}} -@FeignClient(name="${<%title%>.name:<%title%>}", url="${<%title%>.url:<%basePath%>}", configuration = ClientConfiguration.class) -<%={{ }}=%> -public interface {{classname}}Client extends {{classname}} { -} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/apiKeyRequestInterceptor.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/apiKeyRequestInterceptor.mustache deleted file mode 100644 index a7835fc983..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/api_test.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/api_test.mustache deleted file mode 100644 index 0723a652b4..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/api_test.mustache +++ /dev/null @@ -1,45 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} -import io.swagger.Application; - -import java.util.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import static org.junit.Assert.assertEquals; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = Application.class) -public class {{classname}}Test { - -@Autowired -private {{classname}} api; - -{{#operations}} -{{#operation}} -{{#contents}} - @Test - public void {{operationId}}Test() throws Exception { - {{#parameters}} - {{^isFile}} - {{{dataType}}} {{paramName}} = {{{example}}}; - {{/isFile}} - {{#isFile}} - org.springframework.web.multipart.MultipartFile {{paramName}} = null; - {{/isFile}} - {{/parameters}} - api.{{operationId}}({{#parameters}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}}); - // todo: add verifications - } -{{/contents}} -{{/operation}} -{{/operations}} -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/clientConfiguration.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/clientConfiguration.mustache deleted file mode 100644 index 3e86330c91..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/clientConfiguration.mustache +++ /dev/null @@ -1,105 +0,0 @@ -package {{configPackage}}; - -import feign.Logger; -import feign.auth.BasicAuthRequestInterceptor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.cloud.security.oauth2.client.feign.OAuth2FeignRequestInterceptor; -import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext; -import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; -import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; -import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails; -import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails; -import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails; -import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; -import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; - -@Configuration -@EnableConfigurationProperties -public class ClientConfiguration { - -{{#authMethods}} - {{#isBasic}} - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.username:}")<%={{ }}=%> - private String {{{name}}}Username; - - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.password:}")<%={{ }}=%> - private String {{{name}}}Password; - - @Bean - @ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.username") - public BasicAuthRequestInterceptor {{{name}}}RequestInterceptor() { - return new BasicAuthRequestInterceptor(this.{{{name}}}Username, this.{{{name}}}Password); - } - - {{/isBasic}} - {{#isApiKey}} - {{=<% %>=}}@Value("${<%title%>.security.<%name%>.key:}")<%={{ }}=%> - private String {{{name}}}Key; - - @Bean - @ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.key") - public ApiKeyRequestInterceptor {{{name}}}RequestInterceptor() { - return new ApiKeyRequestInterceptor({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{{keyParamName}}}", this.{{{name}}}Key); - } - - {{/isApiKey}} - {{#isOAuth}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor() { - return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), {{{name}}}ResourceDetails()); - } - - {{#isCode}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public AuthorizationCodeResourceDetails {{{name}}}ResourceDetails() { - AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - details.setUserAuthorizationUri("{{{authorizationUrl}}}"); - return details; - } - - {{/isCode}} - {{#isPassword}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ResourceOwnerPasswordResourceDetails {{{name}}}ResourceDetails() { - ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - return details; - } - - {{/isPassword}} - {{#isApplication}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ClientCredentialsResourceDetails {{{name}}}ResourceDetails() { - ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails(); - details.setAccessTokenUri("{{{tokenUrl}}}"); - return details; - } - - {{/isApplication}} - {{#isImplicit}} - @Bean - @ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id") - @ConfigurationProperties("{{{title}}}.security.{{{name}}}") - public ImplicitResourceDetails {{{name}}}ResourceDetails() { - ImplicitResourceDetails details = new ImplicitResourceDetails(); - details.setUserAuthorizationUri("{{{authorizationUrl}}}"); - return details; - } - - {{/isImplicit}} - {{/isOAuth}} -{{/authMethods}} -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/formParams.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/formParams.mustache deleted file mode 100644 index bd2cb8bb64..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/formParams.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#isFormParam}}{{#notFile}}@ApiParam(value = "{{{description}}}"{{#required}}, required=true{{/required}} {{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @RequestParam(value="{{baseName}}"{{#required}}, required=true{{/required}}{{^required}}, required=false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}@ApiParam(value = "file detail") @RequestParam("{{baseName}}") MultipartFile {{paramName}}{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/jacksonConfiguration.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/jacksonConfiguration.mustache deleted file mode 100644 index e96aa772c6..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/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/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/pom.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/pom.mustache deleted file mode 100644 index 9efcee55a5..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-cloud/pom.mustache +++ /dev/null @@ -1,99 +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 - - - org.springframework.boot - spring-boot-starter-parent - 1.5.4.RELEASE - - - src/main/java - - - - - - org.springframework.cloud - spring-cloud-starter-parent - Dalston.SR1 - pom - import - - - - - - - io.swagger - swagger-annotations - ${swagger-core-version} - - - org.springframework.cloud - spring-cloud-starter-feign - - - org.springframework.cloud - spring-cloud-security - - - org.springframework.security.oauth - spring-security-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 - 2.6.4 - - {{/threetenbp}} -{{#useBeanValidation}} - - - javax.validation - validation-api - 1.1.0.Final - provided - -{{/useBeanValidation}} - - org.springframework.boot - spring-boot-starter-test - test - - - diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/README.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/README.mustache deleted file mode 100644 index 1354151afb..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/README.mustache +++ /dev/null @@ -1,12 +0,0 @@ -# Swagger generated server - -Spring MVC Server - - -## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the Spring MVC framework. - -The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox) - -You can view the server in swagger-ui by pointing to -http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}/swagger-ui.html \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/RFC3339DateFormat.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/RFC3339DateFormat.mustache deleted file mode 100644 index 597120b5b2..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/RFC3339DateFormat.mustache +++ /dev/null @@ -1,22 +0,0 @@ -package {{configPackage}}; - -import com.fasterxml.jackson.databind.util.ISO8601DateFormat; -import com.fasterxml.jackson.databind.util.ISO8601Utils; - -import java.text.FieldPosition; -import java.util.Date; - - -public class RFC3339DateFormat extends ISO8601DateFormat { - - private static final long serialVersionUID = 1L; - - // Same as ISO8601DateFormat but serializing milliseconds. - @Override - public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { - String value = ISO8601Utils.format(date, true); - toAppendTo.append(value); - return toAppendTo; - } - -} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/api_test.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/api_test.mustache deleted file mode 100644 index 52f7248870..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/api_test.mustache +++ /dev/null @@ -1,33 +0,0 @@ -package {{package}}; - -{{#imports}}import {{import}}; -{{/imports}} - -import java.util.*; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.HttpClientBuilder; - -import org.testng.annotations.Test; -import static org.junit.Assert.assertEquals; - -/** - * Test class to verify that GET endpoints on generated project are reached. - */ -public class {{classname}}ControllerIT { - - {{#operations}} - {{#operation}} - {{#vendorExtensions.x-is-get-method}} - @Test - public void {{operationId}}Test() throws Exception { - final String requestURL = "http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}{{testPath}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{paramName}}={{testExample}}{{#hasMore}}&{{/hasMore}}{{/queryParams}}"; - final HttpClient client = HttpClientBuilder.create().build(); - final HttpResponse response = client.execute(new HttpGet(requestURL)); - assertEquals(response.getStatusLine().getStatusCode(), 501); - } - {{/vendorExtensions.x-is-get-method}} - {{/operation}} - {{/operations}} -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/pom.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/pom.mustache deleted file mode 100644 index bd4245633c..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/pom.mustache +++ /dev/null @@ -1,205 +0,0 @@ - - 4.0.0 - {{groupId}} - {{artifactId}} - jar - {{artifactId}} - {{artifactVersion}} - - src/main/java - - - org.apache.maven.plugins - maven-war-plugin - 3.1.0 - - - maven-failsafe-plugin - 2.18.1 - - - - integration-test - verify - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty-version} - - - {{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}} - - target/${project.artifactId}-${project.version} - 8079 - stopit - 10 - - 8002 - 60000 - - - - - start-jetty - pre-integration-test - - start - - - 0 - true - - - - stop-jetty - post-integration-test - - stop - - - - - - - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - - - - - org.springframework - spring-core - ${spring-version} - - - org.springframework - spring-webmvc - ${spring-version} - - - org.springframework - spring-web - ${spring-version} - - - - - io.springfox - springfox-swagger2 - ${springfox-version} - - - com.fasterxml.jackson.core - jackson-annotations - - - - - io.springfox - springfox-swagger-ui - ${springfox-version} - - {{#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}} - - - junit - junit - ${junit-version} - test - - - javax.servlet - servlet-api - ${servlet-api-version} - -{{#useBeanValidation}} - - - javax.validation - validation-api - 1.1.0.Final - provided - -{{/useBeanValidation}} - - org.testng - testng - 6.8.8 - test - - - junit - junit - - - snakeyaml - org.yaml - - - bsh - org.beanshell - - - - - - org.apache.httpcomponents - httpclient - 4.5.2 - test - - - - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - ${java.version} - ${java.version} - 9.2.15.v20160210 - 1.7.21 - 4.12 - 2.5 - 2.7.0 - 2.8.9 - 2.6.4 - 4.3.9.RELEASE - - diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/swaggerUiConfiguration.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/swaggerUiConfiguration.mustache deleted file mode 100644 index 563a76915f..0000000000 --- a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/swaggerUiConfiguration.mustache +++ /dev/null @@ -1,89 +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}} -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Bean; -import org.springframework.http.converter.HttpMessageConverter; -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 springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.util.List; - -{{>generatedAnnotation}} -@Configuration -@ComponentScan(basePackages = "{{apiPackage}}") -@EnableWebMvc -@EnableSwagger2 //Loads the spring beans required by the framework -@PropertySource("classpath:swagger.properties") -@Import(SwaggerDocumentationConfig.class) -public class SwaggerUiConfiguration 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 addResourceHandlers(ResourceHandlerRegistry registry) { - if (!registry.hasMappingForPattern("/webjars/**")) { - registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); - } - if (!registry.hasMappingForPattern("/**")) { - registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS); - } - } - - @Bean - public Jackson2ObjectMapperBuilder builder() { - Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() - .indentOutput(true) - .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .dateFormat(new RFC3339DateFormat()); - return builder; - } - - @Override - public void configureMessageConverters(List> converters) { - converters.add(new MappingJackson2HttpMessageConverter(objectMapper())); - super.configureMessageConverters(converters); - } - - @Bean - public ObjectMapper objectMapper(){ - return builder().build(); - } -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/webApplication.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/webApplication.mustache deleted file mode 100644 index 9c31004d13..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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[] { SwaggerUiConfiguration.class }; - } - - @Override - protected Class[] getServletConfigClasses() { - return new Class[] { WebMvcConfiguration.class }; - } - - @Override - protected String[] getServletMappings() { - return new String[] { "/" }; - } -} diff --git a/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/webMvcConfiguration.mustache b/src/main/resources/mustache/JavaSpring2/libraries/spring-mvc/webMvcConfiguration.mustache deleted file mode 100644 index d60c126316..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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/src/main/resources/mustache/JavaSpring2/model.mustache b/src/main/resources/mustache/JavaSpring2/model.mustache deleted file mode 100644 index 4c471ff2b7..0000000000 --- a/src/main/resources/mustache/JavaSpring2/model.mustache +++ /dev/null @@ -1,40 +0,0 @@ -package {{package}}; - -{{^x-is-composed-model}} -import java.util.Objects; -{{#imports}}import {{import}}; -{{/imports}} -{{#serializableModel}} -import java.io.Serializable; -{{/serializableModel}} -{{#useBeanValidation}} -import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.*; -{{/useBeanValidation}} -{{#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}} -{{/x-is-composed-model}} - -{{#models}} -{{#model}} -{{#vendorExtensions.x-is-composed-model}} -{{>interface}} -{{/vendorExtensions.x-is-composed-model}} -{{^vendorExtensions.x-is-composed-model}} -{{#isEnum}} -{{>enumOuterClass}} -{{/isEnum}} -{{^isEnum}} -{{>pojo}} -{{/isEnum}} -{{/vendorExtensions.x-is-composed-model}} -{{/model}} -{{/models}} diff --git a/src/main/resources/mustache/JavaSpring2/notFoundException.mustache b/src/main/resources/mustache/JavaSpring2/notFoundException.mustache deleted file mode 100644 index 40c25c5ea5..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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/src/main/resources/mustache/JavaSpring2/optionalDataType.mustache b/src/main/resources/mustache/JavaSpring2/optionalDataType.mustache deleted file mode 100644 index 976950e27e..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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/src/main/resources/mustache/JavaSpring2/pathParams.mustache b/src/main/resources/mustache/JavaSpring2/pathParams.mustache deleted file mode 100644 index e433fa121a..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathVariable("{{baseName}}") {{>optionalDataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/pojo.mustache b/src/main/resources/mustache/JavaSpring2/pojo.mustache deleted file mode 100644 index f93000386f..0000000000 --- a/src/main/resources/mustache/JavaSpring2/pojo.mustache +++ /dev/null @@ -1,140 +0,0 @@ -/** - * {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}} - */{{#description}} -@ApiModel(description = "{{{description}}}"){{/description}} -{{#useBeanValidation}}@Validated{{/useBeanValidation}} -{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} -public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable {{#interfaceModels}}, {{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}}{{^serializableModel}}{{#interfaceModels}}{{#@first}}implements {{/@first}}{{name}}{{^@last}}, {{/@last}}{{#@last}} {{/@last}}{{/interfaceModels}}{{/serializableModel}} { -{{#serializableModel}} - private static final long serialVersionUID = 1L; - -{{/serializableModel}} - {{#vars}} - {{#isEnum}} - {{^isContainer}} -{{>enumClass}} - {{/isContainer}} - {{/isEnum}} - {{#items.isEnum}} - {{#items}} - {{^isContainer}} -{{>enumClass}} - {{/isContainer}} - {{/items}} - {{/items.isEnum}} - {{#jackson}} - @JsonProperty("{{baseName}}"){{#withXml}} - @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"){{/withXml}} - {{/jackson}} - {{#gson}} - @SerializedName("{{baseName}}") - {{/gson}} - {{#isContainer}} - {{#useBeanValidation}}@Valid{{/useBeanValidation}} - private {{{datatypeWithEnum}}} {{name}}{{#required}} = {{{defaultValue}}}{{/required}}{{^required}} = null{{/required}}; - {{/isContainer}} - {{^isContainer}} - private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}}; - {{/isContainer}} - - {{/vars}} - {{#vars}} - public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { - this.{{name}} = {{name}}; - return this; - } - {{#isListContainer}} - - public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { - {{^required}} - if (this.{{name}} == null) { - this.{{name}} = {{{defaultValue}}}; - } - {{/required}} - this.{{name}}.add({{name}}Item); - return this; - } - {{/isListContainer}} - {{#isMapContainer}} - - public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { - {{^required}} - if (this.{{name}} == null) { - this.{{name}} = {{{defaultValue}}}; - } - {{/required}} - this.{{name}}.put(key, {{name}}Item); - return this; - } - {{/isMapContainer}} - - /** - {{#description}} - * {{{description}}} - {{/description}} - {{^description}} - * Get {{name}} - {{/description}} - {{#minimum}} - * minimum: {{minimum}} - {{/minimum}} - {{#maximum}} - * maximum: {{maximum}} - {{/maximum}} - * @return {{name}} - **/ - {{#vendorExtensions.extraAnnotation}} - {{{vendorExtensions.extraAnnotation}}} - {{/vendorExtensions.extraAnnotation}} - @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}") -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{#isBoolean}}is{{/isBoolean}}{{getter}}() { - return {{name}}; - } - - public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { - this.{{name}} = {{name}}; - } - - {{/vars}} - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - }{{#hasVars}} - {{classname}} {{classVarName}} = ({{classname}}) o; - return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && - {{/hasMore}}{{/vars}}{{#parent}} && - super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} - return true;{{/hasVars}} - } - - @Override - public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class {{classname}} {\n"); - {{#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(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/src/main/resources/mustache/JavaSpring2/project/build.properties b/src/main/resources/mustache/JavaSpring2/project/build.properties deleted file mode 100644 index a8c2f849be..0000000000 --- a/src/main/resources/mustache/JavaSpring2/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=0.12.0 diff --git a/src/main/resources/mustache/JavaSpring2/project/plugins.sbt b/src/main/resources/mustache/JavaSpring2/project/plugins.sbt deleted file mode 100644 index 713b7f3e99..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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/src/main/resources/mustache/JavaSpring2/queryParams.mustache b/src/main/resources/mustache/JavaSpring2/queryParams.mustache deleted file mode 100644 index 182152c6e5..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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}}{{#defaultValue}}, defaultValue = "{{{defaultValue}}}"{{/defaultValue}}) {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{>optionalDataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/returnTypes.mustache b/src/main/resources/mustache/JavaSpring2/returnTypes.mustache deleted file mode 100644 index c8f7a56938..0000000000 --- a/src/main/resources/mustache/JavaSpring2/returnTypes.mustache +++ /dev/null @@ -1 +0,0 @@ -{{#returnContainer}}{{#isMapContainer}}Map{{/isMapContainer}}{{#isListContainer}}List<{{{returnType}}}>{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}} \ No newline at end of file diff --git a/src/main/resources/mustache/JavaSpring2/swaggerDocumentationConfig.mustache b/src/main/resources/mustache/JavaSpring2/swaggerDocumentationConfig.mustache deleted file mode 100644 index a0b2cded91..0000000000 --- a/src/main/resources/mustache/JavaSpring2/swaggerDocumentationConfig.mustache +++ /dev/null @@ -1,56 +0,0 @@ -package {{configPackage}}; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -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.plugins.Docket; -{{#useOptional}} -import java.util.Optional; -{{/useOptional}} - -{{>generatedAnnotation}} -@Configuration -public class SwaggerDocumentationConfig { - - 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(){ - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("{{apiPackage}}")) - .build() - {{#java8}} - .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()); - } - -} diff --git a/src/main/resources/mustache/JavaSpring2/typeInfoAnnotation.mustache b/src/main/resources/mustache/JavaSpring2/typeInfoAnnotation.mustache deleted file mode 100644 index f2a2e1c88f..0000000000 --- a/src/main/resources/mustache/JavaSpring2/typeInfoAnnotation.mustache +++ /dev/null @@ -1,7 +0,0 @@ -{{#jackson}} -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{discriminator.propertyName}}", visible = true ) -@JsonSubTypes({ - {{#children}} - @JsonSubTypes.Type(value = {{classname}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), - {{/children}} -}){{/jackson}} diff --git a/src/main/resources/mustache/JavaSpring2/xmlAnnotation.mustache b/src/main/resources/mustache/JavaSpring2/xmlAnnotation.mustache deleted file mode 100644 index fd81a4cf5d..0000000000 --- a/src/main/resources/mustache/JavaSpring2/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 diff --git a/src/main/resources/mustache/typescript-angular/npmignore b/src/main/resources/mustache/typescript-angular/npmignore new file mode 100644 index 0000000000..7e981c47c9 --- /dev/null +++ b/src/main/resources/mustache/typescript-angular/npmignore @@ -0,0 +1,5 @@ +wwwroot/*.js +node +node_modules +typings +dist diff --git a/src/main/resources/mustache/typescript-angular/package.mustache b/src/main/resources/mustache/typescript-angular/package.mustache index 1aabb2cf1a..2cce79bca3 100644 --- a/src/main/resources/mustache/typescript-angular/package.mustache +++ b/src/main/resources/mustache/typescript-angular/package.mustache @@ -22,8 +22,8 @@ }, {{/useNgPackagr}} "peerDependencies": { - "@angular/core": "^{{ngVersion}}", - "@angular/http": "^{{ngVersion}}", + "@angular/core": "^{{ngVersion}}",{{^useHttpClientPackage}} + "@angular/http": "^{{ngVersion}}",{{/useHttpClientPackage}} "@angular/common": "^{{ngVersion}}", "@angular/compiler": "^{{ngVersion}}", "core-js": "^2.4.0", @@ -33,8 +33,8 @@ }, "devDependencies": { "@angular/compiler-cli": "^{{ngVersion}}", - "@angular/core": "^{{ngVersion}}", - "@angular/http": "^{{ngVersion}}", + "@angular/core": "^{{ngVersion}}",{{^useHttpClientPackage}} + "@angular/http": "^{{ngVersion}}",{{/useHttpClientPackage}} "@angular/common": "^{{ngVersion}}", "@angular/compiler": "^{{ngVersion}}", "@angular/platform-browser": "^{{ngVersion}}",{{#useNgPackagr}} @@ -42,7 +42,7 @@ "reflect-metadata": "^0.1.3", "rxjs": "{{#useRxJS6}}~6.3.3{{/useRxJS6}}{{^useRxJS6}}^5.4.0{{/useRxJS6}}", "zone.js": "^0.7.6", - "typescript": ">=2.1.5 <2.8" + "typescript": "{{#useNgPackagr}}~3.4.5{{/useNgPackagr}}{{^useNgPackagr}}^>=2.1.5 <2.8{{/useNgPackagr}}" }{{#npmRepository}},{{/npmRepository}} {{#npmRepository}} "publishConfig": {