forked from loafle/openapi-generator-original
add __toString and update php sample
This commit is contained in:
parent
456e17430b
commit
436db1f8e7
@ -65,6 +65,14 @@ class {{classname}} implements ArrayAccess {
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
if (defined('JSON_PRETTY_PRINT')) {
|
||||
return json_encode($this, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
|
@ -61,4 +61,12 @@ class Category implements ArrayAccess {
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
if (defined('JSON_PRETTY_PRINT')) {
|
||||
return json_encode($this, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,4 +80,12 @@ class Order implements ArrayAccess {
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
if (defined('JSON_PRETTY_PRINT')) {
|
||||
return json_encode($this, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,4 +80,12 @@ class Pet implements ArrayAccess {
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
if (defined('JSON_PRETTY_PRINT')) {
|
||||
return json_encode($this, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,4 +61,12 @@ class Tag implements ArrayAccess {
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
if (defined('JSON_PRETTY_PRINT')) {
|
||||
return json_encode($this, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,4 +88,12 @@ class User implements ArrayAccess {
|
||||
public function offsetUnset($offset) {
|
||||
unset($this->$offset);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
if (defined('JSON_PRETTY_PRINT')) {
|
||||
return json_encode($this, JSON_PRETTY_PRINT);
|
||||
} else {
|
||||
return json_encode($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
// for error reporting (need to run with php5.3 to get no warning)
|
||||
//ini_set('display_errors', 1);
|
||||
//error_reporting(~0);
|
||||
ini_set('display_startup_errors',1);
|
||||
ini_set('display_errors',1);
|
||||
error_reporting(-1);
|
||||
|
||||
// enable debugging
|
||||
//SwaggerClient\Configuration::$debug = true;
|
||||
|
@ -23,7 +23,8 @@ try {
|
||||
$pet_api->getApiClient()->addDefaultHeader("TEST_API_KEY", "09182sdkanafndsl903");
|
||||
// return Pet (model)
|
||||
$response = $pet_api->getPetById($petId);
|
||||
var_dump($response);
|
||||
// to test __toString()
|
||||
print ($response);
|
||||
|
||||
// add pet (post json)
|
||||
$new_pet_id = 10005;
|
||||
|
Loading…
x
Reference in New Issue
Block a user