From 4210b41f842cf9ca9475685ef9803fce8e074e4a Mon Sep 17 00:00:00 2001 From: Sem Schilder Date: Tue, 3 Aug 2021 11:09:52 +0200 Subject: [PATCH] [php-symfony] Add backslash to "load" namespaces from global namespace (#9740) * Add backslash to load namespace from global namespace * Update example * Remove hardcoded slash * Add backslash from java side * Update samples * Fix first sample * Fix other snapshot * Update version file --- .../languages/PhpSymfonyServerCodegen.java | 8 +- .../main/resources/php-symfony/api.mustache | 4 +- .../org/openapitools/client/ApiClient.java | 10 -- .../org/openapitools/client/ApiClient.java | 10 -- .../SymfonyBundle-php/Api/PetApiInterface.php | 70 +++++----- .../Api/StoreApiInterface.php | 28 ++-- .../Api/UserApiInterface.php | 54 ++++---- .../SymfonyBundle-php/Model/InlineObject.php | 123 ++++++++++++++++++ .../SymfonyBundle-php/Model/InlineObject1.php | 123 ++++++++++++++++++ .../Resources/docs/Model/InlineObject.md | 11 ++ .../Resources/docs/Model/InlineObject1.md | 11 ++ .../Tests/Model/InlineObject1Test.php | 96 ++++++++++++++ .../Tests/Model/InlineObjectTest.php | 96 ++++++++++++++ 13 files changed, 542 insertions(+), 102 deletions(-) create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Model/InlineObject.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Model/InlineObject1.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/InlineObject.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/InlineObject1.md create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/InlineObject1Test.php create mode 100644 samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/InlineObjectTest.php diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java index f3324629b452..74490df34222 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java @@ -412,17 +412,17 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg } // Create a variable to display the correct data type in comments for interfaces - param.vendorExtensions.put("x-comment-type", param.dataType); + param.vendorExtensions.put("x-comment-type", "\\" + param.dataType); if (param.isContainer) { - param.vendorExtensions.put("x-comment-type", param.dataType + "[]"); + param.vendorExtensions.put("x-comment-type", "\\" + param.dataType + "[]"); } } // Create a variable to display the correct return type in comments for interfaces if (op.returnType != null) { - op.vendorExtensions.put("x-comment-type", op.returnType); + op.vendorExtensions.put("x-comment-type", "\\" + op.returnType); if ("array".equals(op.returnContainer)) { - op.vendorExtensions.put("x-comment-type", op.returnType + "[]"); + op.vendorExtensions.put("x-comment-type", "\\" + op.returnType + "[]"); } } else { op.vendorExtensions.put("x-comment-type", "void"); diff --git a/modules/openapi-generator/src/main/resources/php-symfony/api.mustache b/modules/openapi-generator/src/main/resources/php-symfony/api.mustache index 81f343bb38e9..00c32b468045 100644 --- a/modules/openapi-generator/src/main/resources/php-symfony/api.mustache +++ b/modules/openapi-generator/src/main/resources/php-symfony/api.mustache @@ -59,8 +59,8 @@ interface {{classname}} {{#allParams}} * @param {{vendorExtensions.x-comment-type}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return {{{vendorExtensions.x-comment-type}}} * diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiClient.java index 8dd14bf1a27d..970b3337373d 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiClient.java @@ -123,16 +123,6 @@ public class ApiClient { return objectMapper; } - private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) { - switch (flow) { - case password: - return new OauthPasswordGrant(tokenUrl, scopes); - case application: - return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes); - default: - throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented"); - } - } public ObjectMapper getObjectMapper(){ return objectMapper; diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java index 6dcf3fd17902..0ed3ad8901c0 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java @@ -130,16 +130,6 @@ public class ApiClient { return objectMapper; } - private RequestInterceptor buildOauthRequestInterceptor(OAuthFlow flow, String authorizationUrl, String tokenUrl, String scopes) { - switch (flow) { - case password: - return new OauthPasswordGrant(tokenUrl, scopes); - case application: - return new OauthClientCredentialsGrant(authorizationUrl, tokenUrl, scopes); - default: - throw new RuntimeException("Oauth flow \"" + flow + "\" is not implemented"); - } - } public ObjectMapper getObjectMapper(){ return objectMapper; diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/PetApiInterface.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/PetApiInterface.php index 4958426e7c8f..516447dd1432 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/PetApiInterface.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/PetApiInterface.php @@ -75,11 +75,11 @@ interface PetApiInterface * * Add a new pet to the store * - * @param OpenAPI\Server\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \OpenAPI\Server\Model\Pet $pet Pet object that needs to be added to the store (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\Pet + * @return \OpenAPI\Server\Model\Pet * */ public function addPet(Pet $pet, &$responseCode, array &$responseHeaders); @@ -89,10 +89,10 @@ interface PetApiInterface * * Deletes a pet * - * @param int $petId Pet id to delete (required) - * @param string $apiKey (optional) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \int $petId Pet id to delete (required) + * @param \string $apiKey (optional) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * @@ -104,11 +104,11 @@ interface PetApiInterface * * Finds Pets by status * - * @param string[] $status Status values that need to be considered for filter (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \string[] $status Status values that need to be considered for filter (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\Pet[] + * @return \OpenAPI\Server\Model\Pet[] * */ public function findPetsByStatus(array $status, &$responseCode, array &$responseHeaders); @@ -118,11 +118,11 @@ interface PetApiInterface * * Finds Pets by tags * - * @param string[] $tags Tags to filter by (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \string[] $tags Tags to filter by (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\Pet[] + * @return \OpenAPI\Server\Model\Pet[] * */ public function findPetsByTags(array $tags, &$responseCode, array &$responseHeaders); @@ -132,11 +132,11 @@ interface PetApiInterface * * Find pet by ID * - * @param int $petId ID of pet to return (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \int $petId ID of pet to return (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\Pet + * @return \OpenAPI\Server\Model\Pet * */ public function getPetById($petId, &$responseCode, array &$responseHeaders); @@ -146,11 +146,11 @@ interface PetApiInterface * * Update an existing pet * - * @param OpenAPI\Server\Model\Pet $pet Pet object that needs to be added to the store (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \OpenAPI\Server\Model\Pet $pet Pet object that needs to be added to the store (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\Pet + * @return \OpenAPI\Server\Model\Pet * */ public function updatePet(Pet $pet, &$responseCode, array &$responseHeaders); @@ -160,11 +160,11 @@ interface PetApiInterface * * Updates a pet in the store with form data * - * @param int $petId ID of pet that needs to be updated (required) - * @param string $name Updated name of the pet (optional) - * @param string $status Updated status of the pet (optional) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \int $petId ID of pet that needs to be updated (required) + * @param \string $name Updated name of the pet (optional) + * @param \string $status Updated status of the pet (optional) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * @@ -176,13 +176,13 @@ interface PetApiInterface * * uploads an image * - * @param int $petId ID of pet to update (required) - * @param string $additionalMetadata Additional data to pass to server (optional) - * @param UploadedFile $file file to upload (optional) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \int $petId ID of pet to update (required) + * @param \string $additionalMetadata Additional data to pass to server (optional) + * @param \UploadedFile $file file to upload (optional) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\ApiResponse + * @return \OpenAPI\Server\Model\ApiResponse * */ public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null, &$responseCode, array &$responseHeaders); diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php index cf9093ecf13c..cebfa0aecf56 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php @@ -56,9 +56,9 @@ interface StoreApiInterface * * Delete purchase order by ID * - * @param string $orderId ID of the order that needs to be deleted (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \string $orderId ID of the order that needs to be deleted (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * @@ -70,10 +70,10 @@ interface StoreApiInterface * * Returns pet inventories by status * - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return int + * @return \int * */ public function getInventory(&$responseCode, array &$responseHeaders); @@ -83,11 +83,11 @@ interface StoreApiInterface * * Find purchase order by ID * - * @param int $orderId ID of pet that needs to be fetched (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \int $orderId ID of pet that needs to be fetched (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\Order + * @return \OpenAPI\Server\Model\Order * */ public function getOrderById($orderId, &$responseCode, array &$responseHeaders); @@ -97,11 +97,11 @@ interface StoreApiInterface * * Place an order for a pet * - * @param OpenAPI\Server\Model\Order $order order placed for purchasing the pet (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \OpenAPI\Server\Model\Order $order order placed for purchasing the pet (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\Order + * @return \OpenAPI\Server\Model\Order * */ public function placeOrder(Order $order, &$responseCode, array &$responseHeaders); diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php index 71a5cfac6699..961b6570e8f0 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php @@ -56,9 +56,9 @@ interface UserApiInterface * * Create user * - * @param OpenAPI\Server\Model\User $user Created user object (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \OpenAPI\Server\Model\User $user Created user object (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * @@ -70,9 +70,9 @@ interface UserApiInterface * * Creates list of users with given input array * - * @param OpenAPI\Server\Model\User[] $user List of user object (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \OpenAPI\Server\Model\User[] $user List of user object (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * @@ -84,9 +84,9 @@ interface UserApiInterface * * Creates list of users with given input array * - * @param OpenAPI\Server\Model\User[] $user List of user object (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \OpenAPI\Server\Model\User[] $user List of user object (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * @@ -98,9 +98,9 @@ interface UserApiInterface * * Delete user * - * @param string $username The name that needs to be deleted (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \string $username The name that needs to be deleted (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * @@ -112,11 +112,11 @@ interface UserApiInterface * * Get user by user name * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return OpenAPI\Server\Model\User + * @return \OpenAPI\Server\Model\User * */ public function getUserByName($username, &$responseCode, array &$responseHeaders); @@ -126,12 +126,12 @@ interface UserApiInterface * * Logs user into the system * - * @param string $username The user name for login (required) - * @param string $password The password for login in clear text (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \string $username The user name for login (required) + * @param \string $password The password for login in clear text (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * - * @return string + * @return \string * */ public function loginUser($username, $password, &$responseCode, array &$responseHeaders); @@ -141,8 +141,8 @@ interface UserApiInterface * * Logs out current logged in user session * - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * @@ -154,10 +154,10 @@ interface UserApiInterface * * Updated user * - * @param string $username name that need to be deleted (required) - * @param OpenAPI\Server\Model\User $user Updated user object (required) - * @param integer $responseCode The HTTP response code to return - * @param array $responseHeaders Additional HTTP headers to return with the response () + * @param \string $username name that need to be deleted (required) + * @param \OpenAPI\Server\Model\User $user Updated user object (required) + * @param \int $responseCode The HTTP response code to return + * @param \array $responseHeaders Additional HTTP headers to return with the response () * * @return void * diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/InlineObject.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/InlineObject.php new file mode 100644 index 000000000000..5ee480353c79 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/InlineObject.php @@ -0,0 +1,123 @@ +name = isset($data['name']) ? $data['name'] : null; + $this->status = isset($data['status']) ? $data['status'] : null; + } + + /** + * Gets name. + * + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * Sets name. + * + * @param string|null $name Updated name of the pet + * + * @return $this + */ + public function setName($name = null) + { + $this->name = $name; + + return $this; + } + + /** + * Gets status. + * + * @return string|null + */ + public function getStatus() + { + return $this->status; + } + + /** + * Sets status. + * + * @param string|null $status Updated status of the pet + * + * @return $this + */ + public function setStatus($status = null) + { + $this->status = $status; + + return $this; + } +} + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/InlineObject1.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/InlineObject1.php new file mode 100644 index 000000000000..e27ed1bf0827 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Model/InlineObject1.php @@ -0,0 +1,123 @@ +additionalMetadata = isset($data['additionalMetadata']) ? $data['additionalMetadata'] : null; + $this->file = isset($data['file']) ? $data['file'] : null; + } + + /** + * Gets additionalMetadata. + * + * @return string|null + */ + public function getAdditionalMetadata() + { + return $this->additionalMetadata; + } + + /** + * Sets additionalMetadata. + * + * @param string|null $additionalMetadata Additional data to pass to server + * + * @return $this + */ + public function setAdditionalMetadata($additionalMetadata = null) + { + $this->additionalMetadata = $additionalMetadata; + + return $this; + } + + /** + * Gets file. + * + * @return UploadedFile|null + */ + public function getFile(): ?UploadedFile + { + return $this->file; + } + + /** + * Sets file. + * + * @param UploadedFile|null $file file to upload + * + * @return $this + */ + public function setFile(UploadedFile $file = null) + { + $this->file = $file; + + return $this; + } +} + + diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/InlineObject.md b/samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/InlineObject.md new file mode 100644 index 000000000000..101275879be3 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/InlineObject.md @@ -0,0 +1,11 @@ +# InlineObject + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | Updated name of the pet | [optional] +**status** | **string** | Updated status 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/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/InlineObject1.md b/samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/InlineObject1.md new file mode 100644 index 000000000000..a69b83edc6a1 --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Resources/docs/Model/InlineObject1.md @@ -0,0 +1,11 @@ +# InlineObject1 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additionalMetadata** | **string** | Additional data to pass to server | [optional] +**file** | [**UploadedFile**](UploadedFile.md) | file to upload | [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/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/InlineObject1Test.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/InlineObject1Test.php new file mode 100644 index 000000000000..9d9ee881a0da --- /dev/null +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Tests/Model/InlineObject1Test.php @@ -0,0 +1,96 @@ +