Skip to content

Commit ca8530d

Browse files
authored
docs: add guidance for enabling UI route with Flex (#2695)
## Summary - The installation docs only described route registration inside a "not using Flex" note block - Flex users had no indication that the UI route in `config/routes/nelmio_api_doc.yaml` needs to be uncommented to browse the documentation - Restructure the section so all users see the route configuration, with a separate note for non-Flex kernel registration Fixes #2592
1 parent 818f581 commit ca8530d

1 file changed

Lines changed: 38 additions & 46 deletions

File tree

docs/index.rst

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ Open a command console, enter your project directory and execute the following c
3737
3838
By default, only routes under ``/api`` are documented. Update the regexp at ``nelmio_api_doc.areas.path_patterns`` in ``config/packages/nelmio_api_doc.yaml`` to change this policy.
3939

40+
To browse your documentation with a UI, you need to enable a UI route. If you're using **Flex**, the installer created a ``config/routes/nelmio_api_doc.yaml`` file with a JSON route enabled and the UI route commented out. Uncomment the UI of your choice (Swagger UI requires the ``twig`` and ``asset`` packages):
41+
42+
.. code-block:: yaml
43+
44+
# config/routes/nelmio_api_doc.yaml
45+
app.swagger:
46+
path: /api/doc.json
47+
methods: GET
48+
defaults: { _controller: nelmio_api_doc.controller.swagger }
49+
50+
# Uncomment one of the following to enable a documentation UI:
51+
app.swagger_ui:
52+
path: /api/doc
53+
methods: GET
54+
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
55+
56+
# app.redocly:
57+
# path: /api/doc
58+
# methods: GET
59+
# defaults: { _controller: nelmio_api_doc.controller.redocly }
60+
61+
# app.stoplight:
62+
# path: /api/doc
63+
# methods: GET
64+
# defaults: { _controller: nelmio_api_doc.controller.stoplight }
65+
4066
.. note::
4167

4268
If you're not using Flex, then add the bundle to your kernel::
@@ -55,55 +81,21 @@ By default, only routes under ``/api`` are documented. Update the regexp at ``ne
5581
}
5682
}
5783

58-
To browse your documentation with an UI, register one of the following route:
59-
60-
.. code-block:: yaml
61-
62-
# config/routes.yaml
63-
app.swagger_ui:
64-
path: /api/doc
65-
methods: GET
66-
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
67-
68-
.. code-block:: yaml
69-
70-
# config/routes.yaml
71-
app.redocly:
72-
path: /api/doc
73-
methods: GET
74-
defaults: { _controller: nelmio_api_doc.controller.redocly }
75-
76-
.. code-block:: yaml
77-
78-
# config/routes.yaml
79-
app.stoplight:
80-
path: /api/doc
81-
methods: GET
82-
defaults: { _controller: nelmio_api_doc.controller.stoplight }
83-
84-
If you also want to expose it in JSON, register this route:
85-
86-
.. code-block:: yaml
87-
88-
# config/routes.yaml
89-
app.swagger:
90-
path: /api/doc.json
91-
methods: GET
92-
defaults: { _controller: nelmio_api_doc.controller.swagger }
84+
Then register the routes manually in ``config/routes.yaml`` (same format as shown above).
9385

94-
As you just installed the bundle, you'll likely see routes you don't want in
95-
your documentation such as ``/_profiler/``. To fix this, you can filter the
96-
routes that are documented by configuring the bundle:
86+
As you just installed the bundle, you'll likely see routes you don't want in
87+
your documentation such as ``/_profiler/``. To fix this, you can filter the
88+
routes that are documented by configuring the bundle:
9789

98-
.. code-block:: yaml
90+
.. code-block:: yaml
9991
100-
# config/packages/nelmio_api_doc.yaml
101-
nelmio_api_doc:
102-
areas:
103-
path_patterns: # an array of regexps (document only routes under /api, except /api/doc)
104-
- ^/api(?!/doc$)
105-
host_patterns: # document only routes with a host of the form api.*
106-
- ^api\.
92+
# config/packages/nelmio_api_doc.yaml
93+
nelmio_api_doc:
94+
areas:
95+
path_patterns: # an array of regexps (document only routes under /api, except /api/doc)
96+
- ^/api(?!/doc$)
97+
host_patterns: # document only routes with a host of the form api.*
98+
- ^api\.
10799
108100
.. tip::
109101

0 commit comments

Comments
 (0)