mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Fix 8c9b8331d066269d48ca374280937be264767ee6
* tests * CS
This commit is contained in:
parent
8c9b8331d0
commit
2fd3f33ad8
@ -366,7 +366,7 @@ class ApiDoc
|
||||
$data['statusCodes'] = $statusCodes;
|
||||
}
|
||||
|
||||
if($section = $this->section) {
|
||||
if ($section = $this->section) {
|
||||
$data['section'] = $section;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ abstract class AbstractFormatter implements FormatterInterface
|
||||
foreach ($array as $section => $resources) {
|
||||
foreach ($resources as $path => $annotations) {
|
||||
foreach ($annotations as $annotation) {
|
||||
if($section) {
|
||||
if ($section) {
|
||||
$processedCollection[$section][$path][] = $this->processAnnotation($annotation);
|
||||
} else {
|
||||
$processedCollection['_others'][$path][] = $this->processAnnotation($annotation);
|
||||
@ -143,7 +143,8 @@ abstract class AbstractFormatter implements FormatterInterface
|
||||
}
|
||||
}
|
||||
|
||||
ksort($processedCollection);
|
||||
ksort($processedCollection);
|
||||
|
||||
return $processedCollection;
|
||||
}
|
||||
}
|
||||
|
@ -111,21 +111,31 @@ class MarkdownFormatter extends AbstractFormatter
|
||||
protected function render(array $collection)
|
||||
{
|
||||
$markdown = '';
|
||||
foreach ($collection as $resource => $arrayOfData) {
|
||||
$markdown .= $this->renderResourceSection($resource, $arrayOfData);
|
||||
foreach ($collection as $section => $resources) {
|
||||
$markdown .= $this->renderResourceSection($section, $resources);
|
||||
$markdown .= "\n";
|
||||
}
|
||||
|
||||
return trim($markdown);
|
||||
}
|
||||
|
||||
private function renderResourceSection($resource, array $arrayOfData)
|
||||
private function renderResourceSection($section, array $resources)
|
||||
{
|
||||
$markdown = sprintf("# %s #\n\n", $resource);
|
||||
if ('_others' !== $section) {
|
||||
$markdown = sprintf("# %s #\n\n", $section);
|
||||
}
|
||||
|
||||
foreach ($arrayOfData as $data) {
|
||||
$markdown .= $this->renderOne($data);
|
||||
$markdown .= "\n";
|
||||
foreach ($resources as $resource => $methods) {
|
||||
if ('_others' === $section && 'others' !== $resource) {
|
||||
$markdown = sprintf("## %s ##\n\n", $resource);
|
||||
} elseif ('others' !== $resource) {
|
||||
$markdown = sprintf("## %s ##\n\n", $resource);
|
||||
}
|
||||
|
||||
foreach ($methods as $method) {
|
||||
$markdown .= $this->renderOne($method);
|
||||
$markdown .= "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
|
@ -29,6 +29,6 @@
|
||||
{% endfor %}
|
||||
{% if section != '_others' %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endblock content %}
|
||||
|
@ -26,7 +26,7 @@ class MarkdownFormatterTest extends WebTestCase
|
||||
$result = $container->get('nelmio_api_doc.formatter.markdown_formatter')->format($data);
|
||||
|
||||
$expected = <<<MARKDOWN
|
||||
# /tests #
|
||||
## /tests ##
|
||||
|
||||
### `GET` /tests.{_format} ###
|
||||
|
||||
@ -126,9 +126,6 @@ c:
|
||||
* required: true
|
||||
|
||||
|
||||
|
||||
# others #
|
||||
|
||||
### `POST` /another-post ###
|
||||
|
||||
_create another test_
|
||||
|
Loading…
x
Reference in New Issue
Block a user