forked from loafle/openapi-generator-original
* 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
83 lines
1.9 KiB
PHP
83 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* ApiServer
|
|
*
|
|
* PHP version 8.1.1
|
|
*
|
|
* @category Class
|
|
* @package OpenAPI\Server\Api
|
|
* @author OpenAPI Generator team
|
|
* @link https://github.com/openapitools/openapi-generator
|
|
*/
|
|
|
|
/**
|
|
* OpenAPI Petstore
|
|
*
|
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
*
|
|
* The version of the OpenAPI document: 1.0.0
|
|
*
|
|
* Generated by: https://github.com/openapitools/openapi-generator.git
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* NOTE: This class is auto generated by the openapi generator program.
|
|
* https://github.com/openapitools/openapi-generator
|
|
* Do not edit the class manually.
|
|
*/
|
|
|
|
namespace OpenAPI\Server\Api;
|
|
|
|
use Symfony\Component\DependencyInjection\Reference;
|
|
|
|
/**
|
|
* ApiServer Class Doc Comment
|
|
*
|
|
* PHP version 8.1.1
|
|
*
|
|
* @category Class
|
|
* @package OpenAPI\Server\Api
|
|
* @author OpenAPI Generator team
|
|
* @link https://github.com/openapitools/openapi-generator
|
|
*/
|
|
class ApiServer
|
|
{
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private array $apis = array();
|
|
|
|
/**
|
|
* Adds an API handler to the server.
|
|
*
|
|
* @param string $api An API name of the handle
|
|
* @param mixed $handler A handler to set for the given API
|
|
*/
|
|
public function addApiHandler(string $api, $handler): void
|
|
{
|
|
if (isset($this->apis[$api])) {
|
|
throw new \InvalidArgumentException('API has already a handler: '.$api);
|
|
}
|
|
|
|
$this->apis[$api] = $handler;
|
|
}
|
|
|
|
/**
|
|
* Returns an API handler.
|
|
*
|
|
* @param string $api An API name of the handle
|
|
* @return mixed Returns a handler
|
|
* @throws \InvalidArgumentException When no such handler exists
|
|
*/
|
|
public function getApiHandler(string $api)
|
|
{
|
|
if (!isset($this->apis[$api])) {
|
|
throw new \InvalidArgumentException('No handler for '.$api.' implemented.');
|
|
}
|
|
|
|
return $this->apis[$api];
|
|
}
|
|
}
|