Skip to content

Commit

Permalink
merge gh_60 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellmann committed Feb 28, 2017
2 parents 6930aa4 + af6e205 commit 905e6a3
Show file tree
Hide file tree
Showing 57 changed files with 1,086 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.zalando.stups</groupId>
<artifactId>swagger-codegen-tooling</artifactId>
<version>0.4.39-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>docs</artifactId>

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -10,7 +10,7 @@

<groupId>org.zalando.stups</groupId>
<artifactId>swagger-codegen-tooling</artifactId>
<version>0.4.39-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Swagger-Codegen-Tooling -- Parent</name>

Expand Down Expand Up @@ -44,7 +44,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<version>0.7.8</version>
<executions>
<execution>
<id>default-prepare-agent</id>
Expand Down
2 changes: 1 addition & 1 deletion spring-boot-stups-swagger-codegen-ui/pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.zalando.stups</groupId>
<artifactId>swagger-codegen-tooling</artifactId>
<version>0.4.39-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>spring-boot-stups-swagger-codegen-ui</artifactId>

Expand Down
14 changes: 12 additions & 2 deletions swagger-codegen-common/pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.zalando.stups</groupId>
<artifactId>swagger-codegen-tooling</artifactId>
<version>0.4.39-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>swagger-codegen-common</artifactId>

Expand All @@ -15,7 +15,17 @@
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen</artifactId>
<version>2.1.6</version>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-parser</artifactId>
<version>1.0.25</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-compat-spec-parser</artifactId>
<version>1.0.25</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
Expand Up @@ -69,6 +69,15 @@ public class StandaloneCodegenerator {
private Map<String, Object> additionalProperties;

private List<String> excludedModels;

//
private boolean skipModelTests = true;

private boolean skipModelDocs = true;

private boolean skipApiTests = true;

private boolean skipApiDocs = true;

public static CodegeneratorBuilder builder() {
return new CodegeneratorBuilder();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion swagger-codegen-maven-plugin/pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.zalando.stups</groupId>
<artifactId>swagger-codegen-tooling</artifactId>
<version>0.4.39-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
</parent>
<groupId>org.zalando.maven.plugins</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
Expand Down
6 changes: 4 additions & 2 deletions swagger-codegen-maven-plugin/src/it/multi-execution/pom.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.zalando.maven.plugins.codegen.multi-execution.it</groupId>
<artifactId>simple</artifactId>
Expand Down Expand Up @@ -89,7 +90,8 @@
</goals>
<phase>generate-sources</phase>
</execution>
<!-- generates into different packages and all classes (api and model) into the same package -->
<!-- generates into different packages and all classes
(api and model) into the same package -->
<execution>
<id>second</id>
<configuration>
Expand Down
10 changes: 10 additions & 0 deletions swagger-codegen-maven-plugin/src/it/planb-provider/pom.xml
Expand Up @@ -18,6 +18,16 @@
<artifactId>swagger-annotations</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -29,6 +29,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
Expand Down
Expand Up @@ -53,6 +53,15 @@
<artifactId>swagger-jaxrs</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
<version>1.4.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

Expand All @@ -37,6 +37,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.zalando.stups</groupId>
<artifactId>spring-boot-stups-swagger-codegen-ui</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion swagger-codegen-templates/pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.zalando.stups</groupId>
<artifactId>swagger-codegen-tooling</artifactId>
<version>0.4.39-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>swagger-codegen-templates</artifactId>
<name>Swagger-Codegen-Templates -- Parent</name>
Expand Down
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.zalando.stups</groupId>
<artifactId>swagger-codegen-templates</artifactId>
<version>0.4.39-SNAPSHOT</version>
<version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>swagger-codegen-template-jaxrs-interfaces</artifactId>

Expand Down
Expand Up @@ -22,23 +22,25 @@
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;

/**
* 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 {

Expand Down Expand Up @@ -81,8 +83,8 @@ public List<SupportingFile> supportingFiles() {
supportingFiles.add(new SupportingFile("NotFoundException.mustache",
(apiPackage()).replace(".", File.separator), "NotFoundException.java"));

languageSpecificPrimitives = new HashSet<String>(Arrays.asList("String", "boolean", "Boolean", "Double",
"Integer", "Long", "Float"));
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList("String", "boolean", "Boolean", "Double", "Integer", "Long", "Float"));

return supportingFiles;
}
Expand Down Expand Up @@ -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<String, Object> postProcessOperations(final Map<String, Object> objs) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
Expand Down Expand Up @@ -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
Expand All @@ -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

}



}
@@ -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}}
<a name="{{operationId}}"></a>
# **{{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}}

0 comments on commit 905e6a3

Please sign in to comment.