diff --git a/docs/pom.xml b/docs/pom.xml index 3f77d9e..dc0e1a6 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -3,7 +3,7 @@ org.zalando.stups swagger-codegen-tooling - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT docs diff --git a/pom.xml b/pom.xml index 19db04a..b9a9cf5 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.zalando.stups swagger-codegen-tooling - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT pom Swagger-Codegen-Tooling -- Parent @@ -44,7 +44,7 @@ org.jacoco jacoco-maven-plugin - 0.7.7.201606060606 + 0.7.8 default-prepare-agent diff --git a/spring-boot-stups-swagger-codegen-ui/pom.xml b/spring-boot-stups-swagger-codegen-ui/pom.xml index 898b16f..57b4984 100644 --- a/spring-boot-stups-swagger-codegen-ui/pom.xml +++ b/spring-boot-stups-swagger-codegen-ui/pom.xml @@ -3,7 +3,7 @@ org.zalando.stups swagger-codegen-tooling - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT spring-boot-stups-swagger-codegen-ui diff --git a/swagger-codegen-common/pom.xml b/swagger-codegen-common/pom.xml index 6712fe4..6df29ca 100644 --- a/swagger-codegen-common/pom.xml +++ b/swagger-codegen-common/pom.xml @@ -3,7 +3,7 @@ org.zalando.stups swagger-codegen-tooling - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT swagger-codegen-common @@ -15,7 +15,17 @@ io.swagger swagger-codegen - 2.1.6 + 2.2.1 + + + io.swagger + swagger-parser + 1.0.25 + + + io.swagger + swagger-compat-spec-parser + 1.0.25 junit diff --git a/swagger-codegen-common/src/main/java/org/zalando/stups/swagger/codegen/StandaloneCodegenerator.java b/swagger-codegen-common/src/main/java/org/zalando/stups/swagger/codegen/StandaloneCodegenerator.java index 77c6dbd..58330d7 100644 --- a/swagger-codegen-common/src/main/java/org/zalando/stups/swagger/codegen/StandaloneCodegenerator.java +++ b/swagger-codegen-common/src/main/java/org/zalando/stups/swagger/codegen/StandaloneCodegenerator.java @@ -69,6 +69,15 @@ public class StandaloneCodegenerator { private Map additionalProperties; private List excludedModels; + + // + private boolean skipModelTests = true; + + private boolean skipModelDocs = true; + + private boolean skipApiTests = true; + + private boolean skipApiDocs = true; public static CodegeneratorBuilder builder() { return new CodegeneratorBuilder(); @@ -170,6 +179,20 @@ public void generate() throws CodegenerationException { } } } + + if(skipModelTests){ + System.setProperty("modelTests", Boolean.FALSE.toString()); + } + + if(skipModelDocs){ + System.setProperty("modelDocs", Boolean.FALSE.toString()); + } + if(skipApiTests){ + System.setProperty("apiTests", Boolean.FALSE.toString()); + } + if(skipApiDocs){ + System.setProperty("apiDocs", Boolean.FALSE.toString()); + } try { clientOptInput.opts(clientOpts).swagger(swagger); diff --git a/swagger-codegen-maven-plugin/pom.xml b/swagger-codegen-maven-plugin/pom.xml index ad6ccf2..fd8cf8d 100644 --- a/swagger-codegen-maven-plugin/pom.xml +++ b/swagger-codegen-maven-plugin/pom.xml @@ -3,7 +3,7 @@ org.zalando.stups swagger-codegen-tooling - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT org.zalando.maven.plugins swagger-codegen-maven-plugin diff --git a/swagger-codegen-maven-plugin/src/it/multi-execution/pom.xml b/swagger-codegen-maven-plugin/src/it/multi-execution/pom.xml index bdd8b74..f80e556 100644 --- a/swagger-codegen-maven-plugin/src/it/multi-execution/pom.xml +++ b/swagger-codegen-maven-plugin/src/it/multi-execution/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 de.zalando.maven.plugins.codegen.multi-execution.it simple @@ -89,7 +90,8 @@ generate-sources - + second diff --git a/swagger-codegen-maven-plugin/src/it/planb-provider/pom.xml b/swagger-codegen-maven-plugin/src/it/planb-provider/pom.xml index 5ec2fc8..da6de74 100644 --- a/swagger-codegen-maven-plugin/src/it/planb-provider/pom.xml +++ b/swagger-codegen-maven-plugin/src/it/planb-provider/pom.xml @@ -18,6 +18,16 @@ swagger-annotations 1.5.8 + + com.fasterxml.jackson.core + jackson-databind + 2.8.7 + + + com.google.code.gson + gson + 2.8.0 + diff --git a/swagger-codegen-maven-plugin/src/it/spring-boot-jersey/pom.xml b/swagger-codegen-maven-plugin/src/it/spring-boot-jersey/pom.xml index 80c49f0..560ab1a 100644 --- a/swagger-codegen-maven-plugin/src/it/spring-boot-jersey/pom.xml +++ b/swagger-codegen-maven-plugin/src/it/spring-boot-jersey/pom.xml @@ -29,6 +29,15 @@ org.springframework.boot spring-boot-starter-jersey + + com.fasterxml.jackson.core + jackson-databind + + + com.google.code.gson + gson + 2.8.0 + io.swagger swagger-annotations diff --git a/swagger-codegen-maven-plugin/src/it/spring-boot-requestmapping/pom.xml b/swagger-codegen-maven-plugin/src/it/spring-boot-requestmapping/pom.xml index 4c09311..05713dc 100644 --- a/swagger-codegen-maven-plugin/src/it/spring-boot-requestmapping/pom.xml +++ b/swagger-codegen-maven-plugin/src/it/spring-boot-requestmapping/pom.xml @@ -53,6 +53,15 @@ swagger-jaxrs 1.5.8 + + com.fasterxml.jackson.core + jackson-databind + + + com.google.code.gson + gson + 2.8.0 + org.springframework.boot spring-boot-starter-test diff --git a/swagger-codegen-maven-plugin/src/it/swagger-codegen-ui-jetty/pom.xml b/swagger-codegen-maven-plugin/src/it/swagger-codegen-ui-jetty/pom.xml index 717ca80..486b871 100644 --- a/swagger-codegen-maven-plugin/src/it/swagger-codegen-ui-jetty/pom.xml +++ b/swagger-codegen-maven-plugin/src/it/swagger-codegen-ui-jetty/pom.xml @@ -13,7 +13,7 @@ org.springframework.boot spring-boot-starter-parent - 1.3.5.RELEASE + 1.4.4.RELEASE @@ -37,6 +37,15 @@ org.springframework.boot spring-boot-starter-jetty + + com.fasterxml.jackson.core + jackson-databind + + + com.google.code.gson + gson + 2.8.0 + org.zalando.stups spring-boot-stups-swagger-codegen-ui diff --git a/swagger-codegen-templates/pom.xml b/swagger-codegen-templates/pom.xml index 62439c9..713f8a1 100644 --- a/swagger-codegen-templates/pom.xml +++ b/swagger-codegen-templates/pom.xml @@ -3,7 +3,7 @@ org.zalando.stups swagger-codegen-tooling - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT swagger-codegen-templates Swagger-Codegen-Templates -- Parent diff --git a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/pom.xml b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/pom.xml index ffe80a6..f451565 100644 --- a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/pom.xml +++ b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/pom.xml @@ -3,7 +3,7 @@ org.zalando.stups swagger-codegen-templates - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT swagger-codegen-template-jaxrs-interfaces diff --git a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/java/de/zalando/stups/swagger/codegen/language/JaxRsInterfaces.java b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/java/de/zalando/stups/swagger/codegen/language/JaxRsInterfaces.java index ef8baa3..83bd400 100644 --- a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/java/de/zalando/stups/swagger/codegen/language/JaxRsInterfaces.java +++ b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/java/de/zalando/stups/swagger/codegen/language/JaxRsInterfaces.java @@ -22,15 +22,17 @@ import java.util.List; import java.util.Map; -import io.swagger.models.Swagger; import org.zalando.stups.swagger.codegen.ConfigurableCodegenConfig; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenModel; import io.swagger.codegen.CodegenOperation; +import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; import io.swagger.codegen.languages.JavaClientCodegen; import io.swagger.models.Operation; +import io.swagger.models.Swagger; import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.MapProperty; import io.swagger.models.properties.Property; @@ -38,7 +40,7 @@ /** * https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/JaxRSServerCodegen.java. * - * @author jbellmann + * @author jbellmann */ public class JaxRsInterfaces extends JavaClientCodegen implements CodegenConfig, ConfigurableCodegenConfig { @@ -81,8 +83,8 @@ public List supportingFiles() { supportingFiles.add(new SupportingFile("NotFoundException.mustache", (apiPackage()).replace(".", File.separator), "NotFoundException.java")); - languageSpecificPrimitives = new HashSet(Arrays.asList("String", "boolean", "Boolean", "Double", - "Integer", "Long", "Float")); + languageSpecificPrimitives = new HashSet( + Arrays.asList("String", "boolean", "Boolean", "Double", "Integer", "Long", "Float")); return supportingFiles; } @@ -164,6 +166,19 @@ public void addOperationToGroup(final String tag, final String resourcePath, fin co.baseName = basePath; } + @Override + public void processOpts() { + super.processOpts(); + // we do not want to have + importMapping.remove("SerializedName"); + } + + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + super.postProcessModelProperty(model, property); + model.imports.remove("SerializedName"); + } + public Map postProcessOperations(final Map objs) { Map operations = (Map) objs.get("operations"); if (operations != null) { @@ -224,8 +239,8 @@ public boolean is303Supported() { @Override public void enable303() { -// modelTemplateFiles.remove("model.mustache"); -// modelTemplateFiles.put("model303.mustache", ".java"); + // modelTemplateFiles.remove("model.mustache"); + // modelTemplateFiles.put("model303.mustache", ".java"); } @Override @@ -241,14 +256,13 @@ public String toApiName(String name) { @Override public void skipApiGeneration() { // TODO Auto-generated method stub - + } @Override public void skipModelGeneration() { // TODO Auto-generated method stub - + } - - + } diff --git a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/api_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/api_doc.mustache new file mode 100644 index 0000000..bbb5b66 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/api_doc.mustache @@ -0,0 +1,82 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```java +// Import classes:{{#hasAuthMethods}} +//import {{{invokerPackage}}}.ApiClient;{{/hasAuthMethods}} +//import {{{invokerPackage}}}.ApiException;{{#hasAuthMethods}} +//import {{{invokerPackage}}}.Configuration; +//import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} +//import {{{package}}}.{{{classname}}}; + +{{#hasAuthMethods}} +ApiClient defaultClient = Configuration.getDefaultApiClient(); +{{#authMethods}}{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setUsername("YOUR USERNAME"); +{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: {{{name}}} +ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +{{{classname}}} apiInstance = new {{{classname}}}(); +{{#allParams}} +{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + System.out.println(result);{{/returnType}} +} catch (ApiException e) { + System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); + e.printStackTrace(); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/api_test.mustache b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/api_test.mustache new file mode 100644 index 0000000..1d95ac2 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/api_test.mustache @@ -0,0 +1,45 @@ +{{>licenseInfo}} + +package {{package}}; + +import {{invokerPackage}}.ApiException; +{{#imports}}import {{import}}; +{{/imports}} +import org.junit.Test; +import org.junit.Ignore; + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{/fullJavaUtil}} + +/** + * API tests for {{classname}} + */ +@Ignore +public class {{classname}}Test { + + private final {{classname}} api = new {{classname}}(); + + {{#operations}}{{#operation}} + /** + * {{summary}} + * + * {{notes}} + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void {{operationId}}Test() throws ApiException { + {{#allParams}} + {{{dataType}}} {{paramName}} = null; + {{/allParams}} + {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + // TODO: test validations + } + {{/operation}}{{/operations}} +} diff --git a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/licenseInfo.mustache b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/licenseInfo.mustache new file mode 100644 index 0000000..94c36dd --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/licenseInfo.mustache @@ -0,0 +1,11 @@ +/* + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ diff --git a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/model_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/model_doc.mustache new file mode 100644 index 0000000..357f076 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/model_doc.mustache @@ -0,0 +1,4 @@ + +{{#models}}{{#model}} +{{#isEnum}}{{>enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/pojo_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/pojo_doc.mustache new file mode 100644 index 0000000..0e4c074 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-jaxrs-interfaces/src/main/resources/JaxRsInterfaces/pojo_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + + +## Enum: {{datatypeWithEnum}} +Name | Value +---- | -----{{#allowableValues}}{{#enumVars}} +{{name}} | {{value}}{{/enumVars}}{{/allowableValues}} +{{/isEnum}}{{/vars}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/pom.xml b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/pom.xml index d8f46e7..3a66a8d 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/pom.xml +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/pom.xml @@ -3,7 +3,7 @@ org.zalando.stups swagger-codegen-templates - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT swagger-codegen-template-spring-interfaces-split diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/api_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/api_doc.mustache new file mode 100644 index 0000000..bbb5b66 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/api_doc.mustache @@ -0,0 +1,82 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```java +// Import classes:{{#hasAuthMethods}} +//import {{{invokerPackage}}}.ApiClient;{{/hasAuthMethods}} +//import {{{invokerPackage}}}.ApiException;{{#hasAuthMethods}} +//import {{{invokerPackage}}}.Configuration; +//import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} +//import {{{package}}}.{{{classname}}}; + +{{#hasAuthMethods}} +ApiClient defaultClient = Configuration.getDefaultApiClient(); +{{#authMethods}}{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setUsername("YOUR USERNAME"); +{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: {{{name}}} +ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +{{{classname}}} apiInstance = new {{{classname}}}(); +{{#allParams}} +{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + System.out.println(result);{{/returnType}} +} catch (ApiException e) { + System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); + e.printStackTrace(); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/api_test.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/api_test.mustache new file mode 100644 index 0000000..1d95ac2 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/api_test.mustache @@ -0,0 +1,45 @@ +{{>licenseInfo}} + +package {{package}}; + +import {{invokerPackage}}.ApiException; +{{#imports}}import {{import}}; +{{/imports}} +import org.junit.Test; +import org.junit.Ignore; + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{/fullJavaUtil}} + +/** + * API tests for {{classname}} + */ +@Ignore +public class {{classname}}Test { + + private final {{classname}} api = new {{classname}}(); + + {{#operations}}{{#operation}} + /** + * {{summary}} + * + * {{notes}} + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void {{operationId}}Test() throws ApiException { + {{#allParams}} + {{{dataType}}} {{paramName}} = null; + {{/allParams}} + {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + // TODO: test validations + } + {{/operation}}{{/operations}} +} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/licenseInfo.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/licenseInfo.mustache new file mode 100644 index 0000000..94c36dd --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/licenseInfo.mustache @@ -0,0 +1,11 @@ +/* + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model.mustache index 56b2179..be6cb83 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model.mustache @@ -2,6 +2,8 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} + +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model303.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model303.mustache index a90b205..44ed806 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model303.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model303.mustache @@ -4,6 +4,7 @@ package {{package}}; {{/imports}} import javax.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model_doc.mustache new file mode 100644 index 0000000..357f076 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/model_doc.mustache @@ -0,0 +1,4 @@ + +{{#models}}{{#model}} +{{#isEnum}}{{>enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/pojo_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/pojo_doc.mustache new file mode 100644 index 0000000..0e4c074 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces-split/src/main/resources/SpringInterfacesSplitResponseEntityNoSwaggerAnnotations/pojo_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + + +## Enum: {{datatypeWithEnum}} +Name | Value +---- | -----{{#allowableValues}}{{#enumVars}} +{{name}} | {{value}}{{/enumVars}}{{/allowableValues}} +{{/isEnum}}{{/vars}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/pom.xml b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/pom.xml index b9d36d9..0c64570 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/pom.xml +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/pom.xml @@ -3,7 +3,7 @@ org.zalando.stups swagger-codegen-templates - 0.4.39-SNAPSHOT + 0.5.0-SNAPSHOT swagger-codegen-template-spring-interfaces diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/java/de/zalando/stups/swagger/codegen/language/AbstractSpringInterfaces.java b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/java/de/zalando/stups/swagger/codegen/language/AbstractSpringInterfaces.java index 54e91c2..88b84c1 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/java/de/zalando/stups/swagger/codegen/language/AbstractSpringInterfaces.java +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/java/de/zalando/stups/swagger/codegen/language/AbstractSpringInterfaces.java @@ -22,18 +22,20 @@ import java.util.List; import java.util.Map; -import io.swagger.models.Swagger; import org.zalando.stups.swagger.codegen.ConfigurableCodegenConfig; import com.google.common.collect.Lists; import io.swagger.codegen.CodegenConfig; +import io.swagger.codegen.CodegenModel; import io.swagger.codegen.CodegenOperation; +import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenResponse; import io.swagger.codegen.CodegenType; import io.swagger.codegen.SupportingFile; import io.swagger.codegen.languages.JavaClientCodegen; import io.swagger.models.Operation; +import io.swagger.models.Swagger; /** * https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/JaxRSServerCodegen.java. @@ -133,7 +135,8 @@ public String apiPackage() { } @Override - public void addOperationToGroup(final String tag, final String resourcePath, final Operation operation, final CodegenOperation co, final Map> operations) { + public void addOperationToGroup(final String tag, final String resourcePath, final Operation operation, + final CodegenOperation co, final Map> operations) { String basePath = resourcePath; if (basePath.startsWith("/")) { basePath = basePath.substring(1); @@ -164,6 +167,19 @@ public void addOperationToGroup(final String tag, final String resourcePath, fin co.baseName = basePath; } + @Override + public void processOpts() { + super.processOpts(); + // we do not want to have + importMapping.remove("SerializedName"); + } + + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + super.postProcessModelProperty(model, property); + model.imports.remove("SerializedName"); + } + private final List methodsWithoutRequestBody = Lists.newArrayList("GET", "DELETE"); @Override diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/api_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/api_doc.mustache new file mode 100644 index 0000000..bbb5b66 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/api_doc.mustache @@ -0,0 +1,82 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```java +// Import classes:{{#hasAuthMethods}} +//import {{{invokerPackage}}}.ApiClient;{{/hasAuthMethods}} +//import {{{invokerPackage}}}.ApiException;{{#hasAuthMethods}} +//import {{{invokerPackage}}}.Configuration; +//import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} +//import {{{package}}}.{{{classname}}}; + +{{#hasAuthMethods}} +ApiClient defaultClient = Configuration.getDefaultApiClient(); +{{#authMethods}}{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setUsername("YOUR USERNAME"); +{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: {{{name}}} +ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +{{{classname}}} apiInstance = new {{{classname}}}(); +{{#allParams}} +{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + System.out.println(result);{{/returnType}} +} catch (ApiException e) { + System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); + e.printStackTrace(); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/api_test.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/api_test.mustache new file mode 100644 index 0000000..1d95ac2 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/api_test.mustache @@ -0,0 +1,45 @@ +{{>licenseInfo}} + +package {{package}}; + +import {{invokerPackage}}.ApiException; +{{#imports}}import {{import}}; +{{/imports}} +import org.junit.Test; +import org.junit.Ignore; + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{/fullJavaUtil}} + +/** + * API tests for {{classname}} + */ +@Ignore +public class {{classname}}Test { + + private final {{classname}} api = new {{classname}}(); + + {{#operations}}{{#operation}} + /** + * {{summary}} + * + * {{notes}} + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void {{operationId}}Test() throws ApiException { + {{#allParams}} + {{{dataType}}} {{paramName}} = null; + {{/allParams}} + {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + // TODO: test validations + } + {{/operation}}{{/operations}} +} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/licenseInfo.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/licenseInfo.mustache new file mode 100644 index 0000000..94c36dd --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/licenseInfo.mustache @@ -0,0 +1,11 @@ +/* + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model.mustache index 54d478a..6508309 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model.mustache @@ -2,6 +2,8 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} + +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model303.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model303.mustache index a90b205..44ed806 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model303.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model303.mustache @@ -4,6 +4,7 @@ package {{package}}; {{/imports}} import javax.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model_doc.mustache new file mode 100644 index 0000000..357f076 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/model_doc.mustache @@ -0,0 +1,4 @@ + +{{#models}}{{#model}} +{{#isEnum}}{{>enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/pojo_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/pojo_doc.mustache new file mode 100644 index 0000000..0e4c074 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfaces/pojo_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + + +## Enum: {{datatypeWithEnum}} +Name | Value +---- | -----{{#allowableValues}}{{#enumVars}} +{{name}} | {{value}}{{/enumVars}}{{/allowableValues}} +{{/isEnum}}{{/vars}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/api_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/api_doc.mustache new file mode 100644 index 0000000..bbb5b66 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/api_doc.mustache @@ -0,0 +1,82 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```java +// Import classes:{{#hasAuthMethods}} +//import {{{invokerPackage}}}.ApiClient;{{/hasAuthMethods}} +//import {{{invokerPackage}}}.ApiException;{{#hasAuthMethods}} +//import {{{invokerPackage}}}.Configuration; +//import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} +//import {{{package}}}.{{{classname}}}; + +{{#hasAuthMethods}} +ApiClient defaultClient = Configuration.getDefaultApiClient(); +{{#authMethods}}{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setUsername("YOUR USERNAME"); +{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: {{{name}}} +ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +{{{classname}}} apiInstance = new {{{classname}}}(); +{{#allParams}} +{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + System.out.println(result);{{/returnType}} +} catch (ApiException e) { + System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); + e.printStackTrace(); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/api_test.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/api_test.mustache new file mode 100644 index 0000000..1d95ac2 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/api_test.mustache @@ -0,0 +1,45 @@ +{{>licenseInfo}} + +package {{package}}; + +import {{invokerPackage}}.ApiException; +{{#imports}}import {{import}}; +{{/imports}} +import org.junit.Test; +import org.junit.Ignore; + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{/fullJavaUtil}} + +/** + * API tests for {{classname}} + */ +@Ignore +public class {{classname}}Test { + + private final {{classname}} api = new {{classname}}(); + + {{#operations}}{{#operation}} + /** + * {{summary}} + * + * {{notes}} + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void {{operationId}}Test() throws ApiException { + {{#allParams}} + {{{dataType}}} {{paramName}} = null; + {{/allParams}} + {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + // TODO: test validations + } + {{/operation}}{{/operations}} +} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/licenseInfo.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/licenseInfo.mustache new file mode 100644 index 0000000..94c36dd --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/licenseInfo.mustache @@ -0,0 +1,11 @@ +/* + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model.mustache index 56b2179..be6cb83 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model.mustache @@ -2,6 +2,8 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} + +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model303.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model303.mustache index a90b205..44ed806 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model303.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model303.mustache @@ -4,6 +4,7 @@ package {{package}}; {{/imports}} import javax.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model_doc.mustache new file mode 100644 index 0000000..357f076 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/model_doc.mustache @@ -0,0 +1,4 @@ + +{{#models}}{{#model}} +{{#isEnum}}{{>enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/pojo_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/pojo_doc.mustache new file mode 100644 index 0000000..0e4c074 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesNoSwaggerAnnotations/pojo_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + + +## Enum: {{datatypeWithEnum}} +Name | Value +---- | -----{{#allowableValues}}{{#enumVars}} +{{name}} | {{value}}{{/enumVars}}{{/allowableValues}} +{{/isEnum}}{{/vars}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/api_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/api_doc.mustache new file mode 100644 index 0000000..bbb5b66 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/api_doc.mustache @@ -0,0 +1,82 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```java +// Import classes:{{#hasAuthMethods}} +//import {{{invokerPackage}}}.ApiClient;{{/hasAuthMethods}} +//import {{{invokerPackage}}}.ApiException;{{#hasAuthMethods}} +//import {{{invokerPackage}}}.Configuration; +//import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} +//import {{{package}}}.{{{classname}}}; + +{{#hasAuthMethods}} +ApiClient defaultClient = Configuration.getDefaultApiClient(); +{{#authMethods}}{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setUsername("YOUR USERNAME"); +{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: {{{name}}} +ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +{{{classname}}} apiInstance = new {{{classname}}}(); +{{#allParams}} +{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + System.out.println(result);{{/returnType}} +} catch (ApiException e) { + System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); + e.printStackTrace(); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/api_test.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/api_test.mustache new file mode 100644 index 0000000..1d95ac2 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/api_test.mustache @@ -0,0 +1,45 @@ +{{>licenseInfo}} + +package {{package}}; + +import {{invokerPackage}}.ApiException; +{{#imports}}import {{import}}; +{{/imports}} +import org.junit.Test; +import org.junit.Ignore; + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{/fullJavaUtil}} + +/** + * API tests for {{classname}} + */ +@Ignore +public class {{classname}}Test { + + private final {{classname}} api = new {{classname}}(); + + {{#operations}}{{#operation}} + /** + * {{summary}} + * + * {{notes}} + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void {{operationId}}Test() throws ApiException { + {{#allParams}} + {{{dataType}}} {{paramName}} = null; + {{/allParams}} + {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + // TODO: test validations + } + {{/operation}}{{/operations}} +} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/licenseInfo.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/licenseInfo.mustache new file mode 100644 index 0000000..94c36dd --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/licenseInfo.mustache @@ -0,0 +1,11 @@ +/* + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model.mustache index b69108b..de17d5b 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model.mustache @@ -2,6 +2,8 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} + +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model303.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model303.mustache index a90b205..985a2ff 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model303.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model303.mustache @@ -4,6 +4,8 @@ package {{package}}; {{/imports}} import javax.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonProperty; + {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model_doc.mustache new file mode 100644 index 0000000..357f076 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/model_doc.mustache @@ -0,0 +1,4 @@ + +{{#models}}{{#model}} +{{#isEnum}}{{>enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/pojo_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/pojo_doc.mustache new file mode 100644 index 0000000..0e4c074 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntity/pojo_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + + +## Enum: {{datatypeWithEnum}} +Name | Value +---- | -----{{#allowableValues}}{{#enumVars}} +{{name}} | {{value}}{{/enumVars}}{{/allowableValues}} +{{/isEnum}}{{/vars}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/api_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/api_doc.mustache new file mode 100644 index 0000000..bbb5b66 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/api_doc.mustache @@ -0,0 +1,82 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} + +# **{{operationId}}** +> {{#returnType}}{{returnType}} {{/returnType}}{{operationId}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{summary}}{{#notes}} + +{{notes}}{{/notes}} + +### Example +```java +// Import classes:{{#hasAuthMethods}} +//import {{{invokerPackage}}}.ApiClient;{{/hasAuthMethods}} +//import {{{invokerPackage}}}.ApiException;{{#hasAuthMethods}} +//import {{{invokerPackage}}}.Configuration; +//import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} +//import {{{package}}}.{{{classname}}}; + +{{#hasAuthMethods}} +ApiClient defaultClient = Configuration.getDefaultApiClient(); +{{#authMethods}}{{#isBasic}} +// Configure HTTP basic authorization: {{{name}}} +HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setUsername("YOUR USERNAME"); +{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: {{{name}}} +ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setApiKey("YOUR API KEY"); +// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) +//{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: {{{name}}} +OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); +{{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} + +{{{classname}}} apiInstance = new {{{classname}}}(); +{{#allParams}} +{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} +{{/allParams}} +try { + {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} + System.out.println(result);{{/returnType}} +} catch (ApiException e) { + System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); + e.printStackTrace(); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}{{#allowableValues}} [enum: {{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}]{{/allowableValues}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{returnType}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{returnType}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}null (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{/operation}} +{{/operations}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/api_test.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/api_test.mustache new file mode 100644 index 0000000..1d95ac2 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/api_test.mustache @@ -0,0 +1,45 @@ +{{>licenseInfo}} + +package {{package}}; + +import {{invokerPackage}}.ApiException; +{{#imports}}import {{import}}; +{{/imports}} +import org.junit.Test; +import org.junit.Ignore; + +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{/fullJavaUtil}} + +/** + * API tests for {{classname}} + */ +@Ignore +public class {{classname}}Test { + + private final {{classname}} api = new {{classname}}(); + + {{#operations}}{{#operation}} + /** + * {{summary}} + * + * {{notes}} + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void {{operationId}}Test() throws ApiException { + {{#allParams}} + {{{dataType}}} {{paramName}} = null; + {{/allParams}} + {{#returnType}}{{{returnType}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + + // TODO: test validations + } + {{/operation}}{{/operations}} +} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/licenseInfo.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/licenseInfo.mustache new file mode 100644 index 0000000..94c36dd --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/licenseInfo.mustache @@ -0,0 +1,11 @@ +/* + * {{{appName}}} + * {{{appDescription}}} + * + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model.mustache index 56b2179..be6cb83 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model.mustache @@ -2,6 +2,8 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} + +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model303.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model303.mustache index a90b205..44ed806 100644 --- a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model303.mustache +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model303.mustache @@ -4,6 +4,7 @@ package {{package}}; {{/imports}} import javax.validation.constraints.*; +import com.fasterxml.jackson.annotation.JsonProperty; {{#models}} {{#model}}{{#description}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model_doc.mustache new file mode 100644 index 0000000..357f076 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/model_doc.mustache @@ -0,0 +1,4 @@ + +{{#models}}{{#model}} +{{#isEnum}}{{>enum_outer_doc}}{{/isEnum}}{{^isEnum}}{{>pojo_doc}}{{/isEnum}} +{{/model}}{{/models}} diff --git a/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/pojo_doc.mustache b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/pojo_doc.mustache new file mode 100644 index 0000000..0e4c074 --- /dev/null +++ b/swagger-codegen-templates/swagger-codegen-template-spring-interfaces/src/main/resources/SpringInterfacesResponseEntityNoSwaggerAnnotations/pojo_doc.mustache @@ -0,0 +1,15 @@ +# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isEnum}}[**{{datatypeWithEnum}}**](#{{datatypeWithEnum}}){{/isEnum}}{{^isEnum}}{{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}}{{/isEnum}} | {{description}} | {{^required}} [optional]{{/required}}{{#readOnly}} [readonly]{{/readOnly}} +{{/vars}} +{{#vars}}{{#isEnum}} + + +## Enum: {{datatypeWithEnum}} +Name | Value +---- | -----{{#allowableValues}}{{#enumVars}} +{{name}} | {{value}}{{/enumVars}}{{/allowableValues}} +{{/isEnum}}{{/vars}}