Skip to content

Commit

Permalink
fix java okhttp (array of enum property)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Aug 2, 2016
1 parent 25fa3e8 commit 1fde95f
Show file tree
Hide file tree
Showing 11 changed files with 536 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ samples/client/petstore/qt5cpp/PetStore/Makefile
#Java/Android
**/.gradle
samples/client/petstore/java/hello.txt
samples/client/petstore/java/okhttp-gson/hello.txt
samples/client/petstore/java/jersey2-java8/hello.txt
samples/client/petstore/android/default/hello.txt
samples/client/petstore/android/volley/.gradle/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ protected void updateDataTypeWithEnumForArray(CodegenProperty property) {

// set default value for variable with inner enum
if (property.defaultValue != null) {
property.defaultValue = property.defaultValue.replace(property.items.baseType, toEnumName(property.items));
property.defaultValue = property.defaultValue.replace(baseItem.baseType, toEnumName(baseItem));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1158,15 +1158,16 @@ definitions:
enum:
- fish
- crab
array_array_enum:
type: array
items:
type: array
items:
type: string
enum:
- Cat
- Dog
# comment out the following as 2d array of enum is not supported at the moment
#array_array_enum:
# type: array
# items:
# type: array
# items:
# type: string
# enum:
# - Cat
# - Dog
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
27 changes: 27 additions & 0 deletions samples/client/petstore/java/okhttp-gson/docs/EnumArrays.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# EnumArrays

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**justEnum** | [**JustEnumEnum**](#JustEnumEnum) | | [optional]
**arrayEnum** | [**List<ArrayEnumEnum>**](#List<ArrayEnumEnum>) | | [optional]


<a name="JustEnumEnum"></a>
## Enum: JustEnumEnum
Name | Value
---- | -----
BIRD | &quot;bird&quot;
EAGLE | &quot;eagle&quot;


<a name="List<ArrayEnumEnum>"></a>
## Enum: List&lt;ArrayEnumEnum&gt;
Name | Value
---- | -----
FISH | &quot;fish&quot;
CRAB | &quot;crab&quot;



Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/**
* Swagger Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* 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.
*
* 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.
*/


package io.swagger.client.model;

import java.util.Objects;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;


/**
* EnumArrays
*/

public class EnumArrays {
/**
* Gets or Sets justEnum
*/
public enum JustEnumEnum {
@SerializedName("bird")
BIRD("bird"),

@SerializedName("eagle")
EAGLE("eagle");

private String value;

JustEnumEnum(String value) {
this.value = value;
}

@Override
public String toString() {
return String.valueOf(value);
}
}

@SerializedName("just_enum")
private JustEnumEnum justEnum = null;

/**
* Gets or Sets arrayEnum
*/
public enum ArrayEnumEnum {
@SerializedName("fish")
FISH("fish"),

@SerializedName("crab")
CRAB("crab");

private String value;

ArrayEnumEnum(String value) {
this.value = value;
}

@Override
public String toString() {
return String.valueOf(value);
}
}

@SerializedName("array_enum")
private List<ArrayEnumEnum> arrayEnum = new ArrayList<ArrayEnumEnum>();

public EnumArrays justEnum(JustEnumEnum justEnum) {
this.justEnum = justEnum;
return this;
}

/**
* Get justEnum
* @return justEnum
**/
@ApiModelProperty(example = "null", value = "")
public JustEnumEnum getJustEnum() {
return justEnum;
}

public void setJustEnum(JustEnumEnum justEnum) {
this.justEnum = justEnum;
}

public EnumArrays arrayEnum(List<ArrayEnumEnum> arrayEnum) {
this.arrayEnum = arrayEnum;
return this;
}

public EnumArrays addArrayEnumItem(ArrayEnumEnum arrayEnumItem) {
this.arrayEnum.add(arrayEnumItem);
return this;
}

/**
* Get arrayEnum
* @return arrayEnum
**/
@ApiModelProperty(example = "null", value = "")
public List<ArrayEnumEnum> getArrayEnum() {
return arrayEnum;
}

public void setArrayEnum(List<ArrayEnumEnum> arrayEnum) {
this.arrayEnum = arrayEnum;
}


@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EnumArrays enumArrays = (EnumArrays) o;
return Objects.equals(this.justEnum, enumArrays.justEnum) &&
Objects.equals(this.arrayEnum, enumArrays.arrayEnum);
}

@Override
public int hashCode() {
return Objects.hash(justEnum, arrayEnum);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class EnumArrays {\n");

sb.append(" justEnum: ").append(toIndentedString(justEnum)).append("\n");
sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).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 ");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**just_enum** | **string** | | [optional]
**array_enum** | **string[]** | | [optional]
**array_array_enum** | [**string[][]**](array.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ class EnumArrays implements ArrayAccess
*/
protected static $swaggerTypes = array(
'just_enum' => 'string',
'array_enum' => 'string[]',
'array_array_enum' => 'string[][]'
'array_enum' => 'string[]'
);

public static function swaggerTypes()
Expand All @@ -82,8 +81,7 @@ public static function swaggerTypes()
*/
protected static $attributeMap = array(
'just_enum' => 'just_enum',
'array_enum' => 'array_enum',
'array_array_enum' => 'array_array_enum'
'array_enum' => 'array_enum'
);

public static function attributeMap()
Expand All @@ -97,8 +95,7 @@ public static function attributeMap()
*/
protected static $setters = array(
'just_enum' => 'setJustEnum',
'array_enum' => 'setArrayEnum',
'array_array_enum' => 'setArrayArrayEnum'
'array_enum' => 'setArrayEnum'
);

public static function setters()
Expand All @@ -112,8 +109,7 @@ public static function setters()
*/
protected static $getters = array(
'just_enum' => 'getJustEnum',
'array_enum' => 'getArrayEnum',
'array_array_enum' => 'getArrayArrayEnum'
'array_enum' => 'getArrayEnum'
);

public static function getters()
Expand All @@ -125,8 +121,6 @@ public static function getters()
const JUST_ENUM_EAGLE = 'eagle';
const ARRAY_ENUM_FISH = 'fish';
const ARRAY_ENUM_CRAB = 'crab';
const ARRAY_ARRAY_ENUM_CAT = 'Cat';
const ARRAY_ARRAY_ENUM_DOG = 'Dog';



Expand Down Expand Up @@ -154,18 +148,6 @@ public function getArrayEnumAllowableValues()
];
}

/**
* Gets allowable values of the enum
* @return string[]
*/
public function getArrayArrayEnumAllowableValues()
{
return [
self::ARRAY_ARRAY_ENUM_CAT,
self::ARRAY_ARRAY_ENUM_DOG,
];
}


/**
* Associative array for storing property values
Expand All @@ -181,7 +163,6 @@ public function __construct(array $data = null)
{
$this->container['just_enum'] = isset($data['just_enum']) ? $data['just_enum'] : null;
$this->container['array_enum'] = isset($data['array_enum']) ? $data['array_enum'] : null;
$this->container['array_array_enum'] = isset($data['array_array_enum']) ? $data['array_array_enum'] : null;
}

/**
Expand Down Expand Up @@ -265,31 +246,6 @@ public function setArrayEnum($array_enum)

return $this;
}

/**
* Gets array_array_enum
* @return string[][]
*/
public function getArrayArrayEnum()
{
return $this->container['array_array_enum'];
}

/**
* Sets array_array_enum
* @param string[][] $array_array_enum
* @return $this
*/
public function setArrayArrayEnum($array_array_enum)
{
$allowed_values = array('Cat', 'Dog');
if (!in_array($array_array_enum, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for 'array_array_enum', must be one of 'Cat', 'Dog'");
}
$this->container['array_array_enum'] = $array_array_enum;

return $this;
}
/**
* Returns true if offset exists. False otherwise.
* @param integer $offset Offset
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/

- API version: 1.0.0
- Package version: 1.0.0
- Build date: 2016-08-01T21:53:35.575+08:00
- Build date: 2016-08-03T00:39:31.384+08:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen

## Installation
Expand Down
9 changes: 9 additions & 0 deletions samples/client/petstore/ruby/docs/EnumArrays.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Petstore::EnumArrays

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**just_enum** | **String** | | [optional]
**array_enum** | **Array&lt;String&gt;** | | [optional]


Loading

0 comments on commit 1fde95f

Please sign in to comment.