From b5de3a446f60f092c10349c9d05a78f822aa62ea Mon Sep 17 00:00:00 2001 From: Pete Holiday Date: Mon, 23 Jan 2017 15:09:50 -0500 Subject: [PATCH 1/2] Prefix apiPackage and modelPackage with invokerPackage. Fix #4538: Ensure that generated API and Model classes are available to the autoloader. Change generator behavior to match documentation for invokerPackage, which reads "The main namespace to use for all classes." --- .../codegen/languages/PhpClientCodegen.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index cf457bbd06c..7bea1ce4da2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -232,17 +232,25 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { this.setInvokerPackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); + + // Update the invokerPackage for the default apiPackage and modelPackage + apiPackage = invokerPackage + "\\" + apiDirName; + modelPackage = invokerPackage + "\\" + modelDirName; } else { additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage); } - if (!additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { - additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); + if (additionalProperties.containsKey(CodegenConstants.MODEL_PACKAGE)) { + // Update model package to contain the specified model package name and the invoker package + modelPackage = invokerPackage + "\\" + (String) additionalProperties.get(CodegenConstants.MODEL_PACKAGE); } + additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage); - if (!additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { - additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); + if (additionalProperties.containsKey(CodegenConstants.API_PACKAGE)) { + // Update model package to contain the specified model package name and the invoker package + apiPackage = invokerPackage + "\\" + (String) additionalProperties.get(CodegenConstants.API_PACKAGE); } + additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage); if (additionalProperties.containsKey(COMPOSER_PROJECT_NAME)) { this.setComposerProjectName((String) additionalProperties.get(COMPOSER_PROJECT_NAME)); From 02dcd0eaf7bc0d64246e697af5338dadb35879e1 Mon Sep 17 00:00:00 2001 From: Pete Holiday Date: Mon, 23 Jan 2017 15:14:18 -0500 Subject: [PATCH 2/2] Update petstore samples; these appear to have been added by #4616 --- .../docs/Model/Capitalization.md | 15 + .../lib/Model/Capitalization.php | 358 ++++++++++++++++++ .../test/Model/CapitalizationTest.php | 133 +++++++ 3 files changed, 506 insertions(+) create mode 100644 samples/client/petstore/php/SwaggerClient-php/docs/Model/Capitalization.md create mode 100644 samples/client/petstore/php/SwaggerClient-php/lib/Model/Capitalization.php create mode 100644 samples/client/petstore/php/SwaggerClient-php/test/Model/CapitalizationTest.php diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Model/Capitalization.md b/samples/client/petstore/php/SwaggerClient-php/docs/Model/Capitalization.md new file mode 100644 index 00000000000..0fcc9e873d7 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Model/Capitalization.md @@ -0,0 +1,15 @@ +# Capitalization + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**small_camel** | **string** | | [optional] +**capital_camel** | **string** | | [optional] +**small_snake** | **string** | | [optional] +**capital_snake** | **string** | | [optional] +**sca_eth_flow_points** | **string** | | [optional] +**att_name** | **string** | Name of the pet | [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) + + diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Capitalization.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Capitalization.php new file mode 100644 index 00000000000..37de4a9eed2 --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Capitalization.php @@ -0,0 +1,358 @@ + 'string', + 'capital_camel' => 'string', + 'small_snake' => 'string', + 'capital_snake' => 'string', + 'sca_eth_flow_points' => 'string', + 'att_name' => 'string' + ]; + + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of attributes where the key is the local name, and the value is the original name + * @var string[] + */ + protected static $attributeMap = [ + 'small_camel' => 'smallCamel', + 'capital_camel' => 'CapitalCamel', + 'small_snake' => 'small_Snake', + 'capital_snake' => 'Capital_Snake', + 'sca_eth_flow_points' => 'SCA_ETH_Flow_Points', + 'att_name' => 'ATT_NAME' + ]; + + + /** + * Array of attributes to setter functions (for deserialization of responses) + * @var string[] + */ + protected static $setters = [ + 'small_camel' => 'setSmallCamel', + 'capital_camel' => 'setCapitalCamel', + 'small_snake' => 'setSmallSnake', + 'capital_snake' => 'setCapitalSnake', + 'sca_eth_flow_points' => 'setScaEthFlowPoints', + 'att_name' => 'setAttName' + ]; + + + /** + * Array of attributes to getter functions (for serialization of requests) + * @var string[] + */ + protected static $getters = [ + 'small_camel' => 'getSmallCamel', + 'capital_camel' => 'getCapitalCamel', + 'small_snake' => 'getSmallSnake', + 'capital_snake' => 'getCapitalSnake', + 'sca_eth_flow_points' => 'getScaEthFlowPoints', + 'att_name' => 'getAttName' + ]; + + public static function attributeMap() + { + return self::$attributeMap; + } + + public static function setters() + { + return self::$setters; + } + + public static function getters() + { + return self::$getters; + } + + + + + + /** + * Associative array for storing property values + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * @param mixed[] $data Associated array of property values initializing the model + */ + public function __construct(array $data = null) + { + $this->container['small_camel'] = isset($data['small_camel']) ? $data['small_camel'] : null; + $this->container['capital_camel'] = isset($data['capital_camel']) ? $data['capital_camel'] : null; + $this->container['small_snake'] = isset($data['small_snake']) ? $data['small_snake'] : null; + $this->container['capital_snake'] = isset($data['capital_snake']) ? $data['capital_snake'] : null; + $this->container['sca_eth_flow_points'] = isset($data['sca_eth_flow_points']) ? $data['sca_eth_flow_points'] : null; + $this->container['att_name'] = isset($data['att_name']) ? $data['att_name'] : null; + } + + /** + * show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalid_properties = []; + return $invalid_properties; + } + + /** + * validate all the properties in the model + * return true if all passed + * + * @return bool True if all properteis are valid + */ + public function valid() + { + return true; + } + + + /** + * Gets small_camel + * @return string + */ + public function getSmallCamel() + { + return $this->container['small_camel']; + } + + /** + * Sets small_camel + * @param string $small_camel + * @return $this + */ + public function setSmallCamel($small_camel) + { + $this->container['small_camel'] = $small_camel; + + return $this; + } + + /** + * Gets capital_camel + * @return string + */ + public function getCapitalCamel() + { + return $this->container['capital_camel']; + } + + /** + * Sets capital_camel + * @param string $capital_camel + * @return $this + */ + public function setCapitalCamel($capital_camel) + { + $this->container['capital_camel'] = $capital_camel; + + return $this; + } + + /** + * Gets small_snake + * @return string + */ + public function getSmallSnake() + { + return $this->container['small_snake']; + } + + /** + * Sets small_snake + * @param string $small_snake + * @return $this + */ + public function setSmallSnake($small_snake) + { + $this->container['small_snake'] = $small_snake; + + return $this; + } + + /** + * Gets capital_snake + * @return string + */ + public function getCapitalSnake() + { + return $this->container['capital_snake']; + } + + /** + * Sets capital_snake + * @param string $capital_snake + * @return $this + */ + public function setCapitalSnake($capital_snake) + { + $this->container['capital_snake'] = $capital_snake; + + return $this; + } + + /** + * Gets sca_eth_flow_points + * @return string + */ + public function getScaEthFlowPoints() + { + return $this->container['sca_eth_flow_points']; + } + + /** + * Sets sca_eth_flow_points + * @param string $sca_eth_flow_points + * @return $this + */ + public function setScaEthFlowPoints($sca_eth_flow_points) + { + $this->container['sca_eth_flow_points'] = $sca_eth_flow_points; + + return $this; + } + + /** + * Gets att_name + * @return string + */ + public function getAttName() + { + return $this->container['att_name']; + } + + /** + * Sets att_name + * @param string $att_name Name of the pet + * @return $this + */ + public function setAttName($att_name) + { + $this->container['att_name'] = $att_name; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * @param integer $offset Offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * @param integer $offset Offset + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * @param integer $offset Offset + * @param mixed $value Value to be set + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * @param integer $offset Offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); + } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/samples/client/petstore/php/SwaggerClient-php/test/Model/CapitalizationTest.php b/samples/client/petstore/php/SwaggerClient-php/test/Model/CapitalizationTest.php new file mode 100644 index 00000000000..48e309b787f --- /dev/null +++ b/samples/client/petstore/php/SwaggerClient-php/test/Model/CapitalizationTest.php @@ -0,0 +1,133 @@ +