[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
This commit is contained in:
Sem Schilder
2021-08-03 11:09:52 +02:00
committed by GitHub
parent c28c1253a4
commit 4210b41f84
13 changed files with 542 additions and 102 deletions

View File

@@ -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");

View File

@@ -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}}}
*

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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
*

View File

@@ -0,0 +1,123 @@
<?php
/**
* InlineObject
*
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the InlineObject model.
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class InlineObject
{
/**
* Updated name of the pet
*
* @var string|null
* @SerializedName("name")
* @Assert\Type("string")
* @Type("string")
*/
protected $name;
/**
* Updated status of the pet
*
* @var string|null
* @SerializedName("status")
* @Assert\Type("string")
* @Type("string")
*/
protected $status;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->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;
}
}

View File

@@ -0,0 +1,123 @@
<?php
/**
* InlineObject1
*
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Do not edit the class manually.
*/
namespace OpenAPI\Server\Model;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Type;
use JMS\Serializer\Annotation\SerializedName;
/**
* Class representing the InlineObject1 model.
*
* @package OpenAPI\Server\Model
* @author OpenAPI Generator team
*/
class InlineObject1
{
/**
* Additional data to pass to server
*
* @var string|null
* @SerializedName("additionalMetadata")
* @Assert\Type("string")
* @Type("string")
*/
protected $additionalMetadata;
/**
* file to upload
*
* @var UploadedFile|null
* @SerializedName("file")
* @Assert\Type("UploadedFile")
* @Type("UploadedFile")
*/
protected $file;
/**
* Constructor
* @param mixed[] $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->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;
}
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -0,0 +1,96 @@
<?php
/**
* InlineObject1Test
*
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\TestCase;
/**
* InlineObject1Test Class Doc Comment
*
* @category Class */
// * @description InlineObject1
/**
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class InlineObject1Test extends TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "InlineObject1"
*/
public function testInlineObject1()
{
$testInlineObject1 = new InlineObject1();
}
/**
* Test attribute "additionalMetadata"
*/
public function testPropertyAdditionalMetadata()
{
}
/**
* Test attribute "file"
*/
public function testPropertyFile()
{
}
}

View File

@@ -0,0 +1,96 @@
<?php
/**
* InlineObjectTest
*
* PHP version 7.1.3
*
* @category Class
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
/**
* OpenAPI Petstore
*
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://github.com/openapitools/openapi-generator.git
*
*/
/**
* NOTE: This class is auto generated by the openapi generator program.
* https://github.com/openapitools/openapi-generator
* Please update the test case below to test the model.
*/
namespace OpenAPI\Server\Model;
use PHPUnit\Framework\TestCase;
/**
* InlineObjectTest Class Doc Comment
*
* @category Class */
// * @description InlineObject
/**
* @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator
*/
class InlineObjectTest extends TestCase
{
/**
* Setup before running any test case
*/
public static function setUpBeforeClass()
{
}
/**
* Setup before running each test case
*/
public function setUp()
{
}
/**
* Clean up after running each test case
*/
public function tearDown()
{
}
/**
* Clean up after running all test cases
*/
public static function tearDownAfterClass()
{
}
/**
* Test "InlineObject"
*/
public function testInlineObject()
{
$testInlineObject = new InlineObject();
}
/**
* Test attribute "name"
*/
public function testPropertyName()
{
}
/**
* Test attribute "status"
*/
public function testPropertyStatus()
{
}
}