SF4 Nelmio В спецификации не определены операции - PullRequest
0 голосов
/ 17 октября 2019

Я установил swagger на проект Symfony 4, но он ничего не показывает. У меня появляется сообщение «В spec! Не определены операции!». Я поставил конфигурацию ниже

nelmio_api_doc:
   documentation:
     info:
        title: My API
        description: This is an awesome app!
        version: 1.0.0
areas: # to filter documented areas
    path_patterns: # an array of regexps
        - ^/api(?!/doc$)
    host_patterns:
        - ^api\.

rout.yaml

app.swagger_ui:
    path: /api/doc
    methods: GET
    defaults: { _controller: nelmio_api_doc.controller.swagger_ui }

app.swagger: путь: /api/doc.json методы: GET по умолчанию: {_controller: nelmio_api_doc.controller. swagger}

fos_rest.yaml

fos_rest:
param_fetcher_listener: true
view:
    view_response_listener: 'force'
    formats:
        xml:  true
        json: true
    templating_formats:
        html: true
format_listener:
    rules:
        - { path: ^/, priorities: [ json, xml, html ], fallback_format: ~, prefer_extension: true }
allowed_methods_listener: true
access_denied_listener:
     json: true
body_listener: true
disable_csrf_role: ROLE_API

ProductController.php

  /**
 * List of products
 *
 * @Rest\Get("/api/list", name="products")
 * @SWG\Response(
 *     response=200,
 *     description="Returns the list of products",
 *     @SWG\Schema(
 *         type="array")
 *     )
 * )
 * @SWG\Parameter(
 *     name="order",
 *     in="query",
 *     type="string",
 *     description="The field used to order rewards"
 * )
 * @SWG\Tag(name="rewards")
 * @Security(name="Bearer")
 *
 *
 */
public function getProduct()
{
    return $this->json([
        'message' => 'Welcome to your new controller!',
        'path' => 'src/Controller/ProductController.php',
    ]);
}
...