Skip to content

Commit afd6140

Browse files
committed
Merge branch 'master' into 5.x
# Conflicts: # tests/Functional/Configs/annotations.yaml
2 parents 33c3cdd + b306289 commit afd6140

File tree

278 files changed

+811
-721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+811
-721
lines changed

.gitattributes

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.* export-ignore
22
*.md export-ignore
3-
Tests export-ignore
4-
Resources/doc export-ignore
3+
tests export-ignore
4+
docs export-ignore
55
phpunit export-ignore
66
phpunit.xml.dist export-ignore

.symfony.bundle.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ maintained_branches: ["3.x", "master"]
33
current_branch: "master"
44
dev_branch: "master"
55
dev_branch_alias: "4.x"
6-
doc_dir: "Resources/doc/"
6+
doc_dir: "docs/"

CHANGELOG.md

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
CHANGELOG
22
=========
33

4+
4.22.0
5+
-----
6+
* Updated bundle directory structure to recommended file structure as described in https://symfony.com/doc/7.0/bundles/best_practices.html.
7+
8+
It might be necessary to reinstall the assets:
9+
```bash
10+
bin/console assets:install
11+
```
12+
13+
4.21.0
14+
-----
15+
* Added bundle configuration options `nelmio_api_doc.cache.pool` and `nelmio_api_doc.cache.item_id`.
16+
```yml
17+
nelmio_api_doc:
18+
cache:
19+
pool: app.cache
20+
item_id: nelmio_api_doc.docs
21+
```
22+
423
4.20.0
524
-----
625
* Added Redocly as an alternative to Swagger UI. https://github.com/Redocly/redoc.

composer.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,12 @@
7474
},
7575
"autoload": {
7676
"psr-4": {
77-
"Nelmio\\ApiDocBundle\\": ""
78-
},
79-
"exclude-from-classmap": [
80-
"Tests/"
81-
]
77+
"Nelmio\\ApiDocBundle\\": "src/"
78+
}
8279
},
8380
"autoload-dev": {
8481
"psr-4": {
85-
"Nelmio\\ApiDocBundle\\Tests\\": "Tests/"
82+
"Nelmio\\ApiDocBundle\\Tests\\": "tests/"
8683
}
8784
},
8885
"extra": {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+98-98
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,98 @@
1-
Areas
2-
=====
3-
4-
We've already seen that you can configure which routes are documented using ``nelmio_api_doc.areas``:
5-
6-
.. code-block:: yaml
7-
8-
nelmio_api_doc:
9-
areas:
10-
path_patterns: [ ^/api ]
11-
host_patterns: [ ^api\. ]
12-
name_patterns: [ ^api_v1 ]
13-
14-
But in fact, this config option is way more powerful and allows you to split your documentation in several parts.
15-
16-
Configuration
17-
-------------
18-
19-
You can define areas which will each generates a different documentation:
20-
21-
.. code-block:: yaml
22-
23-
nelmio_api_doc:
24-
areas:
25-
default:
26-
path_patterns: [ ^/api ]
27-
host_patterns: [ ^api\. ]
28-
internal:
29-
path_patterns: [ ^/internal ]
30-
commercial:
31-
path_patterns: [ ^/commercial ]
32-
store:
33-
# Includes routes with names containing 'store'
34-
name_patterns: [ store ]
35-
36-
37-
Your main documentation is under the ``default`` area. It's the one shown when accessing ``/api/doc``.
38-
39-
Then update your routing to be able to access your different documentations:
40-
41-
.. code-block:: yaml
42-
43-
# app/config/routing.yaml
44-
app.swagger_ui:
45-
path: /api/doc/{area}
46-
methods: GET
47-
defaults: { _controller: nelmio_api_doc.controller.swagger_ui, area: default }
48-
49-
# With Redocly UI
50-
# app/config/routing.yaml
51-
#app.redocly:
52-
# path: /api/doc/{area}
53-
# methods: GET
54-
# defaults: { _controller: nelmio_api_doc.controller.redocly, area: default }
55-
56-
# To expose them as JSON
57-
#app.swagger.areas:
58-
# path: /api/doc/{area}.json
59-
# methods: GET
60-
# defaults: { _controller: nelmio_api_doc.controller.swagger }
61-
62-
63-
That's all! You can now access ``/api/doc/internal``, ``/api/doc/commercial`` and ``/api/doc/store``.
64-
65-
Use annotations to filter documented routes in each area
66-
--------------------------------------------------------
67-
68-
You can use the `@Areas` annotation inside your controllers to define your routes' areas.
69-
70-
First, you need to define which areas will use the`@Areas` annotations to filter
71-
the routes that should be documented:
72-
73-
.. code-block:: yaml
74-
75-
nelmio_api_doc:
76-
areas:
77-
default:
78-
path_patterns: [ ^/api ]
79-
internal:
80-
with_annotation: true
81-
82-
Then add the annotation before your controller or action::
83-
84-
use Nelmio\Annotations as Nelmio;
85-
86-
/**
87-
* @Nelmio\Areas({"internal"}) => All actions in this controller are documented under the 'internal' area
88-
*/
89-
class MyController
90-
{
91-
/**
92-
* @Nelmio\Areas({"internal"}) => This action is documented under the 'internal' area
93-
*/
94-
public function index()
95-
{
96-
...
97-
}
98-
}
1+
Areas
2+
=====
3+
4+
We've already seen that you can configure which routes are documented using ``nelmio_api_doc.areas``:
5+
6+
.. code-block:: yaml
7+
8+
nelmio_api_doc:
9+
areas:
10+
path_patterns: [ ^/api ]
11+
host_patterns: [ ^api\. ]
12+
name_patterns: [ ^api_v1 ]
13+
14+
But in fact, this config option is way more powerful and allows you to split your documentation in several parts.
15+
16+
Configuration
17+
-------------
18+
19+
You can define areas which will each generates a different documentation:
20+
21+
.. code-block:: yaml
22+
23+
nelmio_api_doc:
24+
areas:
25+
default:
26+
path_patterns: [ ^/api ]
27+
host_patterns: [ ^api\. ]
28+
internal:
29+
path_patterns: [ ^/internal ]
30+
commercial:
31+
path_patterns: [ ^/commercial ]
32+
store:
33+
# Includes routes with names containing 'store'
34+
name_patterns: [ store ]
35+
36+
37+
Your main documentation is under the ``default`` area. It's the one shown when accessing ``/api/doc``.
38+
39+
Then update your routing to be able to access your different documentations:
40+
41+
.. code-block:: yaml
42+
43+
# app/config/routing.yaml
44+
app.swagger_ui:
45+
path: /api/doc/{area}
46+
methods: GET
47+
defaults: { _controller: nelmio_api_doc.controller.swagger_ui, area: default }
48+
49+
# With Redocly UI
50+
# app/config/routing.yaml
51+
#app.redocly:
52+
# path: /api/doc/{area}
53+
# methods: GET
54+
# defaults: { _controller: nelmio_api_doc.controller.redocly, area: default }
55+
56+
# To expose them as JSON
57+
#app.swagger.areas:
58+
# path: /api/doc/{area}.json
59+
# methods: GET
60+
# defaults: { _controller: nelmio_api_doc.controller.swagger }
61+
62+
63+
That's all! You can now access ``/api/doc/internal``, ``/api/doc/commercial`` and ``/api/doc/store``.
64+
65+
Use annotations to filter documented routes in each area
66+
--------------------------------------------------------
67+
68+
You can use the `@Areas` annotation inside your controllers to define your routes' areas.
69+
70+
First, you need to define which areas will use the`@Areas` annotations to filter
71+
the routes that should be documented:
72+
73+
.. code-block:: yaml
74+
75+
nelmio_api_doc:
76+
areas:
77+
default:
78+
path_patterns: [ ^/api ]
79+
internal:
80+
with_annotation: true
81+
82+
Then add the annotation before your controller or action::
83+
84+
use Nelmio\Annotations as Nelmio;
85+
86+
/**
87+
* @Nelmio\Areas({"internal"}) => All actions in this controller are documented under the 'internal' area
88+
*/
89+
class MyController
90+
{
91+
/**
92+
* @Nelmio\Areas({"internal"}) => This action is documented under the 'internal' area
93+
*/
94+
public function index()
95+
{
96+
...
97+
}
98+
}
File renamed without changes.
File renamed without changes.

Resources/doc/faq.rst docs/faq.rst

File renamed without changes.

0 commit comments

Comments
 (0)