Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: swagger-api/swagger-codegen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b57c3e3d74ff8b73dea1e3b0d1ca1750ba6c6439
Choose a base ref
..
head repository: swagger-api/swagger-codegen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1ba22dc201290a2b74415a956c7ea04be85a5d28
Choose a head ref
Showing with 124 additions and 1,256 deletions.
  1. +51 −13 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java
  2. +0 −345 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/ApiClient.mustache
  3. +0 −95 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/CollectionFormats.mustache
  4. +0 −35 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/api.mustache
  5. +0 −68 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/auth/ApiKeyAuth.mustache
  6. +0 −49 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/auth/HttpBasicAuth.mustache
  7. +0 −161 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/auth/OAuth.mustache
  8. +0 −69 ...es/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/auth/OAuthOkHttpClient.mustache
  9. +0 −1 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/bodyParams.mustache
  10. +0 −113 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/build.gradle.mustache
  11. +0 −1 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/formParams.mustache
  12. +0 −1 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/headerParams.mustache
  13. +0 −84 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/model.mustache
  14. +0 −1 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/pathParams.mustache
  15. +0 −158 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/pom.mustache
  16. +0 −1 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2-rx/queryParams.mustache
  17. +3 −0 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache
  18. +4 −2 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/api.mustache
  19. +13 −1 modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache
  20. +1 −1 ...es/swagger-codegen/src/test/java/io/swagger/codegen/inflector/JavaInflectorServerOptionsTest.java
  21. +1 −1 modules/swagger-codegen/src/test/java/io/swagger/codegen/java/JavaClientOptionsTest.java
  22. +1 −1 modules/swagger-codegen/src/test/java/io/swagger/codegen/jaxrs/JaxRSServerOptionsTest.java
  23. +27 −6 modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java
  24. +23 −49 modules/swagger-generator/src/test/java/io/swagger/generator/online/OnlineGeneratorOptionsTest.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
package io.swagger.codegen.languages;

import com.google.common.base.Strings;
import io.swagger.codegen.*;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenOperation;
import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
import io.swagger.models.Model;
import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
import io.swagger.models.parameters.FormParameter;
import io.swagger.models.parameters.Parameter;
import io.swagger.models.properties.*;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.*;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.BooleanProperty;
import io.swagger.models.properties.DoubleProperty;
import io.swagger.models.properties.FloatProperty;
import io.swagger.models.properties.IntegerProperty;
import io.swagger.models.properties.LongProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.StringProperty;

public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(JavaClientCodegen.class);
public static final String FULL_JAVA_UTIL = "fullJavaUtil";
public static final String DEFAULT_LIBRARY = "<default>";
public static final String DATE_LIBRARY = "dateLibrary";
public static final String USE_RX_JAVA = "useRxJava";

public static final String RETROFIT_1 = "retrofit";
public static final String RETROFIT_2 = "retrofit2";

protected String dateLibrary = "default";
protected String invokerPackage = "io.swagger.client";
@@ -34,6 +63,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
protected String javaUtilPrefix = "";
protected Boolean serializableModel = false;
protected boolean serializeBigDecimalAsString = false;
protected boolean useRxJava = false;

public JavaClientCodegen() {
super();
@@ -87,14 +117,14 @@ public JavaClientCodegen() {
cliOptions.add(CliOption.newBoolean(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, CodegenConstants
.SERIALIZE_BIG_DECIMAL_AS_STRING_DESC));
cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util"));
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library."));

supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2");
supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.1.1");
supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1");
supportedLibraries.put("retrofit", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
supportedLibraries.put("retrofit2", "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2)");
supportedLibraries.put("retrofit2-rx", "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta3), using RxJavaCallAdapterFactory.");
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2). Enable the RxJava adapter using '-DuseRxJava=true'.");

CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setDefault(DEFAULT_LIBRARY);
@@ -184,6 +214,10 @@ public void processOpts() {
if (additionalProperties.containsKey(FULL_JAVA_UTIL)) {
this.setFullJavaUtil(Boolean.valueOf(additionalProperties.get(FULL_JAVA_UTIL).toString()));
}

if (additionalProperties.containsKey(USE_RX_JAVA)) {
this.setUseRxJava(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA).toString()));
}
if (fullJavaUtil) {
javaUtilPrefix = "java.util.";
}
@@ -287,11 +321,11 @@ else if ("java8".equals(dateLibrary)) {
}

private boolean usesAnyRetrofitLibrary() {
return getLibrary() != null && getLibrary().contains("retrofit");
return getLibrary() != null && getLibrary().contains(RETROFIT_1);
}

private boolean usesRetrofit2Library() {
return getLibrary() != null && getLibrary().contains("retrofit2");
return getLibrary() != null && getLibrary().contains(RETROFIT_2);
}

private void sanitizeConfig() {
@@ -801,6 +835,10 @@ public void setFullJavaUtil(boolean fullJavaUtil) {
this.fullJavaUtil = fullJavaUtil;
}

public void setUseRxJava(boolean useRxJava) {
this.useRxJava = useRxJava;
}

public void setDateLibrary(String library) {
this.dateLibrary = library;
}
Loading