forked from loafle/openapi-generator-original
Merge branch 'qtstc-master'
This commit is contained in:
@@ -2,32 +2,6 @@ package io.swagger.codegen;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.swagger.codegen.examples.ExampleGenerator;
|
||||
import io.swagger.models.ArrayModel;
|
||||
import io.swagger.models.ComposedModel;
|
||||
@@ -71,7 +45,29 @@ import io.swagger.models.properties.RefProperty;
|
||||
import io.swagger.models.properties.StringProperty;
|
||||
import io.swagger.models.properties.UUIDProperty;
|
||||
import io.swagger.util.Json;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DefaultCodegen {
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
|
||||
@@ -2609,7 +2605,11 @@ public class DefaultCodegen {
|
||||
}
|
||||
|
||||
addImport(m, cp.baseType);
|
||||
addImport(m, cp.complexType);
|
||||
CodegenProperty innerCp = cp;
|
||||
while(innerCp != null) {
|
||||
addImport(m, innerCp.complexType);
|
||||
innerCp = innerCp.items;
|
||||
}
|
||||
vars.add(cp);
|
||||
|
||||
// if required, add to the list "requiredVars"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.swagger.codegen.java;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import io.swagger.codegen.CodegenModel;
|
||||
import io.swagger.codegen.CodegenParameter;
|
||||
import io.swagger.codegen.CodegenProperty;
|
||||
@@ -12,13 +13,12 @@ import io.swagger.models.parameters.QueryParameter;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.ByteArrayProperty;
|
||||
import io.swagger.models.properties.DateTimeProperty;
|
||||
import io.swagger.models.properties.DecimalProperty;
|
||||
import io.swagger.models.properties.IntegerProperty;
|
||||
import io.swagger.models.properties.LongProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.RefProperty;
|
||||
import io.swagger.models.properties.StringProperty;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
@@ -458,6 +458,21 @@ public class JavaModelTest {
|
||||
Assert.assertNull(cm.allowableValues);
|
||||
}
|
||||
|
||||
@Test(description = "types used by inner properties should be imported")
|
||||
public void mapWithAnListOfBigDecimalTest() {
|
||||
final CodegenModel cm1 = new JavaClientCodegen().fromModel("sample", new ModelImpl()
|
||||
.description("model with Map<String, List<BigDecimal>>")
|
||||
.property("map", new MapProperty().additionalProperties(new ArrayProperty(new DecimalProperty()))));
|
||||
Assert.assertEquals(cm1.vars.get(0).datatype, "Map<String, List<BigDecimal>>");
|
||||
Assert.assertTrue(cm1.imports.contains("BigDecimal"));
|
||||
|
||||
final CodegenModel cm2 = new JavaClientCodegen().fromModel("sample", new ModelImpl()
|
||||
.description("model with Map<String, Map<String, List<BigDecimal>>>")
|
||||
.property("map", new MapProperty().additionalProperties(new MapProperty().additionalProperties(new ArrayProperty(new DecimalProperty())))));
|
||||
Assert.assertEquals(cm2.vars.get(0).datatype, "Map<String, Map<String, List<BigDecimal>>>");
|
||||
Assert.assertTrue(cm2.imports.contains("BigDecimal"));
|
||||
}
|
||||
|
||||
@DataProvider(name = "modelNames")
|
||||
public static Object[][] primeNumbers() {
|
||||
return new Object[][] {
|
||||
|
||||
@@ -1005,6 +1005,27 @@ definitions:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/ReadOnlyFirst'
|
||||
NumberOnly:
|
||||
type: object
|
||||
properties:
|
||||
JustNumber:
|
||||
type: number
|
||||
ArrayOfNumberOnly:
|
||||
type: object
|
||||
properties:
|
||||
ArrayNumber:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
ArrayOfArrayOfNumberOnly:
|
||||
type: object
|
||||
properties:
|
||||
ArrayArrayNumber:
|
||||
type: array
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
type: number
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: 'http://swagger.io'
|
||||
|
||||
29
samples/client/petstore/java/default/.travis.yml
Normal file
29
samples/client/petstore/java/default/.travis.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
- oraclejdk7
|
||||
before_install:
|
||||
# ensure gradlew has proper permission
|
||||
- chmod a+x ./gradlew
|
||||
script:
|
||||
# test using maven
|
||||
- mvn test
|
||||
# uncomment below to test using gradle
|
||||
# - gradle test
|
||||
# uncomment below to test using sbt
|
||||
# - sbt test
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
# ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayArrayNumber** | [**List<List<BigDecimal>>**](List.md) | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
# ArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayNumber** | [**List<BigDecimal>**](BigDecimal.md) | | [optional]
|
||||
|
||||
|
||||
|
||||
10
samples/client/petstore/java/default/docs/NumberOnly.md
Normal file
10
samples/client/petstore/java/default/docs/NumberOnly.md
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
# NumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**justNumber** | [**BigDecimal**](BigDecimal.md) | | [optional]
|
||||
|
||||
|
||||
|
||||
1
samples/client/petstore/java/default/hello.txt
Normal file
1
samples/client/petstore/java/default/hello.txt
Normal file
@@ -0,0 +1 @@
|
||||
Hello world!
|
||||
@@ -0,0 +1,77 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
|
||||
public class ArrayOfArrayOfNumberOnly {
|
||||
|
||||
private List<List<BigDecimal>> arrayArrayNumber = new ArrayList<List<BigDecimal>>();
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
public ArrayOfArrayOfNumberOnly arrayArrayNumber(List<List<BigDecimal>> arrayArrayNumber) {
|
||||
this.arrayArrayNumber = arrayArrayNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("ArrayArrayNumber")
|
||||
public List<List<BigDecimal>> getArrayArrayNumber() {
|
||||
return arrayArrayNumber;
|
||||
}
|
||||
public void setArrayArrayNumber(List<List<BigDecimal>> arrayArrayNumber) {
|
||||
this.arrayArrayNumber = arrayArrayNumber;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o;
|
||||
return Objects.equals(this.arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(arrayArrayNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ArrayOfArrayOfNumberOnly {\n");
|
||||
|
||||
sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* ArrayOfNumberOnly
|
||||
*/
|
||||
|
||||
public class ArrayOfNumberOnly {
|
||||
|
||||
private List<BigDecimal> arrayNumber = new ArrayList<BigDecimal>();
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
public ArrayOfNumberOnly arrayNumber(List<BigDecimal> arrayNumber) {
|
||||
this.arrayNumber = arrayNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("ArrayNumber")
|
||||
public List<BigDecimal> getArrayNumber() {
|
||||
return arrayNumber;
|
||||
}
|
||||
public void setArrayNumber(List<BigDecimal> arrayNumber) {
|
||||
this.arrayNumber = arrayNumber;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o;
|
||||
return Objects.equals(this.arrayNumber, arrayOfNumberOnly.arrayNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(arrayNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class ArrayOfNumberOnly {\n");
|
||||
|
||||
sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.client.model.ReadOnlyFirst;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* NumberOnly
|
||||
*/
|
||||
|
||||
public class NumberOnly {
|
||||
|
||||
private BigDecimal justNumber = null;
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
public NumberOnly justNumber(BigDecimal justNumber) {
|
||||
this.justNumber = justNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("JustNumber")
|
||||
public BigDecimal getJustNumber() {
|
||||
return justNumber;
|
||||
}
|
||||
public void setJustNumber(BigDecimal justNumber) {
|
||||
this.justNumber = justNumber;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
NumberOnly numberOnly = (NumberOnly) o;
|
||||
return Objects.equals(this.justNumber, numberOnly.justNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(justNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class NumberOnly {\n");
|
||||
|
||||
sb.append(" justNumber: ").append(toIndentedString(justNumber)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user