mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-01 21:20:55 +00:00
[php Symfony] fix return type for non json/xml api
This fixes the generated returned type of controller methods for endpoint with a response declared like content: text/plain: schema: type: <boolean|string|integer|number> or for content: image/png: schema: type: string format: binary Without this commit the generated method *had to* return a value that matched "array|object|null", which does not work in this case. This commit makes it possible to return the proper type.
This commit is contained in:
parent
d300ae9a41
commit
bb18191411
@ -417,7 +417,17 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
|
|||||||
op.vendorExtensions.put("x-comment-type", "void");
|
op.vendorExtensions.put("x-comment-type", "void");
|
||||||
}
|
}
|
||||||
// Create a variable to add typing for return value of interface
|
// Create a variable to add typing for return value of interface
|
||||||
if (op.returnType != null) {
|
if ("bool".equals(op.returnType)) {
|
||||||
|
op.vendorExtensions.put("x-return-type", "bool");
|
||||||
|
} else if ("UploadedFile".equals(op.returnType)) {
|
||||||
|
op.vendorExtensions.put("x-return-type", "string");
|
||||||
|
} else if ("int".equals(op.returnType)) {
|
||||||
|
op.vendorExtensions.put("x-return-type", "int");
|
||||||
|
} else if ("float".equals(op.returnType)) {
|
||||||
|
op.vendorExtensions.put("x-return-type", "float");
|
||||||
|
} else if ("string".equals(op.returnType)) {
|
||||||
|
op.vendorExtensions.put("x-return-type", "string");
|
||||||
|
} else if (op.returnType != null) {
|
||||||
op.vendorExtensions.put("x-return-type", "array|object|null");
|
op.vendorExtensions.put("x-return-type", "array|object|null");
|
||||||
} else {
|
} else {
|
||||||
op.vendorExtensions.put("x-return-type", "void");
|
op.vendorExtensions.put("x-return-type", "void");
|
||||||
|
@ -77,12 +77,12 @@ interface StoreApiInterface
|
|||||||
* @param int &$responseCode The HTTP Response Code
|
* @param int &$responseCode The HTTP Response Code
|
||||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||||
*
|
*
|
||||||
* @return array|object|null
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getInventory(
|
public function getInventory(
|
||||||
int &$responseCode,
|
int &$responseCode,
|
||||||
array &$responseHeaders
|
array &$responseHeaders
|
||||||
): array|object|null;
|
): int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation getOrderById
|
* Operation getOrderById
|
||||||
|
@ -147,14 +147,14 @@ interface UserApiInterface
|
|||||||
* @param int &$responseCode The HTTP Response Code
|
* @param int &$responseCode The HTTP Response Code
|
||||||
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
* @param array $responseHeaders Additional HTTP headers to return with the response ()
|
||||||
*
|
*
|
||||||
* @return array|object|null
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function loginUser(
|
public function loginUser(
|
||||||
string $username,
|
string $username,
|
||||||
string $password,
|
string $password,
|
||||||
int &$responseCode,
|
int &$responseCode,
|
||||||
array &$responseHeaders
|
array &$responseHeaders
|
||||||
): array|object|null;
|
): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation logoutUser
|
* Operation logoutUser
|
||||||
|
@ -107,7 +107,7 @@ class StoreApi implements StoreApiInterface
|
|||||||
/**
|
/**
|
||||||
* Implementation of StoreApiInterface#getInventory
|
* Implementation of StoreApiInterface#getInventory
|
||||||
*/
|
*/
|
||||||
public function getInventory(int &$responseCode, array &$responseHeaders): array|object|null
|
public function getInventory(int &$responseCode, array &$responseHeaders): int
|
||||||
{
|
{
|
||||||
// Implement the operation ...
|
// Implement the operation ...
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ class UserApi implements UserApiInterface
|
|||||||
/**
|
/**
|
||||||
* Implementation of UserApiInterface#loginUser
|
* Implementation of UserApiInterface#loginUser
|
||||||
*/
|
*/
|
||||||
public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): array|object|null
|
public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): string
|
||||||
{
|
{
|
||||||
// Implement the operation ...
|
// Implement the operation ...
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user