mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
9d3c0a8c29
Unified data types [actualType and subType] Updated tests. JMS parsing fixes; updated {Validator,FormType}Parser, FOSRestHandler, and AbstractFormatter, and updated DataTypes enum. Modified dataType checking. Updated tests. Updated DataTypes enum. Quick fix and added doc comments. CS fixes. Refactored FormTypeParser to produce nested parameters. Updated tests accordingly. Logical and CS fixes. Sub-forms and more tests. Logical and CS fixes. Swagger support: created formatter. Configuration and resourcePath logic update. ApiDoc annotation update. Updated formatter and added tests. Parameter formatting. Added tests for SwaggerFormatter. Added option in annotation, and the corresponding logic for parsing the supplied values and processing them in the formatter. Routing update. Updated tests. Removed unused dependency and updated doc comments. Renamed 'responseModels' to 'responseMap' Update the resource filtering and formatting of response messages. Updated check for 200 response model. Ignore data_class and always use form-type to avoid conflicts. Fix: add 'type' even if '' is specified. Refactored responseMap; added parsedResponseMap. Added tests and updated some. Fix: add 'type' even if '' is specified. Initial commit of command. Finished logic for dumping files. Updated doc comment; added license and added more meaningful class comment. Array of models support.
74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the NelmioApiDocBundle.
|
|
*
|
|
* (c) Nelmio <hello@nelm.io>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Nelmio\ApiDocBundle\Formatter;
|
|
|
|
|
|
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
/**
|
|
* Extends SwaggerFormatter which takes into account the request's base URL when generating the documents for direct swagger-ui consumption.
|
|
*
|
|
* @author Bezalel Hermoso <bezalelhermoso@gmail.com>
|
|
*/
|
|
class RequestAwareSwaggerFormatter implements FormatterInterface
|
|
{
|
|
/**
|
|
* @var \Symfony\Component\HttpFoundation\Request
|
|
*/
|
|
protected $request;
|
|
|
|
/**
|
|
* @var SwaggerFormatter
|
|
*/
|
|
protected $formatter;
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @param SwaggerFormatter $formatter
|
|
*/
|
|
public function __construct(Request $request, SwaggerFormatter $formatter)
|
|
{
|
|
$this->request = $request;
|
|
$this->formatter = $formatter;
|
|
}
|
|
|
|
/**
|
|
* Format a collection of documentation data.
|
|
*
|
|
* @param array $collection
|
|
* @param null $resource
|
|
* @internal param $array [ApiDoc] $collection
|
|
* @return string|array
|
|
*/
|
|
public function format(array $collection, $resource = null)
|
|
{
|
|
$result = $this->formatter->format($collection, $resource);
|
|
|
|
if ($resource !== null) {
|
|
$result['basePath'] = $this->request->getBaseUrl() . $result['basePath'];
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* Format documentation data for one route.
|
|
*
|
|
* @param ApiDoc $annotation
|
|
* return string|array
|
|
*/
|
|
public function formatOne(ApiDoc $annotation)
|
|
{
|
|
return $this->formatter->formatOne($annotation);
|
|
}
|
|
} |