better model name for php

This commit is contained in:
wing328 2016-03-04 14:26:28 +08:00
parent adc4547c8c
commit ae54301ed7
7 changed files with 799 additions and 0 deletions

View File

@ -358,6 +358,9 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public String toModelName(String name) { public String toModelName(String name) {
// remove [
name = name.replaceAll("\\]", "");
// Note: backslash ("\\") is allowed for e.g. "\\DateTime" // Note: backslash ("\\") is allowed for e.g. "\\DateTime"
name = name.replaceAll("[^\\w\\\\]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'. name = name.replaceAll("[^\\w\\\\]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.

View File

@ -0,0 +1,238 @@
<?php
/**
* InlineResponse200
*
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Copyright 2016 SmartBear Software
*
* 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.
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
namespace Swagger\Client\Model;
use \ArrayAccess;
/**
* InlineResponse200 Class Doc Comment
*
* @category Class
* @description
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
class InlineResponse200 implements ArrayAccess
{
/**
* Array of property to type mappings. Used for (de)serialization
* @var string[]
*/
static $swaggerTypes = array(
'id' => 'int',
'category' => 'object',
'name' => 'string'
);
/**
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
static $attributeMap = array(
'id' => 'id',
'category' => 'category',
'name' => 'name'
);
/**
* Array of attributes to setter functions (for deserialization of responses)
* @var string[]
*/
static $setters = array(
'id' => 'setId',
'category' => 'setCategory',
'name' => 'setName'
);
/**
* Array of attributes to getter functions (for serialization of requests)
* @var string[]
*/
static $getters = array(
'id' => 'getId',
'category' => 'getCategory',
'name' => 'getName'
);
/**
* $id
* @var int
*/
protected $id;
/**
* $category
* @var object
*/
protected $category;
/**
* $name
* @var string
*/
protected $name;
/**
* Constructor
* @param mixed[] $data Associated array of property value initalizing the model
*/
public function __construct(array $data = null)
{
if ($data != null) {
$this->id = $data["id"];
$this->category = $data["category"];
$this->name = $data["name"];
}
}
/**
* Gets id
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Sets id
* @param int $id
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Gets category
* @return object
*/
public function getCategory()
{
return $this->category;
}
/**
* Sets category
* @param object $category
* @return $this
*/
public function setCategory($category)
{
$this->category = $category;
return $this;
}
/**
* Gets name
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Sets name
* @param string $name
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
* @param integer $offset Offset
* @return boolean
*/
public function offsetExists($offset)
{
return isset($this->$offset);
}
/**
* Gets offset.
* @param integer $offset Offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->$offset;
}
/**
* Sets value based on offset.
* @param integer $offset Offset
* @param mixed $value Value to be set
* @return void
*/
public function offsetSet($offset, $value)
{
$this->$offset = $value;
}
/**
* Unsets offset.
* @param integer $offset Offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->$offset);
}
/**
* Gets the string presentation of the object
* @return string
*/
public function __toString()
{
if (defined('JSON_PRETTY_PRINT')) {
return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
} else {
return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this));
}
}
}

View File

@ -0,0 +1,174 @@
<?php
/**
* ObjectReturn
*
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Copyright 2016 SmartBear Software
*
* 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.
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
namespace Swagger\Client\Model;
use \ArrayAccess;
/**
* ObjectReturn Class Doc Comment
*
* @category Class
* @description
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
class ObjectReturn implements ArrayAccess
{
/**
* Array of property to type mappings. Used for (de)serialization
* @var string[]
*/
static $swaggerTypes = array(
'return' => 'int'
);
/**
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
static $attributeMap = array(
'return' => 'return'
);
/**
* Array of attributes to setter functions (for deserialization of responses)
* @var string[]
*/
static $setters = array(
'return' => 'setReturn'
);
/**
* Array of attributes to getter functions (for serialization of requests)
* @var string[]
*/
static $getters = array(
'return' => 'getReturn'
);
/**
* $return
* @var int
*/
protected $return;
/**
* Constructor
* @param mixed[] $data Associated array of property value initalizing the model
*/
public function __construct(array $data = null)
{
if ($data != null) {
$this->return = $data["return"];
}
}
/**
* Gets return
* @return int
*/
public function getReturn()
{
return $this->return;
}
/**
* Sets return
* @param int $return
* @return $this
*/
public function setReturn($return)
{
$this->return = $return;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
* @param integer $offset Offset
* @return boolean
*/
public function offsetExists($offset)
{
return isset($this->$offset);
}
/**
* Gets offset.
* @param integer $offset Offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->$offset;
}
/**
* Sets value based on offset.
* @param integer $offset Offset
* @param mixed $value Value to be set
* @return void
*/
public function offsetSet($offset, $value)
{
$this->$offset = $value;
}
/**
* Unsets offset.
* @param integer $offset Offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->$offset);
}
/**
* Gets the string presentation of the object
* @return string
*/
public function __toString()
{
if (defined('JSON_PRETTY_PRINT')) {
return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
} else {
return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this));
}
}
}

View File

@ -0,0 +1,174 @@
<?php
/**
* SpecialModelName
*
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Copyright 2016 SmartBear Software
*
* 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.
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
*/
namespace Swagger\Client\Model;
use \ArrayAccess;
/**
* SpecialModelName Class Doc Comment
*
* @category Class
* @description
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
class SpecialModelName implements ArrayAccess
{
/**
* Array of property to type mappings. Used for (de)serialization
* @var string[]
*/
static $swaggerTypes = array(
'special_property_name' => 'int'
);
/**
* Array of attributes where the key is the local name, and the value is the original name
* @var string[]
*/
static $attributeMap = array(
'special_property_name' => '$special[property.name]'
);
/**
* Array of attributes to setter functions (for deserialization of responses)
* @var string[]
*/
static $setters = array(
'special_property_name' => 'setSpecialPropertyName'
);
/**
* Array of attributes to getter functions (for serialization of requests)
* @var string[]
*/
static $getters = array(
'special_property_name' => 'getSpecialPropertyName'
);
/**
* $special_property_name
* @var int
*/
protected $special_property_name;
/**
* Constructor
* @param mixed[] $data Associated array of property value initalizing the model
*/
public function __construct(array $data = null)
{
if ($data != null) {
$this->special_property_name = $data["special_property_name"];
}
}
/**
* Gets special_property_name
* @return int
*/
public function getSpecialPropertyName()
{
return $this->special_property_name;
}
/**
* Sets special_property_name
* @param int $special_property_name
* @return $this
*/
public function setSpecialPropertyName($special_property_name)
{
$this->special_property_name = $special_property_name;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
* @param integer $offset Offset
* @return boolean
*/
public function offsetExists($offset)
{
return isset($this->$offset);
}
/**
* Gets offset.
* @param integer $offset Offset
* @return mixed
*/
public function offsetGet($offset)
{
return $this->$offset;
}
/**
* Sets value based on offset.
* @param integer $offset Offset
* @param mixed $value Value to be set
* @return void
*/
public function offsetSet($offset, $value)
{
$this->$offset = $value;
}
/**
* Unsets offset.
* @param integer $offset Offset
* @return void
*/
public function offsetUnset($offset)
{
unset($this->$offset);
}
/**
* Gets the string presentation of the object
* @return string
*/
public function __toString()
{
if (defined('JSON_PRETTY_PRINT')) {
return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
} else {
return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this));
}
}
}

View File

@ -0,0 +1,70 @@
<?php
/**
* InlineResponse200Test
*
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Copyright 2016 SmartBear Software
*
* 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.
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Please update the test case below to test the model.
*/
namespace Swagger\Client\Model;
/**
* InlineResponse200Test Class Doc Comment
*
* @category Class
* @description
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
class InlineResponse200Test extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running each test case
*/
public static function setUpBeforeClass() {
}
/**
* Clean up after running each test case
*/
public static function tearDownAfterClass() {
}
/**
* Test InlineResponse200
*/
public function testInlineResponse200() {
}
}

View File

@ -0,0 +1,70 @@
<?php
/**
* ObjectReturnTest
*
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Copyright 2016 SmartBear Software
*
* 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.
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Please update the test case below to test the model.
*/
namespace Swagger\Client\Model;
/**
* ObjectReturnTest Class Doc Comment
*
* @category Class
* @description
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
class ObjectReturnTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running each test case
*/
public static function setUpBeforeClass() {
}
/**
* Clean up after running each test case
*/
public static function tearDownAfterClass() {
}
/**
* Test ObjectReturn
*/
public function testObjectReturn() {
}
}

View File

@ -0,0 +1,70 @@
<?php
/**
* SpecialModelNameTest
*
* PHP version 5
*
* @category Class
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
/**
* Copyright 2016 SmartBear Software
*
* 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.
*/
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Please update the test case below to test the model.
*/
namespace Swagger\Client\Model;
/**
* SpecialModelNameTest Class Doc Comment
*
* @category Class
* @description
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
*/
class SpecialModelNameTest extends \PHPUnit_Framework_TestCase
{
/**
* Setup before running each test case
*/
public static function setUpBeforeClass() {
}
/**
* Clean up after running each test case
*/
public static function tearDownAfterClass() {
}
/**
* Test SpecialModelName
*/
public function testSpecialModelName() {
}
}