Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Apr 25, 2017
2 parents aef25ff + 702f193 commit f4d7807
Show file tree
Hide file tree
Showing 38 changed files with 205 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ out/
*.iws
classpath.txt
version.properties
!modules/swagger-codegen-cli/src/main/resources/version.properties
!modules/swagger-codegen/src/main/resources/version.properties
.project
.classpath
lib/*
Expand Down
12 changes: 0 additions & 12 deletions modules/swagger-codegen-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>logback.xml</exclude>
</excludes>
Expand Down Expand Up @@ -79,17 +78,6 @@
<artifactId>swagger-codegen</artifactId>
<version>${project.version}</version>
</dependency>
<!--https://github.com/airlift/airline-->
<dependency>
<groupId>io.airlift</groupId>
<artifactId>airline</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down

This file was deleted.

11 changes: 11 additions & 0 deletions modules/swagger-codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>logback.xml</exclude>
</excludes>
Expand Down Expand Up @@ -249,6 +250,16 @@
<artifactId>commons-cli</artifactId>
<version>${commons-cli-version}</version>
</dependency>
<dependency>
<groupId>io.airlift</groupId>
<artifactId>airline</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>com.googlecode.lambdaj</groupId>
<artifactId>lambdaj</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.codegen.cmd.Version;
import io.swagger.codegen.ignore.CodegenIgnoreProcessor;
import io.swagger.models.*;
import io.swagger.models.auth.OAuth2Definition;
Expand All @@ -10,15 +11,14 @@
import io.swagger.util.Json;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.*;
import java.util.*;

import org.apache.commons.lang3.StringUtils;

public class DefaultGenerator extends AbstractGenerator implements Generator {
protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
protected CodegenConfig config;
Expand Down Expand Up @@ -127,8 +127,8 @@ private void configureGeneratorProperties() {
config.processOpts();
config.preprocessSwagger(swagger);
// TODO need to obtain version from a file instead of hardcoding it
config.additionalProperties().put("generatorVersion", "2.2.3-SNAPSHOT");
config.additionalProperties().put("generatedDate", DateTime.now().toString());
config.additionalProperties().put("generatorVersion", Version.readVersionFromResources());
config.additionalProperties().put("generatorClass", config.getClass().getName());
config.additionalProperties().put("inputSpec", config.getInputSpec());
if (swagger.getVendorExtensions() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.io.Writer;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class SpringCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* 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}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ import javax.validation.Valid;
@Controller
{{#operations}}
public class {{classname}}Controller implements {{classname}} {
private final ObjectMapper objectMapper;
public {{classname}}Controller(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

{{#isDelegate}}
private final {{classname}}Delegate delegate;

Expand All @@ -49,11 +55,7 @@ public class {{classname}}Controller implements {{classname}} {
{{^isDelegate}}
{{^async}}
{{#examples}}
{{#-first}}

ObjectMapper objectMapper = new ObjectMapper();

{{/-first}}
if (accept != null && accept.contains("{{{contentType}}}")) {
return new ResponseEntity<{{>returnTypes}}>(objectMapper.readValue("{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{>exampleReturnTypes}}.class), HttpStatus.OK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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;
Expand Down Expand Up @@ -66,21 +67,23 @@ public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
}
}

@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<HttpMessageConverter<?>> converters) {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.dateFormat(new RFC3339DateFormat())
.build();
{{#threetenbp}}
ThreeTenModule module = new ThreeTenModule();
module.addDeserializer(Instant.class, CustomInstantDeserializer.INSTANT);
module.addDeserializer(OffsetDateTime.class, CustomInstantDeserializer.OFFSET_DATE_TIME);
module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME);
objectMapper.registerModule(module);
{{/threetenbp}}
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
super.configureMessageConverters(converters);
}

@Bean
public ObjectMapper objectMapper(){
return builder().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = ${project.version}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}

Expand All @@ -25,11 +25,11 @@ if(hasProperty('target') && target == 'android') {
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 25
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

package io.swagger.api;

import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@

@Controller
public class FakeApiController implements FakeApi {
private final ObjectMapper objectMapper;

public FakeApiController(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

package io.swagger.api;

import io.swagger.model.Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@

@Controller
public class FakeClassnameTestApiController implements FakeClassnameTestApi {
private final ObjectMapper objectMapper;

public FakeClassnameTestApiController(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

package io.swagger.api;

import io.swagger.model.ModelApiResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@

@Controller
public class PetApiController implements PetApi {
private final ObjectMapper objectMapper;

public PetApiController(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

package io.swagger.api;

import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@

@Controller
public class StoreApiController implements StoreApi {
private final ObjectMapper objectMapper;

public StoreApiController(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

package io.swagger.api;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@

@Controller
public class UserApiController implements UserApi {
private final ObjectMapper objectMapper;

public UserApiController(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand Down Expand Up @@ -58,14 +59,23 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
}
}

@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<HttpMessageConverter<?>> converters) {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.dateFormat(new RFC3339DateFormat())
.build();
converters.add(new MappingJackson2HttpMessageConverter(objectMapper));
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
super.configureMessageConverters(converters);
}

@Bean
public ObjectMapper objectMapper(){
return builder().build();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

package io.swagger.api;

import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@

@Controller
public class FakeApiController implements FakeApi {
private final ObjectMapper objectMapper;

public FakeApiController(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}

public ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true ) @Valid @RequestBody Client body,
@RequestHeader("Accept") String accept) throws IOException {
// do some magic!

ObjectMapper objectMapper = new ObjectMapper();

if (accept != null && accept.contains("application/json")) {
return new ResponseEntity<Client>(objectMapper.readValue("{ \"client\" : \"aeiou\"}", Client.class), HttpStatus.OK);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* NOTE: This class is auto generated by the swagger code generator program (2.3.0-SNAPSHOT).
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/

package io.swagger.api;

import io.swagger.model.Client;
Expand Down
Loading

0 comments on commit f4d7807

Please sign in to comment.