[PHP] Enhance Symfony generator (#12532)

* Enhance Symfony generator

  - Add missing typehints
  - Add missing use statements
  - Simplify model ctor
  - Change fallthrough Exception to Throwable
  - prevent storing result of void methods
  - fix validate method
  - add default null values to model properties
  - simplify API interface return values
  - fix/rework default value implementation
  - fix optional params deprecation warnings
  - ..

For more details check out the PR: https://github.com/OpenAPITools/openapi-generator/pull/12532

* Enhance Symfony generator Tests

  - Skip risky tests
  - Fix type hint error
  - Fix class exists tests
  - Fix broken doc block
  - Enhance annotations
  - Update phpunit.xml.dist
  - Fix test config resource location
This commit is contained in:
Daniel Metzner
2022-06-25 14:53:21 +02:00
committed by GitHub
parent 286a31c019
commit 3b15bb8a4e
56 changed files with 862 additions and 558 deletions

View File

@@ -373,23 +373,15 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
// Type-hintable primitive types // Type-hintable primitive types
// ref: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration // ref: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
if (phpLegacySupport) { typeHintable = new HashSet<>(
typeHintable = new HashSet<>( Arrays.asList(
Arrays.asList( "array",
"array" "bool",
) "float",
); "int",
} else { "string"
typeHintable = new HashSet<>( )
Arrays.asList( );
"array",
"bool",
"float",
"int",
"string"
)
);
}
} }
@Override @Override
@@ -419,32 +411,24 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
} }
// Create a variable to display the correct data type in comments for interfaces // 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", prependSlashToDataTypeOnlyIfNecessary(param.dataType));
if (param.isContainer) { if (param.isContainer) {
param.vendorExtensions.put("x-comment-type", "\\" + param.dataType + "[]"); param.vendorExtensions.put("x-comment-type", prependSlashToDataTypeOnlyIfNecessary(param.dataType) + "[]");
} }
} }
// Create a variable to display the correct return type in comments for interfaces // Create a variable to display the correct return type in comments for interfaces
if (op.returnType != null) { if (op.returnType != null) {
op.vendorExtensions.put("x-comment-type", "\\" + op.returnType); op.vendorExtensions.put("x-comment-type", prependSlashToDataTypeOnlyIfNecessary(op.returnType));
if ("array".equals(op.returnContainer)) { if ("array".equals(op.returnContainer)) {
op.vendorExtensions.put("x-comment-type", "\\" + op.returnType + "[]"); op.vendorExtensions.put("x-comment-type", prependSlashToDataTypeOnlyIfNecessary(op.returnType) + "[]");
} }
} else { } else {
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 (op.returnType != null) {
if ("array".equals(op.returnContainer)) { op.vendorExtensions.put("x-return-type", "array|object|null");
op.vendorExtensions.put("x-return-type", "iterable");
} else {
if (defaultIncludes.contains(op.returnType)) {
op.vendorExtensions.put("x-return-type", "array|" + op.returnType);
} else {
op.vendorExtensions.put("x-return-type", "array|\\" + op.returnType);
}
}
} else { } else {
op.vendorExtensions.put("x-return-type", "void"); op.vendorExtensions.put("x-return-type", "void");
} }
@@ -476,19 +460,11 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
if (var.dataType != null) { if (var.dataType != null) {
// Determine if the parameter type is supported as a type hint and make it available // Determine if the parameter type is supported as a type hint and make it available
// to the templating engine // to the templating engine
String typeHint = getTypeHint(var.dataType); var.vendorExtensions.put("x-parameter-type", getTypeHintNullable(var.dataType));
if (!typeHint.isEmpty()) { var.vendorExtensions.put("x-comment-type", getTypeHintNullableForComments(var.dataType));
var.vendorExtensions.put("x-parameter-type", typeHint);
}
if (var.isContainer) { if (var.isContainer) {
var.vendorExtensions.put("x-parameter-type", getTypeHint(var.dataType + "[]")); var.vendorExtensions.put("x-parameter-type", getTypeHintNullable(var.dataType + "[]"));
} var.vendorExtensions.put("x-comment-type", getTypeHintNullableForComments(var.dataType + "[]"));
// Create a variable to display the correct data type in comments for models
var.vendorExtensions.put("x-comment-type", var.dataType);
if (var.isContainer) {
var.vendorExtensions.put("x-comment-type", var.dataType + "[]");
} }
} }
} }
@@ -496,6 +472,14 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
return objs; return objs;
} }
public String prependSlashToDataTypeOnlyIfNecessary(String dataType) {
if (dataType.equals("array") || dataType.equals("bool") || dataType.equals("float") || dataType.equals("int") || dataType.equals("string") || dataType.equals("object") || dataType.equals("iterable") || dataType.equals("mixed")) {
return dataType;
}
return "\\" + dataType;
}
/** /**
* Output the Getter name for boolean property, e.g. isActive * Output the Getter name for boolean property, e.g. isActive
* *
@@ -645,6 +629,24 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
return prefix + name; return prefix + name;
} }
protected String getTypeHintNullable(String type) {
String typeHint = getTypeHint(type);
if (!typeHint.equals("")) {
return "?" + typeHint;
}
return typeHint;
}
protected String getTypeHintNullableForComments(String type) {
String typeHint = getTypeHint(type);
if (!typeHint.equals("")) {
return typeHint + "|null";
}
return typeHint;
}
protected String getTypeHint(String type) { protected String getTypeHint(String type) {
// Type hint array types // Type hint array types
if (type.endsWith("[]")) { if (type.endsWith("[]")) {

View File

@@ -19,6 +19,8 @@
namespace {{apiPackage}}; namespace {{apiPackage}};
use Symfony\Component\DependencyInjection\Reference;
/** /**
* ApiServer Class Doc Comment * ApiServer Class Doc Comment
* *
@@ -35,7 +37,7 @@ class ApiServer
/** /**
* @var array * @var array
*/ */
private $apis = array(); private array $apis = array();
/** /**
* Adds an API handler to the server. * Adds an API handler to the server.
@@ -43,7 +45,7 @@ class ApiServer
* @param string $api An API name of the handle * @param string $api An API name of the handle
* @param mixed $handler A handler to set for the given API * @param mixed $handler A handler to set for the given API
*/ */
public function addApiHandler($api, $handler) public function addApiHandler(string $api, $handler): void
{ {
if (isset($this->apis[$api])) { if (isset($this->apis[$api])) {
throw new \InvalidArgumentException('API has already a handler: '.$api); throw new \InvalidArgumentException('API has already a handler: '.$api);
@@ -59,7 +61,7 @@ class ApiServer
* @return mixed Returns a handler * @return mixed Returns a handler
* @throws \InvalidArgumentException When no such handler exists * @throws \InvalidArgumentException When no such handler exists
*/ */
public function getApiHandler($api) public function getApiHandler(string $api)
{ {
if (!isset($this->apis[$api])) { if (!isset($this->apis[$api])) {
throw new \InvalidArgumentException('No handler for '.$api.' implemented.'); throw new \InvalidArgumentException('No handler for '.$api.' implemented.');

View File

@@ -19,10 +19,12 @@
namespace {{controllerPackage}}; namespace {{controllerPackage}};
use {{apiPackage}}\ApiServer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Validator\ConstraintViolation;
use {{servicePackage}}\SerializerInterface; use {{servicePackage}}\SerializerInterface;
use {{servicePackage}}\ValidatorInterface; use {{servicePackage}}\ValidatorInterface;
@@ -36,23 +38,29 @@ use {{servicePackage}}\ValidatorInterface;
*/ */
class Controller extends AbstractController class Controller extends AbstractController
{ {
protected $validator; protected ValidatorInterface $validator;
protected $serializer; protected SerializerInterface $serializer;
protected $apiServer; protected ApiServer $apiServer;
public function setValidator(ValidatorInterface $validator) public function setValidator(ValidatorInterface $validator): self
{ {
$this->validator = $validator; $this->validator = $validator;
return $this;
} }
public function setSerializer(SerializerInterface $serializer) public function setSerializer(SerializerInterface $serializer): self
{ {
$this->serializer = $serializer; $this->serializer = $serializer;
return $this;
} }
public function setApiServer($server) public function setApiServer(ApiServer $server): self
{ {
$this->apiServer = $server; $this->apiServer = $server;
return $this;
} }
/** /**
@@ -63,7 +71,7 @@ class Controller extends AbstractController
* *
* @return Response * @return Response
*/ */
public function createBadRequestResponse($message = 'Bad Request.') public function createBadRequestResponse(string $message = 'Bad Request.'): Response
{ {
return new Response($message, 400); return new Response($message, 400);
} }
@@ -76,7 +84,7 @@ class Controller extends AbstractController
* *
* @return Response * @return Response
*/ */
public function createErrorResponse(HttpException $exception) public function createErrorResponse(HttpException $exception): Response
{ {
$statusCode = $exception->getStatusCode(); $statusCode = $exception->getStatusCode();
$headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']); $headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']);
@@ -91,12 +99,11 @@ class Controller extends AbstractController
* Serializes data to a given type format. * Serializes data to a given type format.
* *
* @param mixed $data The data to serialize. * @param mixed $data The data to serialize.
* @param string $class The source data class.
* @param string $format The target serialization format. * @param string $format The target serialization format.
* *
* @return string A serialized data string. * @return string A serialized data string.
*/ */
protected function serialize($data, $format) protected function serialize($data, string $format): string
{ {
return $this->serializer->serialize($data, $format); return $this->serializer->serialize($data, $format);
} }
@@ -104,35 +111,47 @@ class Controller extends AbstractController
/** /**
* Deserializes data from a given type format. * Deserializes data from a given type format.
* *
* @param string $data The data to deserialize. * @param mixed $data The data to deserialize.
* @param string $class The target data class. * @param string $class The target data class.
* @param string $format The source serialization format. * @param string $format The source serialization format.
* *
* @return mixed A deserialized data. * @return mixed A deserialized data.
*/ */
protected function deserialize($data, $class, $format) protected function deserialize($data, string $class, string $format)
{ {
return $this->serializer->deserialize($data, $class, $format); return $this->serializer->deserialize($data, $class, $format);
} }
protected function validate($data, $asserts = null) /**
* @param mixed $data
* @param mixed $asserts
*
* @return Response|null
*/
protected function validate($data, $asserts = null): ?Response
{ {
$errors = $this->validator->validate($data, $asserts); $errors = $this->validator->validate($data, $asserts);
if (count($errors) > 0) { if (count($errors) > 0) {
$errorsString = (string)$errors; $errorsString = '';
/** @var ConstraintViolation $violation */
foreach ($errors as $violation) {
$errorsString .= $violation->getMessage()."\n";
}
return $this->createBadRequestResponse($errorsString); return $this->createBadRequestResponse($errorsString);
} }
return null;
} }
/** /**
* Converts an exception to a serializable array. * Converts an exception to a serializable array.
* *
* @param \Exception|null $exception * @param \Throwable|null $exception
* *
* @return array * @return array|null
*/ */
private function exceptionToArray(\Exception $exception = null) private function exceptionToArray(\Throwable $exception = null): ?array
{ {
if (null === $exception) { if (null === $exception) {
return null; return null;
@@ -151,7 +170,15 @@ class Controller extends AbstractController
]; ];
} }
protected function getOutputFormat($accept, array $produced) /**
* Converts an exception to a serializable array.
*
* @param string $accept
* @param array $produced
*
* @return ?string
*/
protected function getOutputFormat(string $accept, array $produced): ?string
{ {
// Figure out what the client accepts // Figure out what the client accepts
$accept = preg_split("/[\s,]+/", $accept); $accept = preg_split("/[\s,]+/", $accept);
@@ -186,7 +213,7 @@ class Controller extends AbstractController
* *
* @return bool Returns true if Content-Type supported otherwise false. * @return bool Returns true if Content-Type supported otherwise false.
*/ */
public static function isContentTypeAllowed(Request $request, array $consumes = []) public static function isContentTypeAllowed(Request $request, array $consumes = []): bool
{ {
if (!empty($consumes) && $consumes[0] !== '*/*') { if (!empty($consumes) && $consumes[0] !== '*/*') {
$currentFormat = $request->getContentType(); $currentFormat = $request->getContentType();

View File

@@ -34,7 +34,7 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
*/ */
class {{bundleExtensionName}} extends Extension class {{bundleExtensionName}} extends Extension
{ {
public function load(array $configs, ContainerBuilder $container) public function load(array $configs, ContainerBuilder $container): void
{ {
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml'); $loader->load('services.yml');

View File

@@ -106,7 +106,7 @@ class {{baseName}}Api implements {{classname}} // An interface is autogenerated
/** /**
* Implementation of {{classname}}#{{operationId}} * Implementation of {{classname}}#{{operationId}}
*/ */
public function {{operationId}}({{#allParams}}{{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}, &$responseCode, array &$responseHeaders): {{#isArray}}iterable{{/isArray}}{{^isArray}}array|{{{vendorExtensions.x-comment-type}}}{{/isArray}} public function {{operationId}}({{#allParams}}{{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}, int &$responseCode, array &$responseHeaders): {{{vendorExtensions.x-return-type}}}
{ {
// Implement the operation ... // Implement the operation ...
} }

View File

@@ -38,11 +38,11 @@ interface {{classname}}
/** /**
* Sets authentication method {{name}} * Sets authentication method {{name}}
* *
* @param string $value Value of the {{name}} authentication method. * @param string|null $value Value of the {{name}} authentication method.
* *
* @return void * @return void
*/ */
public function set{{name}}($value); public function set{{name}}(?string $value): void;
{{/authMethods}} {{/authMethods}}
{{#operation}} {{#operation}}
@@ -58,16 +58,17 @@ interface {{classname}}
* *
{{/description}} {{/description}}
{{#allParams}} {{#allParams}}
* @param {{vendorExtensions.x-comment-type}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}} * @param {{vendorExtensions.x-parameter-type}}{{^required}}{{^defaultValue}}|null{{/defaultValue}}{{/required}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
{{/allParams}} {{/allParams}}
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return {{{vendorExtensions.x-comment-type}}} * @return {{{vendorExtensions.x-return-type}}}
{{#isDeprecated}} {{#isDeprecated}}
* @deprecated * @deprecated
{{/isDeprecated}} {{/isDeprecated}}
*/ */
public function {{operationId}}({{#allParams}}{{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{paramName}}{{^required}} = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}&$responseCode, array &$responseHeaders): {{{vendorExtensions.x-return-type}}}; public function {{operationId}}({{#allParams}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{paramName}}, {{/allParams}}int &$responseCode, array &$responseHeaders): {{{vendorExtensions.x-return-type}}};
{{/operation}} {{/operation}}
} }

View File

@@ -109,17 +109,17 @@ class {{controllerName}} extends Controller
// Read out all input parameter values into variables // Read out all input parameter values into variables
{{#queryParams}} {{#queryParams}}
${{paramName}} = $request->query->get('{{paramName}}'); ${{paramName}} = $request->query->get('{{paramName}}'{{#defaultValue}}, {{{.}}}{{/defaultValue}});
{{/queryParams}} {{/queryParams}}
{{#headerParams}} {{#headerParams}}
${{paramName}} = $request->headers->get('{{baseName}}'); ${{paramName}} = $request->headers->get('{{baseName}}'{{#defaultValue}}, {{{.}}}{{/defaultValue}});
{{/headerParams}} {{/headerParams}}
{{#formParams}} {{#formParams}}
{{#isFile}} {{#isFile}}
${{paramName}} = $request->files->get('{{paramName}}'); ${{paramName}} = $request->files->get('{{paramName}}'{{#defaultValue}}, {{{.}}}{{/defaultValue}});
{{/isFile}} {{/isFile}}
{{^isFile}} {{^isFile}}
${{paramName}} = $request->request->get('{{paramName}}'); ${{paramName}} = $request->request->get('{{paramName}}'{{#defaultValue}}, {{{.}}}{{/defaultValue}});
{{/isFile}} {{/isFile}}
{{/formParams}} {{/formParams}}
{{#bodyParams}} {{#bodyParams}}
@@ -175,7 +175,8 @@ class {{controllerName}} extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = {{#returnType}}200{{/returnType}}{{^returnType}}204{{/returnType}}; $responseCode = {{#returnType}}200{{/returnType}}{{^returnType}}204{{/returnType}};
$responseHeaders = []; $responseHeaders = [];
$result = $handler->{{operationId}}({{#allParams}}${{paramName}}, {{/allParams}}$responseCode, $responseHeaders);
{{#returnType}}$result = {{/returnType}}$handler->{{operationId}}({{#allParams}}${{paramName}}, {{/allParams}}$responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = '{{#responses}}{{#isDefault}}{{message}}{{/isDefault}}{{/responses}}'; $message = '{{#responses}}{{#isDefault}}{{message}}{{/isDefault}}{{/responses}}';
@@ -202,7 +203,7 @@ class {{controllerName}} extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }

View File

@@ -61,7 +61,7 @@ class {{baseName}}Api implements {{classname}}
/** /**
* Implementation of {{classname}}#{{operationId}} * Implementation of {{classname}}#{{operationId}}
*/ */
public function {{operationId}}({{#allParams}}{{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}, &$responseCode, array &$responseHeaders): {{{vendorExtensions.x-return-type}}} public function {{operationId}}({{#allParams}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{paramName}}, {{/allParams}}int &$responseCode, array &$responseHeaders): {{{vendorExtensions.x-return-type}}}
{ {
// Implement the operation ... // Implement the operation ...
} }

View File

@@ -4,7 +4,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
{{/vars}} {{/vars}}
/** /**
* Constructor * Constructor
* @param mixed[] $data Associated array of property values initializing the model * @param array|null $data Associated array of property values initializing the model
*/ */
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
@@ -13,7 +13,7 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
{{/parentSchema}} {{/parentSchema}}
{{#vars}} {{#vars}}
$this->{{name}} = isset($data['{{name}}']) ? $data['{{name}}'] : {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}; $this->{{name}} = $data['{{name}}'] ?? null;
{{/vars}} {{/vars}}
} }
{{#vars}} {{#vars}}
@@ -21,9 +21,9 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
/** /**
* Gets {{name}}. * Gets {{name}}.
* *
* @return {{{vendorExtensions.x-comment-type}}}{{^required}}|null{{/required}} * @return {{{vendorExtensions.x-comment-type}}}
*/ */
public function {{getter}}(){{#vendorExtensions.x-parameter-type}}: {{^required}}?{{/required}}{{vendorExtensions.x-parameter-type}}{{/vendorExtensions.x-parameter-type}} public function {{getter}}(){{#vendorExtensions.x-parameter-type}}: {{vendorExtensions.x-parameter-type}}{{/vendorExtensions.x-parameter-type}}
{ {
return $this->{{name}}; return $this->{{name}};
} }
@@ -31,11 +31,11 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}
/** /**
* Sets {{name}}. * Sets {{name}}.
* *
* @param {{{vendorExtensions.x-comment-type}}}{{^required}}|null{{/required}} ${{name}}{{#description}} {{{.}}}{{/description}} * @param {{{vendorExtensions.x-comment-type}}} ${{name}}{{#description}} {{{.}}}{{/description}}
* *
* @return $this * @return $this
*/ */
public function {{setter}}({{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{name}}{{^required}} = null{{/required}}) public function {{setter}}({{#vendorExtensions.x-parameter-type}}{{vendorExtensions.x-parameter-type}} {{/vendorExtensions.x-parameter-type}}${{name}}{{^required}} = null{{/required}}): self
{ {
$this->{{name}} = ${{name}}; $this->{{name}} = ${{name}};

View File

@@ -3,7 +3,7 @@
* {{.}} * {{.}}
* *
{{/description}} {{/description}}
* @var {{{vendorExtensions.x-comment-type}}}{{^required}}|null{{/required}} * @var {{{vendorExtensions.x-comment-type}}}
* @SerializedName("{{baseName}}") * @SerializedName("{{baseName}}")
{{#required}} {{#required}}
* @Assert\NotNull() * @Assert\NotNull()
@@ -98,4 +98,4 @@
{{/minItems}} {{/minItems}}
{{/hasValidation}} {{/hasValidation}}
*/ */
protected ${{name}}; protected {{{vendorExtensions.x-parameter-type}}} ${{name}} = null;

View File

@@ -5,13 +5,14 @@ namespace {{servicePackage}};
use JMS\Serializer\SerializerBuilder; use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Naming\CamelCaseNamingStrategy; use JMS\Serializer\Naming\CamelCaseNamingStrategy;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy; use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
use JMS\Serializer\Serializer;
use JMS\Serializer\Visitor\Factory\XmlDeserializationVisitorFactory; use JMS\Serializer\Visitor\Factory\XmlDeserializationVisitorFactory;
use DateTime; use DateTime;
use RuntimeException; use RuntimeException;
class JmsSerializer implements SerializerInterface class JmsSerializer implements SerializerInterface
{ {
protected $serializer; protected Serializer $serializer;
public function __construct() public function __construct()
{ {
@@ -23,12 +24,18 @@ class JmsSerializer implements SerializerInterface
->build(); ->build();
} }
public function serialize($data, $format) /**
* @inheritdoc
*/
public function serialize($data, string $format): string
{ {
return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format)); return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format));
} }
public function deserialize($data, $type, $format) /**
* @inheritdoc
*/
public function deserialize($data, string $type, string $format)
{ {
if ($format == 'string') { if ($format == 'string') {
return $this->deserializeString($data, $type); return $this->deserializeString($data, $type);
@@ -38,7 +45,7 @@ class JmsSerializer implements SerializerInterface
return $this->serializer->deserialize($data, $type, $this->convertFormat($format)); return $this->serializer->deserialize($data, $type, $this->convertFormat($format));
} }
private function convertFormat($format) private function convertFormat(string $format): ?string
{ {
switch ($format) { switch ($format) {
case 'application/json': case 'application/json':
@@ -50,7 +57,7 @@ class JmsSerializer implements SerializerInterface
return null; return null;
} }
private function deserializeString($data, $type) private function deserializeString($data, string $type)
{ {
// Figure out if we have an array format // Figure out if we have an array format
if (1 === preg_match('/array<(csv|ssv|tsv|pipes),(int|string)>/i', $type, $matches)) { if (1 === preg_match('/array<(csv|ssv|tsv|pipes),(int|string)>/i', $type, $matches)) {
@@ -73,6 +80,10 @@ class JmsSerializer implements SerializerInterface
break; break;
case 'boolean': case 'boolean':
case 'bool': case 'bool':
if (is_bool($data)) {
return $data;
}
if (strtolower($data) === 'true') { if (strtolower($data) === 'true') {
return true; return true;
} }
@@ -93,10 +104,9 @@ class JmsSerializer implements SerializerInterface
return $data; return $data;
} }
private function deserializeArrayString($format, $type, $data) private function deserializeArrayString(string $format, string $type, $data): array
{ {
if($data === null) if (empty($data)) {
{
return []; return [];
} }

View File

@@ -12,16 +12,16 @@ interface SerializerInterface
* *
* @return string * @return string
*/ */
public function serialize($data, $format); public function serialize($data, string $format): string;
/** /**
* Deserializes the given data to the specified type. * Deserializes the given data to the specified type.
* *
* @param string $data * @param mixed $data
* @param string $type * @param string $type
* @param string $format * @param string $format
* *
* @return object|array|scalar * @return object|array|scalar
*/ */
public function deserialize($data, $type, $format); public function deserialize($data, string $type, string $format);
} }

View File

@@ -8,15 +8,20 @@ use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel class AppKernel extends Kernel
{ {
/**
* @inheritDoc
*/
public function registerBundles(): iterable public function registerBundles(): iterable
{ {
$bundles = array( return [
new FrameworkBundle() new FrameworkBundle(),
); ];
return $bundles;
} }
/**
* @inheritDoc
* @throws \Exception
*/
public function registerContainerConfiguration(LoaderInterface $loader) public function registerContainerConfiguration(LoaderInterface $loader)
{ {
$loader->load(__DIR__.'/test_config.yml'); $loader->load(__DIR__.'/test_config.yml');

View File

@@ -33,21 +33,16 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class ControllerTest extends TestCase class ControllerTest extends TestCase
{ {
/** /**
* Tests isContentTypeAllowed static method. * Tests isContentTypeAllowed static method.
* *
* @param string $contentType
* @param array $consumes
* @param bool $expectedReturn
*
* @covers ::isContentTypeAllowed * @covers ::isContentTypeAllowed
* @dataProvider provideArgumentsForIsContentTypeAllowed * @dataProvider dataProviderIsContentTypeAllowed
*/ */
public function testIsContentTypeAllowed($contentType, array $consumes, $expectedReturn) public function testIsContentTypeAllowed(?string $contentType, array $consumes, bool $expectedReturn): void
{ {
$request = new Request(); $request = new Request();
$request->headers->set('CONTENT_TYPE', $contentType, true);// last one argument overrides header $request->headers->set('CONTENT_TYPE', $contentType);// last one argument overrides header
$this->assertSame( $this->assertSame(
$expectedReturn, $expectedReturn,
Controller::isContentTypeAllowed($request, $consumes), Controller::isContentTypeAllowed($request, $consumes),
@@ -60,7 +55,7 @@ class ControllerTest extends TestCase
); );
} }
public function provideArgumentsForIsContentTypeAllowed() public function dataProviderIsContentTypeAllowed(): array
{ {
return [ return [
'usual JSON content type' => [ 'usual JSON content type' => [

View File

@@ -18,10 +18,6 @@
namespace {{apiTestsPackage}}; namespace {{apiTestsPackage}};
use {{invokerPackage}}\Configuration;
use {{invokerPackage}}\ApiClient;
use {{invokerPackage}}\ApiException;
use {{invokerPackage}}\ObjectSerializer;
use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -32,6 +28,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @package {{apiTestsPackage}} * @package {{apiTestsPackage}}
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \{{apiPackage}}\{{classname}}
*/ */
{{#operations}}class {{classname}}Test extends WebTestCase {{#operations}}class {{classname}}Test extends WebTestCase
{ {
@@ -76,7 +73,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* {{{summary}}}. * {{{summary}}}.
* *
*/ */
public function test{{operationIdCamelCase}}() public function test{{operationIdCamelCase}}(): void
{ {
$client = self::$client; $client = self::$client;
@@ -106,10 +103,15 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
{{/pathParams}} {{/pathParams}}
$crawler = $client->request('{{httpMethod}}', $path{{#hasBodyParam}}, [], [], ['CONTENT_TYPE' => 'application/json']{{/hasBodyParam}}); $crawler = $client->request('{{httpMethod}}', $path{{#hasBodyParam}}, [], [], ['CONTENT_TYPE' => 'application/json']{{/hasBodyParam}});
$this->markTestSkipped('Test for {{operationId}} not implemented');
} }
{{/operation}} {{/operation}}
protected function genTestData($regexp) /**
* @param string $regexp
* @return mixed
*/
protected function genTestData(string $regexp)
{ {
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp'); $grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar); $compiler = \Hoa\Compiler\Llk\Llk::load($grammar);

View File

@@ -21,20 +21,22 @@
namespace {{modelPackage}}; namespace {{modelPackage}};
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
* {{classname}}Test Class Doc Comment * {{classname}}Test Class Doc Comment
* *
* @category Class */ * @category Class
// * @description {{description}}{{^description}}{{classname}}{{/description}} * @description {{description}}{{^description}}{{classname}}{{/description}}
/**
* @package {{modelTestsPackage}} * @package {{modelTestsPackage}}
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \{{modelPackage}}\{{classname}}
*/ */
class {{classname}}Test extends TestCase class {{classname}}Test extends TestCase
{ {
protected {{classname}}|MockObject $object;
/** /**
* Setup before running any test case * Setup before running any test case
@@ -48,6 +50,7 @@ class {{classname}}Test extends TestCase
*/ */
public function setUp(): void public function setUp(): void
{ {
$this->object = $this->getMockBuilder({{classname}}::class)->getMockForAbstractClass();
} }
/** /**
@@ -65,19 +68,25 @@ class {{classname}}Test extends TestCase
} }
/** /**
* Test "{{classname}}" * @group integration
* @small
*/ */
public function test{{classname}}() public function testTestClassExists(): void
{ {
$test{{classname}} = new {{classname}}(); $this->assertTrue(class_exists({{classname}}::class));
$this->assertInstanceOf({{classname}}::class, $this->object);
} }
{{#vars}} {{#vars}}
/** /**
* Test attribute "{{name}}" * Test attribute "{{name}}"
*
* @group unit
* @small
*/ */
public function testProperty{{nameInCamelCase}}() public function testProperty{{nameInCamelCase}}(): void
{ {
$this->markTestSkipped('Test for property {{name}} not implemented');
} }
{{/vars}} {{/vars}}
} }

View File

@@ -1,24 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./vendor/autoload.php"
colors="true" colors="true"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
stopOnFailure="false"> stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">{{apiSrcPath}}</directory>
<directory suffix=".php">{{modelSrcPath}}</directory>
<directory suffix=".php">{{controllerSrcPath}}</directory>
</include>
</coverage>
<testsuites> <testsuites>
<testsuite> <testsuite name="Default test suite">
<directory>{{apiTestPath}}</directory> <directory>{{apiTestPath}}</directory>
<directory>{{modelTestPath}}</directory> <directory>{{modelTestPath}}</directory>
<directory>{{controllerTestPath}}</directory> <directory>{{controllerTestPath}}</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">{{apiSrcPath}}</directory>
<directory suffix=".php">{{modelSrcPath}}</directory>
<directory suffix=".php">{{controllerSrcPath}}</directory>
</whitelist>
</filter>
<php> <php>
<ini name="error_reporting" value="E_ALL" /> <ini name="error_reporting" value="E_ALL" />
<server name="KERNEL_CLASS" value="{{testsPackage}}\AppKernel" /> <server name="KERNEL_CLASS" value="{{testsPackage}}\AppKernel" />

View File

@@ -5,4 +5,4 @@ framework:
secret: "testsecret" secret: "testsecret"
test: ~ test: ~
router: router:
resource: "%kernel.project_dir%/../Resources/config/routing.yml" resource: "%kernel.project_dir%/Resources/config/routing.yml"

View File

@@ -6,7 +6,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface as SymfonyValidator
class SymfonyValidator implements ValidatorInterface class SymfonyValidator implements ValidatorInterface
{ {
protected $validator; protected SymfonyValidatorInterface $validator;
public function __construct(SymfonyValidatorInterface $validator) public function __construct(SymfonyValidatorInterface $validator)
{ {

View File

@@ -2,6 +2,9 @@
namespace {{servicePackage}}; namespace {{servicePackage}};
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintViolationListInterface;
interface ValidatorInterface interface ValidatorInterface
{ {
/** /**

View File

@@ -29,6 +29,8 @@
namespace OpenAPI\Server\Api; namespace OpenAPI\Server\Api;
use Symfony\Component\DependencyInjection\Reference;
/** /**
* ApiServer Class Doc Comment * ApiServer Class Doc Comment
* *
@@ -45,7 +47,7 @@ class ApiServer
/** /**
* @var array * @var array
*/ */
private $apis = array(); private array $apis = array();
/** /**
* Adds an API handler to the server. * Adds an API handler to the server.
@@ -53,7 +55,7 @@ class ApiServer
* @param string $api An API name of the handle * @param string $api An API name of the handle
* @param mixed $handler A handler to set for the given API * @param mixed $handler A handler to set for the given API
*/ */
public function addApiHandler($api, $handler) public function addApiHandler(string $api, $handler): void
{ {
if (isset($this->apis[$api])) { if (isset($this->apis[$api])) {
throw new \InvalidArgumentException('API has already a handler: '.$api); throw new \InvalidArgumentException('API has already a handler: '.$api);
@@ -69,7 +71,7 @@ class ApiServer
* @return mixed Returns a handler * @return mixed Returns a handler
* @throws \InvalidArgumentException When no such handler exists * @throws \InvalidArgumentException When no such handler exists
*/ */
public function getApiHandler($api) public function getApiHandler(string $api)
{ {
if (!isset($this->apis[$api])) { if (!isset($this->apis[$api])) {
throw new \InvalidArgumentException('No handler for '.$api.' implemented.'); throw new \InvalidArgumentException('No handler for '.$api.' implemented.');

View File

@@ -47,32 +47,33 @@ interface PetApiInterface
/** /**
* Sets authentication method petstore_auth * Sets authentication method petstore_auth
* *
* @param string $value Value of the petstore_auth authentication method. * @param string|null $value Value of the petstore_auth authentication method.
* *
* @return void * @return void
*/ */
public function setpetstore_auth($value); public function setpetstore_auth(?string $value): void;
/** /**
* Sets authentication method api_key * Sets authentication method api_key
* *
* @param string $value Value of the api_key authentication method. * @param string|null $value Value of the api_key authentication method.
* *
* @return void * @return void
*/ */
public function setapi_key($value); public function setapi_key(?string $value): void;
/** /**
* Operation addPet * Operation addPet
* *
* Add a new pet to the store * 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 Pet $pet Pet object that needs to be added to the store (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\Pet * @return array|object|null
*/ */
public function addPet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet; public function addPet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -80,13 +81,14 @@ interface PetApiInterface
* *
* Deletes a pet * Deletes a pet
* *
* @param \int $petId Pet id to delete (required) * @param int $petId Pet id to delete (required)
* @param \string $apiKey (optional) * @param string|null $apiKey (optional)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function deletePet($petId, $apiKey = null, &$responseCode, array &$responseHeaders): void; public function deletePet(int $petId, ?string $apiKey, int &$responseCode, array &$responseHeaders): void;
/** /**
@@ -94,12 +96,13 @@ interface PetApiInterface
* *
* Finds Pets by status * Finds Pets by status
* *
* @param \string[] $status Status values that need to be considered for filter (required) (deprecated) * @param array $status Status values that need to be considered for filter (required) (deprecated)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\Pet[] * @return array|object|null
*/ */
public function findPetsByStatus(array $status, &$responseCode, array &$responseHeaders): iterable; public function findPetsByStatus(array $status, int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -107,13 +110,14 @@ interface PetApiInterface
* *
* Finds Pets by tags * Finds Pets by tags
* *
* @param \string[] $tags Tags to filter by (required) * @param array $tags Tags to filter by (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\Pet[] * @return array|object|null
* @deprecated * @deprecated
*/ */
public function findPetsByTags(array $tags, &$responseCode, array &$responseHeaders): iterable; public function findPetsByTags(array $tags, int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -121,12 +125,13 @@ interface PetApiInterface
* *
* Find pet by ID * Find pet by ID
* *
* @param \int $petId ID of pet to return (required) * @param int $petId ID of pet to return (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\Pet * @return array|object|null
*/ */
public function getPetById($petId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet; public function getPetById(int $petId, int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -134,12 +139,13 @@ interface PetApiInterface
* *
* Update an existing pet * Update an existing pet
* *
* @param \OpenAPI\Server\Model\Pet $pet Pet object that needs to be added to the store (required) * @param Pet $pet Pet object that needs to be added to the store (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\Pet * @return array|object|null
*/ */
public function updatePet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet; public function updatePet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -147,14 +153,15 @@ interface PetApiInterface
* *
* Updates a pet in the store with form data * Updates a pet in the store with form data
* *
* @param \int $petId ID of pet that needs to be updated (required) * @param int $petId ID of pet that needs to be updated (required)
* @param \string $name Updated name of the pet (optional) * @param string|null $name Updated name of the pet (optional)
* @param \string $status Updated status of the pet (optional) * @param string|null $status Updated status of the pet (optional)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function updatePetWithForm($petId, $name = null, $status = null, &$responseCode, array &$responseHeaders): void; public function updatePetWithForm(int $petId, ?string $name, ?string $status, int &$responseCode, array &$responseHeaders): void;
/** /**
@@ -162,13 +169,14 @@ interface PetApiInterface
* *
* uploads an image * uploads an image
* *
* @param \int $petId ID of pet to update (required) * @param int $petId ID of pet to update (required)
* @param \string $additionalMetadata Additional data to pass to server (optional) * @param string|null $additionalMetadata Additional data to pass to server (optional)
* @param \UploadedFile $file file to upload (optional) * @param UploadedFile|null $file file to upload (optional)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\ApiResponse * @return array|object|null
*/ */
public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\ApiResponse; public function uploadFile(int $petId, ?string $additionalMetadata, ?UploadedFile $file, int &$responseCode, array &$responseHeaders): array|object|null;
} }

View File

@@ -46,23 +46,24 @@ interface StoreApiInterface
/** /**
* Sets authentication method api_key * Sets authentication method api_key
* *
* @param string $value Value of the api_key authentication method. * @param string|null $value Value of the api_key authentication method.
* *
* @return void * @return void
*/ */
public function setapi_key($value); public function setapi_key(?string $value): void;
/** /**
* Operation deleteOrder * Operation deleteOrder
* *
* Delete purchase order by ID * Delete purchase order by ID
* *
* @param \string $orderId ID of the order that needs to be deleted (required) * @param string $orderId ID of the order that needs to be deleted (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function deleteOrder($orderId, &$responseCode, array &$responseHeaders): void; public function deleteOrder(string $orderId, int &$responseCode, array &$responseHeaders): void;
/** /**
@@ -70,11 +71,12 @@ interface StoreApiInterface
* *
* Returns pet inventories by status * Returns pet inventories by status
* *
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \int * @return array|object|null
*/ */
public function getInventory(&$responseCode, array &$responseHeaders): array|\int; public function getInventory(int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -82,12 +84,13 @@ interface StoreApiInterface
* *
* Find purchase order by ID * Find purchase order by ID
* *
* @param \int $orderId ID of pet that needs to be fetched (required) * @param int $orderId ID of pet that needs to be fetched (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\Order * @return array|object|null
*/ */
public function getOrderById($orderId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order; public function getOrderById(int $orderId, int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -95,11 +98,12 @@ interface StoreApiInterface
* *
* Place an order for a pet * Place an order for a pet
* *
* @param \OpenAPI\Server\Model\Order $order order placed for purchasing the pet (required) * @param Order $order order placed for purchasing the pet (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\Order * @return array|object|null
*/ */
public function placeOrder(Order $order, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order; public function placeOrder(Order $order, int &$responseCode, array &$responseHeaders): array|object|null;
} }

View File

@@ -46,23 +46,24 @@ interface UserApiInterface
/** /**
* Sets authentication method api_key * Sets authentication method api_key
* *
* @param string $value Value of the api_key authentication method. * @param string|null $value Value of the api_key authentication method.
* *
* @return void * @return void
*/ */
public function setapi_key($value); public function setapi_key(?string $value): void;
/** /**
* Operation createUser * Operation createUser
* *
* Create user * Create user
* *
* @param \OpenAPI\Server\Model\User $user Created user object (required) * @param User $user Created user object (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function createUser(User $user, &$responseCode, array &$responseHeaders): void; public function createUser(User $user, int &$responseCode, array &$responseHeaders): void;
/** /**
@@ -70,12 +71,13 @@ interface UserApiInterface
* *
* Creates list of users with given input array * Creates list of users with given input array
* *
* @param \OpenAPI\Server\Model\User[] $user List of user object (required) * @param array $user List of user object (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function createUsersWithArrayInput(array $user, &$responseCode, array &$responseHeaders): void; public function createUsersWithArrayInput(array $user, int &$responseCode, array &$responseHeaders): void;
/** /**
@@ -83,12 +85,13 @@ interface UserApiInterface
* *
* Creates list of users with given input array * Creates list of users with given input array
* *
* @param \OpenAPI\Server\Model\User[] $user List of user object (required) * @param array $user List of user object (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function createUsersWithListInput(array $user, &$responseCode, array &$responseHeaders): void; public function createUsersWithListInput(array $user, int &$responseCode, array &$responseHeaders): void;
/** /**
@@ -96,12 +99,13 @@ interface UserApiInterface
* *
* Delete user * Delete user
* *
* @param \string $username The name that needs to be deleted (required) * @param string $username The name that needs to be deleted (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function deleteUser($username, &$responseCode, array &$responseHeaders): void; public function deleteUser(string $username, int &$responseCode, array &$responseHeaders): void;
/** /**
@@ -109,12 +113,13 @@ interface UserApiInterface
* *
* Get user by user name * Get user by user name
* *
* @param \string $username The name that needs to be fetched. Use user1 for testing. (required) * @param string $username The name that needs to be fetched. Use user1 for testing. (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \OpenAPI\Server\Model\User * @return array|object|null
*/ */
public function getUserByName($username, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\User; public function getUserByName(string $username, int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -122,13 +127,14 @@ interface UserApiInterface
* *
* Logs user into the system * Logs user into the system
* *
* @param \string $username The user name for login (required) * @param string $username The user name for login (required)
* @param \string $password The password for login in clear text (required) * @param string $password The password for login in clear text (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return \string * @return array|object|null
*/ */
public function loginUser($username, $password, &$responseCode, array &$responseHeaders): array|\string; public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): array|object|null;
/** /**
@@ -136,11 +142,12 @@ interface UserApiInterface
* *
* Logs out current logged in user session * Logs out current logged in user session
* *
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function logoutUser(&$responseCode, array &$responseHeaders): void; public function logoutUser(int &$responseCode, array &$responseHeaders): void;
/** /**
@@ -148,12 +155,13 @@ interface UserApiInterface
* *
* Updated user * Updated user
* *
* @param \string $username name that need to be deleted (required) * @param string $username name that need to be deleted (required)
* @param \OpenAPI\Server\Model\User $user Updated user object (required) * @param User $user Updated user object (required)
* @param \array $responseHeaders Additional HTTP headers to return with the response () * @param int &$responseCode The HTTP Response Code
* @param array $responseHeaders Additional HTTP headers to return with the response ()
* *
* @return void * @return void
*/ */
public function updateUser($username, User $user, &$responseCode, array &$responseHeaders): void; public function updateUser(string $username, User $user, int &$responseCode, array &$responseHeaders): void;
} }

View File

@@ -29,10 +29,12 @@
namespace OpenAPI\Server\Controller; namespace OpenAPI\Server\Controller;
use OpenAPI\Server\Api\ApiServer;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Validator\ConstraintViolation;
use OpenAPI\Server\Service\SerializerInterface; use OpenAPI\Server\Service\SerializerInterface;
use OpenAPI\Server\Service\ValidatorInterface; use OpenAPI\Server\Service\ValidatorInterface;
@@ -46,23 +48,29 @@ use OpenAPI\Server\Service\ValidatorInterface;
*/ */
class Controller extends AbstractController class Controller extends AbstractController
{ {
protected $validator; protected ValidatorInterface $validator;
protected $serializer; protected SerializerInterface $serializer;
protected $apiServer; protected ApiServer $apiServer;
public function setValidator(ValidatorInterface $validator) public function setValidator(ValidatorInterface $validator): self
{ {
$this->validator = $validator; $this->validator = $validator;
return $this;
} }
public function setSerializer(SerializerInterface $serializer) public function setSerializer(SerializerInterface $serializer): self
{ {
$this->serializer = $serializer; $this->serializer = $serializer;
return $this;
} }
public function setApiServer($server) public function setApiServer(ApiServer $server): self
{ {
$this->apiServer = $server; $this->apiServer = $server;
return $this;
} }
/** /**
@@ -73,7 +81,7 @@ class Controller extends AbstractController
* *
* @return Response * @return Response
*/ */
public function createBadRequestResponse($message = 'Bad Request.') public function createBadRequestResponse(string $message = 'Bad Request.'): Response
{ {
return new Response($message, 400); return new Response($message, 400);
} }
@@ -86,7 +94,7 @@ class Controller extends AbstractController
* *
* @return Response * @return Response
*/ */
public function createErrorResponse(HttpException $exception) public function createErrorResponse(HttpException $exception): Response
{ {
$statusCode = $exception->getStatusCode(); $statusCode = $exception->getStatusCode();
$headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']); $headers = array_merge($exception->getHeaders(), ['Content-Type' => 'application/json']);
@@ -101,12 +109,11 @@ class Controller extends AbstractController
* Serializes data to a given type format. * Serializes data to a given type format.
* *
* @param mixed $data The data to serialize. * @param mixed $data The data to serialize.
* @param string $class The source data class.
* @param string $format The target serialization format. * @param string $format The target serialization format.
* *
* @return string A serialized data string. * @return string A serialized data string.
*/ */
protected function serialize($data, $format) protected function serialize($data, string $format): string
{ {
return $this->serializer->serialize($data, $format); return $this->serializer->serialize($data, $format);
} }
@@ -114,35 +121,47 @@ class Controller extends AbstractController
/** /**
* Deserializes data from a given type format. * Deserializes data from a given type format.
* *
* @param string $data The data to deserialize. * @param mixed $data The data to deserialize.
* @param string $class The target data class. * @param string $class The target data class.
* @param string $format The source serialization format. * @param string $format The source serialization format.
* *
* @return mixed A deserialized data. * @return mixed A deserialized data.
*/ */
protected function deserialize($data, $class, $format) protected function deserialize($data, string $class, string $format)
{ {
return $this->serializer->deserialize($data, $class, $format); return $this->serializer->deserialize($data, $class, $format);
} }
protected function validate($data, $asserts = null) /**
* @param mixed $data
* @param mixed $asserts
*
* @return Response|null
*/
protected function validate($data, $asserts = null): ?Response
{ {
$errors = $this->validator->validate($data, $asserts); $errors = $this->validator->validate($data, $asserts);
if (count($errors) > 0) { if (count($errors) > 0) {
$errorsString = (string)$errors; $errorsString = '';
/** @var ConstraintViolation $violation */
foreach ($errors as $violation) {
$errorsString .= $violation->getMessage()."\n";
}
return $this->createBadRequestResponse($errorsString); return $this->createBadRequestResponse($errorsString);
} }
return null;
} }
/** /**
* Converts an exception to a serializable array. * Converts an exception to a serializable array.
* *
* @param \Exception|null $exception * @param \Throwable|null $exception
* *
* @return array * @return array|null
*/ */
private function exceptionToArray(\Exception $exception = null) private function exceptionToArray(\Throwable $exception = null): ?array
{ {
if (null === $exception) { if (null === $exception) {
return null; return null;
@@ -161,7 +180,15 @@ class Controller extends AbstractController
]; ];
} }
protected function getOutputFormat($accept, array $produced) /**
* Converts an exception to a serializable array.
*
* @param string $accept
* @param array $produced
*
* @return ?string
*/
protected function getOutputFormat(string $accept, array $produced): ?string
{ {
// Figure out what the client accepts // Figure out what the client accepts
$accept = preg_split("/[\s,]+/", $accept); $accept = preg_split("/[\s,]+/", $accept);
@@ -196,7 +223,7 @@ class Controller extends AbstractController
* *
* @return bool Returns true if Content-Type supported otherwise false. * @return bool Returns true if Content-Type supported otherwise false.
*/ */
public static function isContentTypeAllowed(Request $request, array $consumes = []) public static function isContentTypeAllowed(Request $request, array $consumes = []): bool
{ {
if (!empty($consumes) && $consumes[0] !== '*/*') { if (!empty($consumes) && $consumes[0] !== '*/*') {
$currentFormat = $request->getContentType(); $currentFormat = $request->getContentType();

View File

@@ -114,6 +114,7 @@ class PetController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->addPet($pet, $responseCode, $responseHeaders); $result = $handler->addPet($pet, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -140,7 +141,7 @@ class PetController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -198,7 +199,8 @@ class PetController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->deletePet($petId, $apiKey, $responseCode, $responseHeaders);
$handler->deletePet($petId, $apiKey, $responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = ''; $message = '';
@@ -220,7 +222,7 @@ class PetController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -286,6 +288,7 @@ class PetController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->findPetsByStatus($status, $responseCode, $responseHeaders); $result = $handler->findPetsByStatus($status, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -312,7 +315,7 @@ class PetController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -376,6 +379,7 @@ class PetController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->findPetsByTags($tags, $responseCode, $responseHeaders); $result = $handler->findPetsByTags($tags, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -402,7 +406,7 @@ class PetController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -461,6 +465,7 @@ class PetController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->getPetById($petId, $responseCode, $responseHeaders); $result = $handler->getPetById($petId, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -490,7 +495,7 @@ class PetController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -559,6 +564,7 @@ class PetController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->updatePet($pet, $responseCode, $responseHeaders); $result = $handler->updatePet($pet, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -591,7 +597,7 @@ class PetController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -657,7 +663,8 @@ class PetController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->updatePetWithForm($petId, $name, $status, $responseCode, $responseHeaders);
$handler->updatePetWithForm($petId, $name, $status, $responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = ''; $message = '';
@@ -679,7 +686,7 @@ class PetController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -753,6 +760,7 @@ class PetController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->uploadFile($petId, $additionalMetadata, $file, $responseCode, $responseHeaders); $result = $handler->uploadFile($petId, $additionalMetadata, $file, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -776,7 +784,7 @@ class PetController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }

View File

@@ -89,7 +89,8 @@ class StoreController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->deleteOrder($orderId, $responseCode, $responseHeaders);
$handler->deleteOrder($orderId, $responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = ''; $message = '';
@@ -114,7 +115,7 @@ class StoreController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -159,6 +160,7 @@ class StoreController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->getInventory($responseCode, $responseHeaders); $result = $handler->getInventory($responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -182,7 +184,7 @@ class StoreController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -238,6 +240,7 @@ class StoreController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->getOrderById($orderId, $responseCode, $responseHeaders); $result = $handler->getOrderById($orderId, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -267,7 +270,7 @@ class StoreController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -331,6 +334,7 @@ class StoreController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->placeOrder($order, $responseCode, $responseHeaders); $result = $handler->placeOrder($order, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -357,7 +361,7 @@ class StoreController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }

View File

@@ -104,7 +104,8 @@ class UserController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->createUser($user, $responseCode, $responseHeaders);
$handler->createUser($user, $responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = 'successful operation'; $message = 'successful operation';
@@ -126,7 +127,7 @@ class UserController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -188,7 +189,8 @@ class UserController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->createUsersWithArrayInput($user, $responseCode, $responseHeaders);
$handler->createUsersWithArrayInput($user, $responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = 'successful operation'; $message = 'successful operation';
@@ -210,7 +212,7 @@ class UserController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -272,7 +274,8 @@ class UserController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->createUsersWithListInput($user, $responseCode, $responseHeaders);
$handler->createUsersWithListInput($user, $responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = 'successful operation'; $message = 'successful operation';
@@ -294,7 +297,7 @@ class UserController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -344,7 +347,8 @@ class UserController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->deleteUser($username, $responseCode, $responseHeaders);
$handler->deleteUser($username, $responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = ''; $message = '';
@@ -369,7 +373,7 @@ class UserController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -423,6 +427,7 @@ class UserController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->getUserByName($username, $responseCode, $responseHeaders); $result = $handler->getUserByName($username, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -452,7 +457,7 @@ class UserController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -517,6 +522,7 @@ class UserController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 200; $responseCode = 200;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->loginUser($username, $password, $responseCode, $responseHeaders); $result = $handler->loginUser($username, $password, $responseCode, $responseHeaders);
// Find default response message // Find default response message
@@ -543,7 +549,7 @@ class UserController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -579,7 +585,8 @@ class UserController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->logoutUser($responseCode, $responseHeaders);
$handler->logoutUser($responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = 'successful operation'; $message = 'successful operation';
@@ -601,7 +608,7 @@ class UserController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }
@@ -669,7 +676,8 @@ class UserController extends Controller
// Make the call to the business logic // Make the call to the business logic
$responseCode = 204; $responseCode = 204;
$responseHeaders = []; $responseHeaders = [];
$result = $handler->updateUser($username, $user, $responseCode, $responseHeaders);
$handler->updateUser($username, $user, $responseCode, $responseHeaders);
// Find default response message // Find default response message
$message = ''; $message = '';
@@ -694,7 +702,7 @@ class UserController extends Controller
] ]
) )
); );
} catch (Exception $fallthrough) { } catch (\Throwable $fallthrough) {
return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough)); return $this->createErrorResponse(new HttpException(500, 'An unsuspected error occurred.', $fallthrough));
} }
} }

View File

@@ -44,7 +44,7 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
*/ */
class OpenAPIServerExtension extends Extension class OpenAPIServerExtension extends Extension
{ {
public function load(array $configs, ContainerBuilder $container) public function load(array $configs, ContainerBuilder $container): void
{ {
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml'); $loader->load('services.yml');

View File

@@ -49,7 +49,7 @@ class ApiResponse
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $code; protected ?int $code = null;
/** /**
* @var string|null * @var string|null
@@ -57,7 +57,7 @@ class ApiResponse
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $type; protected ?string $type = null;
/** /**
* @var string|null * @var string|null
@@ -65,17 +65,17 @@ class ApiResponse
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $message; protected ?string $message = null;
/** /**
* Constructor * Constructor
* @param mixed[] $data Associated array of property values initializing the model * @param array|null $data Associated array of property values initializing the model
*/ */
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
$this->code = isset($data['code']) ? $data['code'] : null; $this->code = $data['code'] ?? null;
$this->type = isset($data['type']) ? $data['type'] : null; $this->type = $data['type'] ?? null;
$this->message = isset($data['message']) ? $data['message'] : null; $this->message = $data['message'] ?? null;
} }
/** /**
@@ -83,7 +83,7 @@ class ApiResponse
* *
* @return int|null * @return int|null
*/ */
public function getCode() public function getCode(): ?int
{ {
return $this->code; return $this->code;
} }
@@ -95,7 +95,7 @@ class ApiResponse
* *
* @return $this * @return $this
*/ */
public function setCode($code = null) public function setCode(?int $code = null): self
{ {
$this->code = $code; $this->code = $code;
@@ -107,7 +107,7 @@ class ApiResponse
* *
* @return string|null * @return string|null
*/ */
public function getType() public function getType(): ?string
{ {
return $this->type; return $this->type;
} }
@@ -119,7 +119,7 @@ class ApiResponse
* *
* @return $this * @return $this
*/ */
public function setType($type = null) public function setType(?string $type = null): self
{ {
$this->type = $type; $this->type = $type;
@@ -131,7 +131,7 @@ class ApiResponse
* *
* @return string|null * @return string|null
*/ */
public function getMessage() public function getMessage(): ?string
{ {
return $this->message; return $this->message;
} }
@@ -143,7 +143,7 @@ class ApiResponse
* *
* @return $this * @return $this
*/ */
public function setMessage($message = null) public function setMessage(?string $message = null): self
{ {
$this->message = $message; $this->message = $message;

View File

@@ -49,7 +49,7 @@ class Category
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $id; protected ?int $id = null;
/** /**
* @var string|null * @var string|null
@@ -58,16 +58,16 @@ class Category
* @Type("string") * @Type("string")
* @Assert\Regex("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/") * @Assert\Regex("/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/")
*/ */
protected $name; protected ?string $name = null;
/** /**
* Constructor * Constructor
* @param mixed[] $data Associated array of property values initializing the model * @param array|null $data Associated array of property values initializing the model
*/ */
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
$this->id = isset($data['id']) ? $data['id'] : null; $this->id = $data['id'] ?? null;
$this->name = isset($data['name']) ? $data['name'] : null; $this->name = $data['name'] ?? null;
} }
/** /**
@@ -75,7 +75,7 @@ class Category
* *
* @return int|null * @return int|null
*/ */
public function getId() public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
@@ -87,7 +87,7 @@ class Category
* *
* @return $this * @return $this
*/ */
public function setId($id = null) public function setId(?int $id = null): self
{ {
$this->id = $id; $this->id = $id;
@@ -99,7 +99,7 @@ class Category
* *
* @return string|null * @return string|null
*/ */
public function getName() public function getName(): ?string
{ {
return $this->name; return $this->name;
} }
@@ -111,7 +111,7 @@ class Category
* *
* @return $this * @return $this
*/ */
public function setName($name = null) public function setName(?string $name = null): self
{ {
$this->name = $name; $this->name = $name;

View File

@@ -49,7 +49,7 @@ class Order
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $id; protected ?int $id = null;
/** /**
* @var int|null * @var int|null
@@ -57,7 +57,7 @@ class Order
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $petId; protected ?int $petId = null;
/** /**
* @var int|null * @var int|null
@@ -65,7 +65,7 @@ class Order
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $quantity; protected ?int $quantity = null;
/** /**
* @var \DateTime|null * @var \DateTime|null
@@ -73,7 +73,7 @@ class Order
* @Assert\DateTime() * @Assert\DateTime()
* @Type("DateTime") * @Type("DateTime")
*/ */
protected $shipDate; protected ?\DateTime $shipDate = null;
/** /**
* Order Status * Order Status
@@ -84,7 +84,7 @@ class Order
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $status; protected ?string $status = null;
/** /**
* @var bool|null * @var bool|null
@@ -92,20 +92,20 @@ class Order
* @Assert\Type("bool") * @Assert\Type("bool")
* @Type("bool") * @Type("bool")
*/ */
protected $complete; protected ?bool $complete = null;
/** /**
* Constructor * Constructor
* @param mixed[] $data Associated array of property values initializing the model * @param array|null $data Associated array of property values initializing the model
*/ */
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
$this->id = isset($data['id']) ? $data['id'] : null; $this->id = $data['id'] ?? null;
$this->petId = isset($data['petId']) ? $data['petId'] : null; $this->petId = $data['petId'] ?? null;
$this->quantity = isset($data['quantity']) ? $data['quantity'] : null; $this->quantity = $data['quantity'] ?? null;
$this->shipDate = isset($data['shipDate']) ? $data['shipDate'] : null; $this->shipDate = $data['shipDate'] ?? null;
$this->status = isset($data['status']) ? $data['status'] : null; $this->status = $data['status'] ?? null;
$this->complete = isset($data['complete']) ? $data['complete'] : false; $this->complete = $data['complete'] ?? null;
} }
/** /**
@@ -113,7 +113,7 @@ class Order
* *
* @return int|null * @return int|null
*/ */
public function getId() public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
@@ -125,7 +125,7 @@ class Order
* *
* @return $this * @return $this
*/ */
public function setId($id = null) public function setId(?int $id = null): self
{ {
$this->id = $id; $this->id = $id;
@@ -137,7 +137,7 @@ class Order
* *
* @return int|null * @return int|null
*/ */
public function getPetId() public function getPetId(): ?int
{ {
return $this->petId; return $this->petId;
} }
@@ -149,7 +149,7 @@ class Order
* *
* @return $this * @return $this
*/ */
public function setPetId($petId = null) public function setPetId(?int $petId = null): self
{ {
$this->petId = $petId; $this->petId = $petId;
@@ -161,7 +161,7 @@ class Order
* *
* @return int|null * @return int|null
*/ */
public function getQuantity() public function getQuantity(): ?int
{ {
return $this->quantity; return $this->quantity;
} }
@@ -173,7 +173,7 @@ class Order
* *
* @return $this * @return $this
*/ */
public function setQuantity($quantity = null) public function setQuantity(?int $quantity = null): self
{ {
$this->quantity = $quantity; $this->quantity = $quantity;
@@ -197,7 +197,7 @@ class Order
* *
* @return $this * @return $this
*/ */
public function setShipDate(\DateTime $shipDate = null) public function setShipDate(?\DateTime $shipDate = null): self
{ {
$this->shipDate = $shipDate; $this->shipDate = $shipDate;
@@ -209,7 +209,7 @@ class Order
* *
* @return string|null * @return string|null
*/ */
public function getStatus() public function getStatus(): ?string
{ {
return $this->status; return $this->status;
} }
@@ -221,7 +221,7 @@ class Order
* *
* @return $this * @return $this
*/ */
public function setStatus($status = null) public function setStatus(?string $status = null): self
{ {
$this->status = $status; $this->status = $status;
@@ -233,7 +233,7 @@ class Order
* *
* @return bool|null * @return bool|null
*/ */
public function isComplete() public function isComplete(): ?bool
{ {
return $this->complete; return $this->complete;
} }
@@ -245,7 +245,7 @@ class Order
* *
* @return $this * @return $this
*/ */
public function setComplete($complete = null) public function setComplete(?bool $complete = null): self
{ {
$this->complete = $complete; $this->complete = $complete;

View File

@@ -49,27 +49,27 @@ class Pet
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $id; protected ?int $id = null;
/** /**
* @var OpenAPI\Server\Model\Category|null * @var Category|null
* @SerializedName("category") * @SerializedName("category")
* @Assert\Type("OpenAPI\Server\Model\Category") * @Assert\Type("OpenAPI\Server\Model\Category")
* @Type("OpenAPI\Server\Model\Category") * @Type("OpenAPI\Server\Model\Category")
*/ */
protected $category; protected ?Category $category = null;
/** /**
* @var string * @var string|null
* @SerializedName("name") * @SerializedName("name")
* @Assert\NotNull() * @Assert\NotNull()
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $name; protected ?string $name = null;
/** /**
* @var string[] * @var array|null
* @SerializedName("photoUrls") * @SerializedName("photoUrls")
* @Assert\NotNull() * @Assert\NotNull()
* @Assert\All({ * @Assert\All({
@@ -77,17 +77,17 @@ class Pet
* }) * })
* @Type("array<string>") * @Type("array<string>")
*/ */
protected $photoUrls; protected ?array $photoUrls = null;
/** /**
* @var OpenAPI\Server\Model\Tag[]|null * @var array|null
* @SerializedName("tags") * @SerializedName("tags")
* @Assert\All({ * @Assert\All({
* @Assert\Type("OpenAPI\Server\Model\Tag") * @Assert\Type("OpenAPI\Server\Model\Tag")
* }) * })
* @Type("array<OpenAPI\Server\Model\Tag>") * @Type("array<OpenAPI\Server\Model\Tag>")
*/ */
protected $tags; protected ?array $tags = null;
/** /**
* pet status in the store * pet status in the store
@@ -98,20 +98,20 @@ class Pet
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $status; protected ?string $status = null;
/** /**
* Constructor * Constructor
* @param mixed[] $data Associated array of property values initializing the model * @param array|null $data Associated array of property values initializing the model
*/ */
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
$this->id = isset($data['id']) ? $data['id'] : null; $this->id = $data['id'] ?? null;
$this->category = isset($data['category']) ? $data['category'] : null; $this->category = $data['category'] ?? null;
$this->name = isset($data['name']) ? $data['name'] : null; $this->name = $data['name'] ?? null;
$this->photoUrls = isset($data['photoUrls']) ? $data['photoUrls'] : null; $this->photoUrls = $data['photoUrls'] ?? null;
$this->tags = isset($data['tags']) ? $data['tags'] : null; $this->tags = $data['tags'] ?? null;
$this->status = isset($data['status']) ? $data['status'] : null; $this->status = $data['status'] ?? null;
} }
/** /**
@@ -119,7 +119,7 @@ class Pet
* *
* @return int|null * @return int|null
*/ */
public function getId() public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
@@ -131,7 +131,7 @@ class Pet
* *
* @return $this * @return $this
*/ */
public function setId($id = null) public function setId(?int $id = null): self
{ {
$this->id = $id; $this->id = $id;
@@ -141,7 +141,7 @@ class Pet
/** /**
* Gets category. * Gets category.
* *
* @return OpenAPI\Server\Model\Category|null * @return Category|null
*/ */
public function getCategory(): ?Category public function getCategory(): ?Category
{ {
@@ -151,11 +151,11 @@ class Pet
/** /**
* Sets category. * Sets category.
* *
* @param OpenAPI\Server\Model\Category|null $category * @param Category|null $category
* *
* @return $this * @return $this
*/ */
public function setCategory(Category $category = null) public function setCategory(?Category $category = null): self
{ {
$this->category = $category; $this->category = $category;
@@ -165,9 +165,9 @@ class Pet
/** /**
* Gets name. * Gets name.
* *
* @return string * @return string|null
*/ */
public function getName() public function getName(): ?string
{ {
return $this->name; return $this->name;
} }
@@ -175,11 +175,11 @@ class Pet
/** /**
* Sets name. * Sets name.
* *
* @param string $name * @param string|null $name
* *
* @return $this * @return $this
*/ */
public function setName($name) public function setName(?string $name): self
{ {
$this->name = $name; $this->name = $name;
@@ -189,9 +189,9 @@ class Pet
/** /**
* Gets photoUrls. * Gets photoUrls.
* *
* @return string[] * @return array|null
*/ */
public function getPhotoUrls(): array public function getPhotoUrls(): ?array
{ {
return $this->photoUrls; return $this->photoUrls;
} }
@@ -199,11 +199,11 @@ class Pet
/** /**
* Sets photoUrls. * Sets photoUrls.
* *
* @param string[] $photoUrls * @param array|null $photoUrls
* *
* @return $this * @return $this
*/ */
public function setPhotoUrls(array $photoUrls) public function setPhotoUrls(?array $photoUrls): self
{ {
$this->photoUrls = $photoUrls; $this->photoUrls = $photoUrls;
@@ -213,7 +213,7 @@ class Pet
/** /**
* Gets tags. * Gets tags.
* *
* @return OpenAPI\Server\Model\Tag[]|null * @return array|null
*/ */
public function getTags(): ?array public function getTags(): ?array
{ {
@@ -223,11 +223,11 @@ class Pet
/** /**
* Sets tags. * Sets tags.
* *
* @param OpenAPI\Server\Model\Tag[]|null $tags * @param array|null $tags
* *
* @return $this * @return $this
*/ */
public function setTags(array $tags = null) public function setTags(?array $tags = null): self
{ {
$this->tags = $tags; $this->tags = $tags;
@@ -239,7 +239,7 @@ class Pet
* *
* @return string|null * @return string|null
*/ */
public function getStatus() public function getStatus(): ?string
{ {
return $this->status; return $this->status;
} }
@@ -251,7 +251,7 @@ class Pet
* *
* @return $this * @return $this
*/ */
public function setStatus($status = null) public function setStatus(?string $status = null): self
{ {
$this->status = $status; $this->status = $status;

View File

@@ -49,7 +49,7 @@ class Tag
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $id; protected ?int $id = null;
/** /**
* @var string|null * @var string|null
@@ -57,16 +57,16 @@ class Tag
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $name; protected ?string $name = null;
/** /**
* Constructor * Constructor
* @param mixed[] $data Associated array of property values initializing the model * @param array|null $data Associated array of property values initializing the model
*/ */
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
$this->id = isset($data['id']) ? $data['id'] : null; $this->id = $data['id'] ?? null;
$this->name = isset($data['name']) ? $data['name'] : null; $this->name = $data['name'] ?? null;
} }
/** /**
@@ -74,7 +74,7 @@ class Tag
* *
* @return int|null * @return int|null
*/ */
public function getId() public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
@@ -86,7 +86,7 @@ class Tag
* *
* @return $this * @return $this
*/ */
public function setId($id = null) public function setId(?int $id = null): self
{ {
$this->id = $id; $this->id = $id;
@@ -98,7 +98,7 @@ class Tag
* *
* @return string|null * @return string|null
*/ */
public function getName() public function getName(): ?string
{ {
return $this->name; return $this->name;
} }
@@ -110,7 +110,7 @@ class Tag
* *
* @return $this * @return $this
*/ */
public function setName($name = null) public function setName(?string $name = null): self
{ {
$this->name = $name; $this->name = $name;

View File

@@ -49,7 +49,7 @@ class User
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $id; protected ?int $id = null;
/** /**
* @var string|null * @var string|null
@@ -57,7 +57,7 @@ class User
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $username; protected ?string $username = null;
/** /**
* @var string|null * @var string|null
@@ -65,7 +65,7 @@ class User
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $firstName; protected ?string $firstName = null;
/** /**
* @var string|null * @var string|null
@@ -73,7 +73,7 @@ class User
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $lastName; protected ?string $lastName = null;
/** /**
* @var string|null * @var string|null
@@ -81,7 +81,7 @@ class User
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $email; protected ?string $email = null;
/** /**
* @var string|null * @var string|null
@@ -89,7 +89,7 @@ class User
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $password; protected ?string $password = null;
/** /**
* @var string|null * @var string|null
@@ -97,7 +97,7 @@ class User
* @Assert\Type("string") * @Assert\Type("string")
* @Type("string") * @Type("string")
*/ */
protected $phone; protected ?string $phone = null;
/** /**
* User Status * User Status
@@ -107,22 +107,22 @@ class User
* @Assert\Type("int") * @Assert\Type("int")
* @Type("int") * @Type("int")
*/ */
protected $userStatus; protected ?int $userStatus = null;
/** /**
* Constructor * Constructor
* @param mixed[] $data Associated array of property values initializing the model * @param array|null $data Associated array of property values initializing the model
*/ */
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
$this->id = isset($data['id']) ? $data['id'] : null; $this->id = $data['id'] ?? null;
$this->username = isset($data['username']) ? $data['username'] : null; $this->username = $data['username'] ?? null;
$this->firstName = isset($data['firstName']) ? $data['firstName'] : null; $this->firstName = $data['firstName'] ?? null;
$this->lastName = isset($data['lastName']) ? $data['lastName'] : null; $this->lastName = $data['lastName'] ?? null;
$this->email = isset($data['email']) ? $data['email'] : null; $this->email = $data['email'] ?? null;
$this->password = isset($data['password']) ? $data['password'] : null; $this->password = $data['password'] ?? null;
$this->phone = isset($data['phone']) ? $data['phone'] : null; $this->phone = $data['phone'] ?? null;
$this->userStatus = isset($data['userStatus']) ? $data['userStatus'] : null; $this->userStatus = $data['userStatus'] ?? null;
} }
/** /**
@@ -130,7 +130,7 @@ class User
* *
* @return int|null * @return int|null
*/ */
public function getId() public function getId(): ?int
{ {
return $this->id; return $this->id;
} }
@@ -142,7 +142,7 @@ class User
* *
* @return $this * @return $this
*/ */
public function setId($id = null) public function setId(?int $id = null): self
{ {
$this->id = $id; $this->id = $id;
@@ -154,7 +154,7 @@ class User
* *
* @return string|null * @return string|null
*/ */
public function getUsername() public function getUsername(): ?string
{ {
return $this->username; return $this->username;
} }
@@ -166,7 +166,7 @@ class User
* *
* @return $this * @return $this
*/ */
public function setUsername($username = null) public function setUsername(?string $username = null): self
{ {
$this->username = $username; $this->username = $username;
@@ -178,7 +178,7 @@ class User
* *
* @return string|null * @return string|null
*/ */
public function getFirstName() public function getFirstName(): ?string
{ {
return $this->firstName; return $this->firstName;
} }
@@ -190,7 +190,7 @@ class User
* *
* @return $this * @return $this
*/ */
public function setFirstName($firstName = null) public function setFirstName(?string $firstName = null): self
{ {
$this->firstName = $firstName; $this->firstName = $firstName;
@@ -202,7 +202,7 @@ class User
* *
* @return string|null * @return string|null
*/ */
public function getLastName() public function getLastName(): ?string
{ {
return $this->lastName; return $this->lastName;
} }
@@ -214,7 +214,7 @@ class User
* *
* @return $this * @return $this
*/ */
public function setLastName($lastName = null) public function setLastName(?string $lastName = null): self
{ {
$this->lastName = $lastName; $this->lastName = $lastName;
@@ -226,7 +226,7 @@ class User
* *
* @return string|null * @return string|null
*/ */
public function getEmail() public function getEmail(): ?string
{ {
return $this->email; return $this->email;
} }
@@ -238,7 +238,7 @@ class User
* *
* @return $this * @return $this
*/ */
public function setEmail($email = null) public function setEmail(?string $email = null): self
{ {
$this->email = $email; $this->email = $email;
@@ -250,7 +250,7 @@ class User
* *
* @return string|null * @return string|null
*/ */
public function getPassword() public function getPassword(): ?string
{ {
return $this->password; return $this->password;
} }
@@ -262,7 +262,7 @@ class User
* *
* @return $this * @return $this
*/ */
public function setPassword($password = null) public function setPassword(?string $password = null): self
{ {
$this->password = $password; $this->password = $password;
@@ -274,7 +274,7 @@ class User
* *
* @return string|null * @return string|null
*/ */
public function getPhone() public function getPhone(): ?string
{ {
return $this->phone; return $this->phone;
} }
@@ -286,7 +286,7 @@ class User
* *
* @return $this * @return $this
*/ */
public function setPhone($phone = null) public function setPhone(?string $phone = null): self
{ {
$this->phone = $phone; $this->phone = $phone;
@@ -298,7 +298,7 @@ class User
* *
* @return int|null * @return int|null
*/ */
public function getUserStatus() public function getUserStatus(): ?int
{ {
return $this->userStatus; return $this->userStatus;
} }
@@ -310,7 +310,7 @@ class User
* *
* @return $this * @return $this
*/ */
public function setUserStatus($userStatus = null) public function setUserStatus(?int $userStatus = null): self
{ {
$this->userStatus = $userStatus; $this->userStatus = $userStatus;

View File

@@ -87,7 +87,7 @@ class PetApi implements PetApiInterface // An interface is autogenerated
/** /**
* Implementation of PetApiInterface#addPet * Implementation of PetApiInterface#addPet
*/ */
public function addPet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet public function addPet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }

View File

@@ -57,7 +57,7 @@ class PetApi implements PetApiInterface
/** /**
* Implementation of PetApiInterface#addPet * Implementation of PetApiInterface#addPet
*/ */
public function addPet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet public function addPet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -119,7 +119,7 @@ class PetApi implements PetApiInterface
/** /**
* Implementation of PetApiInterface#deletePet * Implementation of PetApiInterface#deletePet
*/ */
public function deletePet($petId, $apiKey = null, &$responseCode, array &$responseHeaders): void public function deletePet(int $petId, ?string $apiKey, int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -182,7 +182,7 @@ class PetApi implements PetApiInterface
/** /**
* Implementation of PetApiInterface#findPetsByStatus * Implementation of PetApiInterface#findPetsByStatus
*/ */
public function findPetsByStatus(array $status, &$responseCode, array &$responseHeaders): iterable public function findPetsByStatus(array $status, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -244,7 +244,7 @@ class PetApi implements PetApiInterface
/** /**
* Implementation of PetApiInterface#findPetsByTags * Implementation of PetApiInterface#findPetsByTags
*/ */
public function findPetsByTags(array $tags, &$responseCode, array &$responseHeaders): iterable public function findPetsByTags(array $tags, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -306,7 +306,7 @@ class PetApi implements PetApiInterface
/** /**
* Implementation of PetApiInterface#getPetById * Implementation of PetApiInterface#getPetById
*/ */
public function getPetById($petId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet public function getPetById(int $petId, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -368,7 +368,7 @@ class PetApi implements PetApiInterface
/** /**
* Implementation of PetApiInterface#updatePet * Implementation of PetApiInterface#updatePet
*/ */
public function updatePet(Pet $pet, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Pet public function updatePet(Pet $pet, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -430,7 +430,7 @@ class PetApi implements PetApiInterface
/** /**
* Implementation of PetApiInterface#updatePetWithForm * Implementation of PetApiInterface#updatePetWithForm
*/ */
public function updatePetWithForm($petId, $name = null, $status = null, &$responseCode, array &$responseHeaders): void public function updatePetWithForm(int $petId, ?string $name, ?string $status, int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -494,7 +494,7 @@ class PetApi implements PetApiInterface
/** /**
* Implementation of PetApiInterface#uploadFile * Implementation of PetApiInterface#uploadFile
*/ */
public function uploadFile($petId, $additionalMetadata = null, UploadedFile $file = null, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\ApiResponse public function uploadFile(int $petId, ?string $additionalMetadata, ?UploadedFile $file, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }

View File

@@ -45,7 +45,7 @@ class StoreApi implements StoreApiInterface
/** /**
* Implementation of StoreApiInterface#deleteOrder * Implementation of StoreApiInterface#deleteOrder
*/ */
public function deleteOrder($orderId, &$responseCode, array &$responseHeaders): void public function deleteOrder(string $orderId, int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -107,7 +107,7 @@ class StoreApi implements StoreApiInterface
/** /**
* Implementation of StoreApiInterface#getInventory * Implementation of StoreApiInterface#getInventory
*/ */
public function getInventory(, &$responseCode, array &$responseHeaders): array|\int public function getInventory(int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -158,7 +158,7 @@ class StoreApi implements StoreApiInterface
/** /**
* Implementation of StoreApiInterface#getOrderById * Implementation of StoreApiInterface#getOrderById
*/ */
public function getOrderById($orderId, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order public function getOrderById(int $orderId, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -212,7 +212,7 @@ class StoreApi implements StoreApiInterface
/** /**
* Implementation of StoreApiInterface#placeOrder * Implementation of StoreApiInterface#placeOrder
*/ */
public function placeOrder(Order $order, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\Order public function placeOrder(Order $order, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }

View File

@@ -57,7 +57,7 @@ class UserApi implements UserApiInterface
/** /**
* Implementation of UserApiInterface#createUser * Implementation of UserApiInterface#createUser
*/ */
public function createUser(User $user, &$responseCode, array &$responseHeaders): void public function createUser(User $user, int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -119,7 +119,7 @@ class UserApi implements UserApiInterface
/** /**
* Implementation of UserApiInterface#createUsersWithArrayInput * Implementation of UserApiInterface#createUsersWithArrayInput
*/ */
public function createUsersWithArrayInput(array $user, &$responseCode, array &$responseHeaders): void public function createUsersWithArrayInput(array $user, int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -181,7 +181,7 @@ class UserApi implements UserApiInterface
/** /**
* Implementation of UserApiInterface#createUsersWithListInput * Implementation of UserApiInterface#createUsersWithListInput
*/ */
public function createUsersWithListInput(array $user, &$responseCode, array &$responseHeaders): void public function createUsersWithListInput(array $user, int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -243,7 +243,7 @@ class UserApi implements UserApiInterface
/** /**
* Implementation of UserApiInterface#deleteUser * Implementation of UserApiInterface#deleteUser
*/ */
public function deleteUser($username, &$responseCode, array &$responseHeaders): void public function deleteUser(string $username, int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -297,7 +297,7 @@ class UserApi implements UserApiInterface
/** /**
* Implementation of UserApiInterface#getUserByName * Implementation of UserApiInterface#getUserByName
*/ */
public function getUserByName($username, &$responseCode, array &$responseHeaders): array|\OpenAPI\Server\Model\User public function getUserByName(string $username, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// 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($username, $password, &$responseCode, array &$responseHeaders): array|\string public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): array|object|null
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -414,7 +414,7 @@ class UserApi implements UserApiInterface
/** /**
* Implementation of UserApiInterface#logoutUser * Implementation of UserApiInterface#logoutUser
*/ */
public function logoutUser(, &$responseCode, array &$responseHeaders): void public function logoutUser(int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }
@@ -473,7 +473,7 @@ class UserApi implements UserApiInterface
/** /**
* Implementation of UserApiInterface#updateUser * Implementation of UserApiInterface#updateUser
*/ */
public function updateUser($username, User $user, &$responseCode, array &$responseHeaders): void public function updateUser(string $username, User $user, int &$responseCode, array &$responseHeaders): void
{ {
// Implement the operation ... // Implement the operation ...
} }

View File

@@ -5,13 +5,14 @@ namespace OpenAPI\Server\Service;
use JMS\Serializer\SerializerBuilder; use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\Naming\CamelCaseNamingStrategy; use JMS\Serializer\Naming\CamelCaseNamingStrategy;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy; use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
use JMS\Serializer\Serializer;
use JMS\Serializer\Visitor\Factory\XmlDeserializationVisitorFactory; use JMS\Serializer\Visitor\Factory\XmlDeserializationVisitorFactory;
use DateTime; use DateTime;
use RuntimeException; use RuntimeException;
class JmsSerializer implements SerializerInterface class JmsSerializer implements SerializerInterface
{ {
protected $serializer; protected Serializer $serializer;
public function __construct() public function __construct()
{ {
@@ -23,12 +24,18 @@ class JmsSerializer implements SerializerInterface
->build(); ->build();
} }
public function serialize($data, $format) /**
* @inheritdoc
*/
public function serialize($data, string $format): string
{ {
return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format)); return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format));
} }
public function deserialize($data, $type, $format) /**
* @inheritdoc
*/
public function deserialize($data, string $type, string $format)
{ {
if ($format == 'string') { if ($format == 'string') {
return $this->deserializeString($data, $type); return $this->deserializeString($data, $type);
@@ -38,7 +45,7 @@ class JmsSerializer implements SerializerInterface
return $this->serializer->deserialize($data, $type, $this->convertFormat($format)); return $this->serializer->deserialize($data, $type, $this->convertFormat($format));
} }
private function convertFormat($format) private function convertFormat(string $format): ?string
{ {
switch ($format) { switch ($format) {
case 'application/json': case 'application/json':
@@ -50,7 +57,7 @@ class JmsSerializer implements SerializerInterface
return null; return null;
} }
private function deserializeString($data, $type) private function deserializeString($data, string $type)
{ {
// Figure out if we have an array format // Figure out if we have an array format
if (1 === preg_match('/array<(csv|ssv|tsv|pipes),(int|string)>/i', $type, $matches)) { if (1 === preg_match('/array<(csv|ssv|tsv|pipes),(int|string)>/i', $type, $matches)) {
@@ -73,6 +80,10 @@ class JmsSerializer implements SerializerInterface
break; break;
case 'boolean': case 'boolean':
case 'bool': case 'bool':
if (is_bool($data)) {
return $data;
}
if (strtolower($data) === 'true') { if (strtolower($data) === 'true') {
return true; return true;
} }
@@ -93,10 +104,9 @@ class JmsSerializer implements SerializerInterface
return $data; return $data;
} }
private function deserializeArrayString($format, $type, $data) private function deserializeArrayString(string $format, string $type, $data): array
{ {
if($data === null) if (empty($data)) {
{
return []; return [];
} }

View File

@@ -12,16 +12,16 @@ interface SerializerInterface
* *
* @return string * @return string
*/ */
public function serialize($data, $format); public function serialize($data, string $format): string;
/** /**
* Deserializes the given data to the specified type. * Deserializes the given data to the specified type.
* *
* @param string $data * @param mixed $data
* @param string $type * @param string $type
* @param string $format * @param string $format
* *
* @return object|array|scalar * @return object|array|scalar
*/ */
public function deserialize($data, $type, $format); public function deserialize($data, string $type, string $format);
} }

View File

@@ -6,7 +6,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface as SymfonyValidator
class SymfonyValidator implements ValidatorInterface class SymfonyValidator implements ValidatorInterface
{ {
protected $validator; protected SymfonyValidatorInterface $validator;
public function __construct(SymfonyValidatorInterface $validator) public function __construct(SymfonyValidatorInterface $validator)
{ {

View File

@@ -2,6 +2,9 @@
namespace OpenAPI\Server\Service; namespace OpenAPI\Server\Service;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintViolationListInterface;
interface ValidatorInterface interface ValidatorInterface
{ {
/** /**

View File

@@ -28,10 +28,6 @@
namespace OpenAPI\Server\Tests\Api; namespace OpenAPI\Server\Tests\Api;
use OpenAPI\Server\Configuration;
use OpenAPI\Server\ApiClient;
use OpenAPI\Server\ApiException;
use OpenAPI\Server\ObjectSerializer;
use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @package OpenAPI\Server\Tests\Api * @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Api\PetApiInterface
*/ */
class PetApiInterfaceTest extends WebTestCase class PetApiInterfaceTest extends WebTestCase
{ {
@@ -85,13 +82,14 @@ class PetApiInterfaceTest extends WebTestCase
* Add a new pet to the store. * Add a new pet to the store.
* *
*/ */
public function testAddPet() public function testAddPet(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/pet'; $path = '/pet';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']); $crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for addPet not implemented');
} }
/** /**
@@ -100,7 +98,7 @@ class PetApiInterfaceTest extends WebTestCase
* Deletes a pet. * Deletes a pet.
* *
*/ */
public function testDeletePet() public function testDeletePet(): void
{ {
$client = self::$client; $client = self::$client;
@@ -110,6 +108,7 @@ class PetApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path); $crawler = $client->request('DELETE', $path);
$this->markTestSkipped('Test for deletePet not implemented');
} }
/** /**
@@ -118,13 +117,14 @@ class PetApiInterfaceTest extends WebTestCase
* Finds Pets by status. * Finds Pets by status.
* *
*/ */
public function testFindPetsByStatus() public function testFindPetsByStatus(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/pet/findByStatus'; $path = '/pet/findByStatus';
$crawler = $client->request('GET', $path); $crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for findPetsByStatus not implemented');
} }
/** /**
@@ -133,13 +133,14 @@ class PetApiInterfaceTest extends WebTestCase
* Finds Pets by tags. * Finds Pets by tags.
* *
*/ */
public function testFindPetsByTags() public function testFindPetsByTags(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/pet/findByTags'; $path = '/pet/findByTags';
$crawler = $client->request('GET', $path); $crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for findPetsByTags not implemented');
} }
/** /**
@@ -148,7 +149,7 @@ class PetApiInterfaceTest extends WebTestCase
* Find pet by ID. * Find pet by ID.
* *
*/ */
public function testGetPetById() public function testGetPetById(): void
{ {
$client = self::$client; $client = self::$client;
@@ -158,6 +159,7 @@ class PetApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path); $crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for getPetById not implemented');
} }
/** /**
@@ -166,13 +168,14 @@ class PetApiInterfaceTest extends WebTestCase
* Update an existing pet. * Update an existing pet.
* *
*/ */
public function testUpdatePet() public function testUpdatePet(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/pet'; $path = '/pet';
$crawler = $client->request('PUT', $path, [], [], ['CONTENT_TYPE' => 'application/json']); $crawler = $client->request('PUT', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for updatePet not implemented');
} }
/** /**
@@ -181,7 +184,7 @@ class PetApiInterfaceTest extends WebTestCase
* Updates a pet in the store with form data. * Updates a pet in the store with form data.
* *
*/ */
public function testUpdatePetWithForm() public function testUpdatePetWithForm(): void
{ {
$client = self::$client; $client = self::$client;
@@ -191,6 +194,7 @@ class PetApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('POST', $path); $crawler = $client->request('POST', $path);
$this->markTestSkipped('Test for updatePetWithForm not implemented');
} }
/** /**
@@ -199,7 +203,7 @@ class PetApiInterfaceTest extends WebTestCase
* uploads an image. * uploads an image.
* *
*/ */
public function testUploadFile() public function testUploadFile(): void
{ {
$client = self::$client; $client = self::$client;
@@ -209,13 +213,18 @@ class PetApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('POST', $path); $crawler = $client->request('POST', $path);
$this->markTestSkipped('Test for uploadFile not implemented');
} }
protected function genTestData($regexp) /**
* @param string $regexp
* @return mixed
*/
protected function genTestData(string $regexp)
{ {
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp'); $grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar); $compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp); $ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()); $generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast); return $generator->visit($ast);

View File

@@ -28,10 +28,6 @@
namespace OpenAPI\Server\Tests\Api; namespace OpenAPI\Server\Tests\Api;
use OpenAPI\Server\Configuration;
use OpenAPI\Server\ApiClient;
use OpenAPI\Server\ApiException;
use OpenAPI\Server\ObjectSerializer;
use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @package OpenAPI\Server\Tests\Api * @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Api\StoreApiInterface
*/ */
class StoreApiInterfaceTest extends WebTestCase class StoreApiInterfaceTest extends WebTestCase
{ {
@@ -85,7 +82,7 @@ class StoreApiInterfaceTest extends WebTestCase
* Delete purchase order by ID. * Delete purchase order by ID.
* *
*/ */
public function testDeleteOrder() public function testDeleteOrder(): void
{ {
$client = self::$client; $client = self::$client;
@@ -95,6 +92,7 @@ class StoreApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path); $crawler = $client->request('DELETE', $path);
$this->markTestSkipped('Test for deleteOrder not implemented');
} }
/** /**
@@ -103,13 +101,14 @@ class StoreApiInterfaceTest extends WebTestCase
* Returns pet inventories by status. * Returns pet inventories by status.
* *
*/ */
public function testGetInventory() public function testGetInventory(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/store/inventory'; $path = '/store/inventory';
$crawler = $client->request('GET', $path); $crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for getInventory not implemented');
} }
/** /**
@@ -118,7 +117,7 @@ class StoreApiInterfaceTest extends WebTestCase
* Find purchase order by ID. * Find purchase order by ID.
* *
*/ */
public function testGetOrderById() public function testGetOrderById(): void
{ {
$client = self::$client; $client = self::$client;
@@ -128,6 +127,7 @@ class StoreApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path); $crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for getOrderById not implemented');
} }
/** /**
@@ -136,20 +136,25 @@ class StoreApiInterfaceTest extends WebTestCase
* Place an order for a pet. * Place an order for a pet.
* *
*/ */
public function testPlaceOrder() public function testPlaceOrder(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/store/order'; $path = '/store/order';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']); $crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for placeOrder not implemented');
} }
protected function genTestData($regexp) /**
* @param string $regexp
* @return mixed
*/
protected function genTestData(string $regexp)
{ {
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp'); $grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar); $compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp); $ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()); $generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast); return $generator->visit($ast);

View File

@@ -28,10 +28,6 @@
namespace OpenAPI\Server\Tests\Api; namespace OpenAPI\Server\Tests\Api;
use OpenAPI\Server\Configuration;
use OpenAPI\Server\ApiClient;
use OpenAPI\Server\ApiException;
use OpenAPI\Server\ObjectSerializer;
use Symfony\Bundle\FrameworkBundle\KernelBrowser; use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -42,6 +38,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @package OpenAPI\Server\Tests\Api * @package OpenAPI\Server\Tests\Api
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Api\UserApiInterface
*/ */
class UserApiInterfaceTest extends WebTestCase class UserApiInterfaceTest extends WebTestCase
{ {
@@ -85,13 +82,14 @@ class UserApiInterfaceTest extends WebTestCase
* Create user. * Create user.
* *
*/ */
public function testCreateUser() public function testCreateUser(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/user'; $path = '/user';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']); $crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for createUser not implemented');
} }
/** /**
@@ -100,13 +98,14 @@ class UserApiInterfaceTest extends WebTestCase
* Creates list of users with given input array. * Creates list of users with given input array.
* *
*/ */
public function testCreateUsersWithArrayInput() public function testCreateUsersWithArrayInput(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/user/createWithArray'; $path = '/user/createWithArray';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']); $crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for createUsersWithArrayInput not implemented');
} }
/** /**
@@ -115,13 +114,14 @@ class UserApiInterfaceTest extends WebTestCase
* Creates list of users with given input array. * Creates list of users with given input array.
* *
*/ */
public function testCreateUsersWithListInput() public function testCreateUsersWithListInput(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/user/createWithList'; $path = '/user/createWithList';
$crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']); $crawler = $client->request('POST', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for createUsersWithListInput not implemented');
} }
/** /**
@@ -130,7 +130,7 @@ class UserApiInterfaceTest extends WebTestCase
* Delete user. * Delete user.
* *
*/ */
public function testDeleteUser() public function testDeleteUser(): void
{ {
$client = self::$client; $client = self::$client;
@@ -140,6 +140,7 @@ class UserApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('DELETE', $path); $crawler = $client->request('DELETE', $path);
$this->markTestSkipped('Test for deleteUser not implemented');
} }
/** /**
@@ -148,7 +149,7 @@ class UserApiInterfaceTest extends WebTestCase
* Get user by user name. * Get user by user name.
* *
*/ */
public function testGetUserByName() public function testGetUserByName(): void
{ {
$client = self::$client; $client = self::$client;
@@ -158,6 +159,7 @@ class UserApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('GET', $path); $crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for getUserByName not implemented');
} }
/** /**
@@ -166,13 +168,14 @@ class UserApiInterfaceTest extends WebTestCase
* Logs user into the system. * Logs user into the system.
* *
*/ */
public function testLoginUser() public function testLoginUser(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/user/login'; $path = '/user/login';
$crawler = $client->request('GET', $path); $crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for loginUser not implemented');
} }
/** /**
@@ -181,13 +184,14 @@ class UserApiInterfaceTest extends WebTestCase
* Logs out current logged in user session. * Logs out current logged in user session.
* *
*/ */
public function testLogoutUser() public function testLogoutUser(): void
{ {
$client = self::$client; $client = self::$client;
$path = '/user/logout'; $path = '/user/logout';
$crawler = $client->request('GET', $path); $crawler = $client->request('GET', $path);
$this->markTestSkipped('Test for logoutUser not implemented');
} }
/** /**
@@ -196,7 +200,7 @@ class UserApiInterfaceTest extends WebTestCase
* Updated user. * Updated user.
* *
*/ */
public function testUpdateUser() public function testUpdateUser(): void
{ {
$client = self::$client; $client = self::$client;
@@ -206,13 +210,18 @@ class UserApiInterfaceTest extends WebTestCase
$path = str_replace($pattern, $data, $path); $path = str_replace($pattern, $data, $path);
$crawler = $client->request('PUT', $path, [], [], ['CONTENT_TYPE' => 'application/json']); $crawler = $client->request('PUT', $path, [], [], ['CONTENT_TYPE' => 'application/json']);
$this->markTestSkipped('Test for updateUser not implemented');
} }
protected function genTestData($regexp) /**
* @param string $regexp
* @return mixed
*/
protected function genTestData(string $regexp)
{ {
$grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp'); $grammar = new \Hoa\File\Read('hoa://Library/Regex/Grammar.pp');
$compiler = \Hoa\Compiler\Llk\Llk::load($grammar); $compiler = \Hoa\Compiler\Llk\Llk::load($grammar);
$ast = $compiler->parse($regexp); $ast = $compiler->parse($regexp);
$generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random()); $generator = new \Hoa\Regex\Visitor\Isotropic(new \Hoa\Math\Sampler\Random());
return $generator->visit($ast); return $generator->visit($ast);

View File

@@ -8,15 +8,20 @@ use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel class AppKernel extends Kernel
{ {
/**
* @inheritDoc
*/
public function registerBundles(): iterable public function registerBundles(): iterable
{ {
$bundles = array( return [
new FrameworkBundle() new FrameworkBundle(),
); ];
return $bundles;
} }
/**
* @inheritDoc
* @throws \Exception
*/
public function registerContainerConfiguration(LoaderInterface $loader) public function registerContainerConfiguration(LoaderInterface $loader)
{ {
$loader->load(__DIR__.'/test_config.yml'); $loader->load(__DIR__.'/test_config.yml');

View File

@@ -43,21 +43,16 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class ControllerTest extends TestCase class ControllerTest extends TestCase
{ {
/** /**
* Tests isContentTypeAllowed static method. * Tests isContentTypeAllowed static method.
* *
* @param string $contentType
* @param array $consumes
* @param bool $expectedReturn
*
* @covers ::isContentTypeAllowed * @covers ::isContentTypeAllowed
* @dataProvider provideArgumentsForIsContentTypeAllowed * @dataProvider dataProviderIsContentTypeAllowed
*/ */
public function testIsContentTypeAllowed($contentType, array $consumes, $expectedReturn) public function testIsContentTypeAllowed(?string $contentType, array $consumes, bool $expectedReturn): void
{ {
$request = new Request(); $request = new Request();
$request->headers->set('CONTENT_TYPE', $contentType, true);// last one argument overrides header $request->headers->set('CONTENT_TYPE', $contentType);// last one argument overrides header
$this->assertSame( $this->assertSame(
$expectedReturn, $expectedReturn,
Controller::isContentTypeAllowed($request, $consumes), Controller::isContentTypeAllowed($request, $consumes),
@@ -70,7 +65,7 @@ class ControllerTest extends TestCase
); );
} }
public function provideArgumentsForIsContentTypeAllowed() public function dataProviderIsContentTypeAllowed(): array
{ {
return [ return [
'usual JSON content type' => [ 'usual JSON content type' => [

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model; namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
* ApiResponseTest Class Doc Comment * ApiResponseTest Class Doc Comment
* *
* @category Class */ * @category Class
// * @description Describes the result of uploading an image resource * @description Describes the result of uploading an image resource
/**
* @package OpenAPI\Server\Tests\Model * @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\ApiResponse
*/ */
class ApiResponseTest extends TestCase class ApiResponseTest extends TestCase
{ {
protected ApiResponse|MockObject $object;
/** /**
* Setup before running any test case * Setup before running any test case
@@ -56,6 +58,7 @@ class ApiResponseTest extends TestCase
*/ */
public function setUp(): void public function setUp(): void
{ {
$this->object = $this->getMockBuilder(ApiResponse::class)->getMockForAbstractClass();
} }
/** /**
@@ -73,31 +76,45 @@ class ApiResponseTest extends TestCase
} }
/** /**
* Test "ApiResponse" * @group integration
* @small
*/ */
public function testApiResponse() public function testTestClassExists(): void
{ {
$testApiResponse = new ApiResponse(); $this->assertTrue(class_exists(ApiResponse::class));
$this->assertInstanceOf(ApiResponse::class, $this->object);
} }
/** /**
* Test attribute "code" * Test attribute "code"
*
* @group unit
* @small
*/ */
public function testPropertyCode() public function testPropertyCode(): void
{ {
$this->markTestSkipped('Test for property code not implemented');
} }
/** /**
* Test attribute "type" * Test attribute "type"
*
* @group unit
* @small
*/ */
public function testPropertyType() public function testPropertyType(): void
{ {
$this->markTestSkipped('Test for property type not implemented');
} }
/** /**
* Test attribute "message" * Test attribute "message"
*
* @group unit
* @small
*/ */
public function testPropertyMessage() public function testPropertyMessage(): void
{ {
$this->markTestSkipped('Test for property message not implemented');
} }
} }

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model; namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
* CategoryTest Class Doc Comment * CategoryTest Class Doc Comment
* *
* @category Class */ * @category Class
// * @description A category for a pet * @description A category for a pet
/**
* @package OpenAPI\Server\Tests\Model * @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\Category
*/ */
class CategoryTest extends TestCase class CategoryTest extends TestCase
{ {
protected Category|MockObject $object;
/** /**
* Setup before running any test case * Setup before running any test case
@@ -56,6 +58,7 @@ class CategoryTest extends TestCase
*/ */
public function setUp(): void public function setUp(): void
{ {
$this->object = $this->getMockBuilder(Category::class)->getMockForAbstractClass();
} }
/** /**
@@ -73,24 +76,34 @@ class CategoryTest extends TestCase
} }
/** /**
* Test "Category" * @group integration
* @small
*/ */
public function testCategory() public function testTestClassExists(): void
{ {
$testCategory = new Category(); $this->assertTrue(class_exists(Category::class));
$this->assertInstanceOf(Category::class, $this->object);
} }
/** /**
* Test attribute "id" * Test attribute "id"
*
* @group unit
* @small
*/ */
public function testPropertyId() public function testPropertyId(): void
{ {
$this->markTestSkipped('Test for property id not implemented');
} }
/** /**
* Test attribute "name" * Test attribute "name"
*
* @group unit
* @small
*/ */
public function testPropertyName() public function testPropertyName(): void
{ {
$this->markTestSkipped('Test for property name not implemented');
} }
} }

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model; namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
* OrderTest Class Doc Comment * OrderTest Class Doc Comment
* *
* @category Class */ * @category Class
// * @description An order for a pets from the pet store * @description An order for a pets from the pet store
/**
* @package OpenAPI\Server\Tests\Model * @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\Order
*/ */
class OrderTest extends TestCase class OrderTest extends TestCase
{ {
protected Order|MockObject $object;
/** /**
* Setup before running any test case * Setup before running any test case
@@ -56,6 +58,7 @@ class OrderTest extends TestCase
*/ */
public function setUp(): void public function setUp(): void
{ {
$this->object = $this->getMockBuilder(Order::class)->getMockForAbstractClass();
} }
/** /**
@@ -73,52 +76,78 @@ class OrderTest extends TestCase
} }
/** /**
* Test "Order" * @group integration
* @small
*/ */
public function testOrder() public function testTestClassExists(): void
{ {
$testOrder = new Order(); $this->assertTrue(class_exists(Order::class));
$this->assertInstanceOf(Order::class, $this->object);
} }
/** /**
* Test attribute "id" * Test attribute "id"
*
* @group unit
* @small
*/ */
public function testPropertyId() public function testPropertyId(): void
{ {
$this->markTestSkipped('Test for property id not implemented');
} }
/** /**
* Test attribute "petId" * Test attribute "petId"
*
* @group unit
* @small
*/ */
public function testPropertyPetId() public function testPropertyPetId(): void
{ {
$this->markTestSkipped('Test for property petId not implemented');
} }
/** /**
* Test attribute "quantity" * Test attribute "quantity"
*
* @group unit
* @small
*/ */
public function testPropertyQuantity() public function testPropertyQuantity(): void
{ {
$this->markTestSkipped('Test for property quantity not implemented');
} }
/** /**
* Test attribute "shipDate" * Test attribute "shipDate"
*
* @group unit
* @small
*/ */
public function testPropertyShipDate() public function testPropertyShipDate(): void
{ {
$this->markTestSkipped('Test for property shipDate not implemented');
} }
/** /**
* Test attribute "status" * Test attribute "status"
*
* @group unit
* @small
*/ */
public function testPropertyStatus() public function testPropertyStatus(): void
{ {
$this->markTestSkipped('Test for property status not implemented');
} }
/** /**
* Test attribute "complete" * Test attribute "complete"
*
* @group unit
* @small
*/ */
public function testPropertyComplete() public function testPropertyComplete(): void
{ {
$this->markTestSkipped('Test for property complete not implemented');
} }
} }

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model; namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
* PetTest Class Doc Comment * PetTest Class Doc Comment
* *
* @category Class */ * @category Class
// * @description A pet for sale in the pet store * @description A pet for sale in the pet store
/**
* @package OpenAPI\Server\Tests\Model * @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\Pet
*/ */
class PetTest extends TestCase class PetTest extends TestCase
{ {
protected Pet|MockObject $object;
/** /**
* Setup before running any test case * Setup before running any test case
@@ -56,6 +58,7 @@ class PetTest extends TestCase
*/ */
public function setUp(): void public function setUp(): void
{ {
$this->object = $this->getMockBuilder(Pet::class)->getMockForAbstractClass();
} }
/** /**
@@ -73,52 +76,78 @@ class PetTest extends TestCase
} }
/** /**
* Test "Pet" * @group integration
* @small
*/ */
public function testPet() public function testTestClassExists(): void
{ {
$testPet = new Pet(); $this->assertTrue(class_exists(Pet::class));
$this->assertInstanceOf(Pet::class, $this->object);
} }
/** /**
* Test attribute "id" * Test attribute "id"
*
* @group unit
* @small
*/ */
public function testPropertyId() public function testPropertyId(): void
{ {
$this->markTestSkipped('Test for property id not implemented');
} }
/** /**
* Test attribute "category" * Test attribute "category"
*
* @group unit
* @small
*/ */
public function testPropertyCategory() public function testPropertyCategory(): void
{ {
$this->markTestSkipped('Test for property category not implemented');
} }
/** /**
* Test attribute "name" * Test attribute "name"
*
* @group unit
* @small
*/ */
public function testPropertyName() public function testPropertyName(): void
{ {
$this->markTestSkipped('Test for property name not implemented');
} }
/** /**
* Test attribute "photoUrls" * Test attribute "photoUrls"
*
* @group unit
* @small
*/ */
public function testPropertyPhotoUrls() public function testPropertyPhotoUrls(): void
{ {
$this->markTestSkipped('Test for property photoUrls not implemented');
} }
/** /**
* Test attribute "tags" * Test attribute "tags"
*
* @group unit
* @small
*/ */
public function testPropertyTags() public function testPropertyTags(): void
{ {
$this->markTestSkipped('Test for property tags not implemented');
} }
/** /**
* Test attribute "status" * Test attribute "status"
*
* @group unit
* @small
*/ */
public function testPropertyStatus() public function testPropertyStatus(): void
{ {
$this->markTestSkipped('Test for property status not implemented');
} }
} }

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model; namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
* TagTest Class Doc Comment * TagTest Class Doc Comment
* *
* @category Class */ * @category Class
// * @description A tag for a pet * @description A tag for a pet
/**
* @package OpenAPI\Server\Tests\Model * @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\Tag
*/ */
class TagTest extends TestCase class TagTest extends TestCase
{ {
protected Tag|MockObject $object;
/** /**
* Setup before running any test case * Setup before running any test case
@@ -56,6 +58,7 @@ class TagTest extends TestCase
*/ */
public function setUp(): void public function setUp(): void
{ {
$this->object = $this->getMockBuilder(Tag::class)->getMockForAbstractClass();
} }
/** /**
@@ -73,24 +76,34 @@ class TagTest extends TestCase
} }
/** /**
* Test "Tag" * @group integration
* @small
*/ */
public function testTag() public function testTestClassExists(): void
{ {
$testTag = new Tag(); $this->assertTrue(class_exists(Tag::class));
$this->assertInstanceOf(Tag::class, $this->object);
} }
/** /**
* Test attribute "id" * Test attribute "id"
*
* @group unit
* @small
*/ */
public function testPropertyId() public function testPropertyId(): void
{ {
$this->markTestSkipped('Test for property id not implemented');
} }
/** /**
* Test attribute "name" * Test attribute "name"
*
* @group unit
* @small
*/ */
public function testPropertyName() public function testPropertyName(): void
{ {
$this->markTestSkipped('Test for property name not implemented');
} }
} }

View File

@@ -29,20 +29,22 @@
namespace OpenAPI\Server\Model; namespace OpenAPI\Server\Model;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
* UserTest Class Doc Comment * UserTest Class Doc Comment
* *
* @category Class */ * @category Class
// * @description A User who is purchasing from the pet store * @description A User who is purchasing from the pet store
/**
* @package OpenAPI\Server\Tests\Model * @package OpenAPI\Server\Tests\Model
* @author openapi-generator contributors * @author openapi-generator contributors
* @link https://github.com/openapitools/openapi-generator * @link https://github.com/openapitools/openapi-generator
* @coversDefaultClass \OpenAPI\Server\Model\User
*/ */
class UserTest extends TestCase class UserTest extends TestCase
{ {
protected User|MockObject $object;
/** /**
* Setup before running any test case * Setup before running any test case
@@ -56,6 +58,7 @@ class UserTest extends TestCase
*/ */
public function setUp(): void public function setUp(): void
{ {
$this->object = $this->getMockBuilder(User::class)->getMockForAbstractClass();
} }
/** /**
@@ -73,66 +76,100 @@ class UserTest extends TestCase
} }
/** /**
* Test "User" * @group integration
* @small
*/ */
public function testUser() public function testTestClassExists(): void
{ {
$testUser = new User(); $this->assertTrue(class_exists(User::class));
$this->assertInstanceOf(User::class, $this->object);
} }
/** /**
* Test attribute "id" * Test attribute "id"
*
* @group unit
* @small
*/ */
public function testPropertyId() public function testPropertyId(): void
{ {
$this->markTestSkipped('Test for property id not implemented');
} }
/** /**
* Test attribute "username" * Test attribute "username"
*
* @group unit
* @small
*/ */
public function testPropertyUsername() public function testPropertyUsername(): void
{ {
$this->markTestSkipped('Test for property username not implemented');
} }
/** /**
* Test attribute "firstName" * Test attribute "firstName"
*
* @group unit
* @small
*/ */
public function testPropertyFirstName() public function testPropertyFirstName(): void
{ {
$this->markTestSkipped('Test for property firstName not implemented');
} }
/** /**
* Test attribute "lastName" * Test attribute "lastName"
*
* @group unit
* @small
*/ */
public function testPropertyLastName() public function testPropertyLastName(): void
{ {
$this->markTestSkipped('Test for property lastName not implemented');
} }
/** /**
* Test attribute "email" * Test attribute "email"
*
* @group unit
* @small
*/ */
public function testPropertyEmail() public function testPropertyEmail(): void
{ {
$this->markTestSkipped('Test for property email not implemented');
} }
/** /**
* Test attribute "password" * Test attribute "password"
*
* @group unit
* @small
*/ */
public function testPropertyPassword() public function testPropertyPassword(): void
{ {
$this->markTestSkipped('Test for property password not implemented');
} }
/** /**
* Test attribute "phone" * Test attribute "phone"
*
* @group unit
* @small
*/ */
public function testPropertyPhone() public function testPropertyPhone(): void
{ {
$this->markTestSkipped('Test for property phone not implemented');
} }
/** /**
* Test attribute "userStatus" * Test attribute "userStatus"
*
* @group unit
* @small
*/ */
public function testPropertyUserStatus() public function testPropertyUserStatus(): void
{ {
$this->markTestSkipped('Test for property userStatus not implemented');
} }
} }

View File

@@ -5,4 +5,4 @@ framework:
secret: "testsecret" secret: "testsecret"
test: ~ test: ~
router: router:
resource: "%kernel.project_dir%/../Resources/config/routing.yml" resource: "%kernel.project_dir%/Resources/config/routing.yml"

View File

@@ -1,24 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="./vendor/autoload.php"
colors="true" colors="true"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
stopOnFailure="false"> stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">././Api</directory>
<directory suffix=".php">././Model</directory>
<directory suffix=".php">././Controller</directory>
</include>
</coverage>
<testsuites> <testsuites>
<testsuite> <testsuite name="Default test suite">
<directory>./Tests/Api</directory> <directory>./Tests/Api</directory>
<directory>./Tests/Model</directory> <directory>./Tests/Model</directory>
<directory>./Tests/Controller</directory> <directory>./Tests/Controller</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">././Api</directory>
<directory suffix=".php">././Model</directory>
<directory suffix=".php">././Controller</directory>
</whitelist>
</filter>
<php> <php>
<ini name="error_reporting" value="E_ALL" /> <ini name="error_reporting" value="E_ALL" />
<server name="KERNEL_CLASS" value="OpenAPI\Server\Tests\AppKernel" /> <server name="KERNEL_CLASS" value="OpenAPI\Server\Tests\AppKernel" />