You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs(openapi): add custom UI template override for Laravel (#2113)
Added documentation on overriding the default OpenAPI UI template.
* docs(serializer): deprecation of annotations and fix broken link (#2118)
- Added detailed documentation about the deprecation of annotations in favor of attributes for Symfony >= 7.0.
- Updated configuration examples for both annotation-based and attribute-based serializers.
- Fixed a broken link to Symfony Flex documentation.
* Merge 3.4 in 4.0 (#2127)
* docs(validation): add missing hook (#1795)
docs: add missing hook in validation.md for "Dynamic validation groups"
* docs(content-negociation): document how to declare an encoder for custom format (#1797)
---------
Co-authored-by: MickaelSchimpf <122897940+MickaelSchimpf@users.noreply.github.com>
Co-authored-by: Nicolas PHILIPPE <nikophil@gmail.com>
* fix(openapi): resolve unsupported blade markdown types by hugoserver
---------
Co-authored-by: MickaelSchimpf <122897940+MickaelSchimpf@users.noreply.github.com>
Co-authored-by: Nicolas PHILIPPE <nikophil@gmail.com>
Copy file name to clipboardExpand all lines: core/content-negotiation.md
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -196,6 +196,19 @@ api_platform:
196
196
myformat: ['application/vnd.myformat']
197
197
```
198
198
199
+
You will also need to declare an encoder which supports the new format:
200
+
201
+
```yaml
202
+
services:
203
+
app.api-platform.myformat.encoder:
204
+
class: ApiPlatform\Serializer\JsonEncoder
205
+
arguments:
206
+
$format: 'myformat'
207
+
# The following lines are only needed if autoconfigure is disabled
208
+
# tags:
209
+
# - { name: 'serializer.encoder' }
210
+
```
211
+
199
212
API Platform will automatically call the serializer with your defined format name as `format` parameter during the deserialization process (`myformat` in the example).
200
213
It will then return the result to the client with the requested MIME type using its built-in responder.
201
214
For non-standard formats, [a vendor, vanity or unregistered MIME type should be used](https://en.wikipedia.org/wiki/Media_type#Vendor_tree).
Copy file name to clipboardExpand all lines: core/openapi.md
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -717,6 +717,10 @@ framework:
717
717
718
718
## Overriding the UI Template
719
719
720
+
You can extend the default UI Template using the Symfony and Laravel instructions below:
721
+
722
+
### Overriding the UI Template using Symfony
723
+
720
724
As described [in the Symfony documentation](https://symfony.com/doc/current/templating/overriding.html), it's possible to override the Twig template that loads Swagger UI and renders the documentation:
721
725
722
726
```twig
@@ -732,6 +736,28 @@ As described [in the Symfony documentation](https://symfony.com/doc/current/temp
732
736
733
737
You may want to copy the [one shipped with API Platform](https://github.com/api-platform/core/blob/main/src/Symfony/Bundle/Resources/views/SwaggerUi/index.html.twig) and customize it.
734
738
739
+
### Overriding the UI Template using Laravel
740
+
741
+
As described [in the Laravel documentation](https://laravel.com/docs/blade#extending-a-layout), it's possible to override the Blade template that loads Swagger UI and renders the documentation:
742
+
743
+
```html
744
+
{# resources/views/swagger-ui.blade.php #}
745
+
<!DOCTYPE html>
746
+
<html>
747
+
<head>
748
+
<meta charset="UTF-8">
749
+
<title>
750
+
@if(isset($title))
751
+
{{ $title }}
752
+
@endif
753
+
My custom template
754
+
</title>
755
+
{# ... #}
756
+
</html>
757
+
```
758
+
759
+
You may want to copy the [one shipped with API Platform](https://github.com/api-platform/core/blob/main/src/Laravel/resources/views/swagger-ui.blade.php) and customize it.
760
+
735
761
## Compatibility Layer with Amazon API Gateway
736
762
737
763
[AWS API Gateway](https://aws.amazon.com/api-gateway/) supports OpenAPI partially, but it [requires some changes](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html).
Copy file name to clipboardExpand all lines: core/serialization.md
+53-5Lines changed: 53 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -49,18 +49,51 @@ to limit the serialization depth.
49
49
Just like other Symfony and API Platform components, the Serializer component can be configured using attributes, XML
50
50
or YAML. Since attributes are easy to understand, we will use them in the following examples.
51
51
52
-
Note: if you aren't using the API Platform distribution, you will need to enable annotation support in the serializer configuration:
52
+
> [!NOTE]
53
+
> If you are not using the API Platform distribution, you need to enable annotation support in the serializer
54
+
> configuration as outlined below, depending on your Symfony version.
55
+
56
+
#### Configuration for Symfony `<= 6.4`
57
+
58
+
##### General Case
59
+
60
+
Add the following configuration to your `framework.yaml` file:
53
61
54
62
```yaml
55
63
# api/config/packages/framework.yaml
56
64
framework:
57
65
serializer: { enable_annotations: true }
58
66
```
59
67
60
-
If you use [Symfony Flex](https://github.com/symfony/flex), just execute `composer req doctrine/annotations` and you are
61
-
all set!
68
+
##### Using Symfony Flex
69
+
70
+
If you use [Symfony Flex](https://github.com/symfony/flex) and Symfony `<= 6.4`, simply run the following command:
71
+
72
+
```console
73
+
composer req doctrine/annotations
74
+
```
75
+
76
+
You're all set!
77
+
78
+
#### Configuration for Symfony `>= 7.0`
79
+
80
+
If you are using Symfony >= 7.0, [annotations have been replaced by attributes](https://www.doctrine-project.org/2022/11/04/annotations-to-attributes.html).
81
+
82
+
Update your configuration as follows:
83
+
84
+
```diff
85
+
# api/config/packages/framework.yaml
86
+
87
+
framework:
88
+
- serializer: { enable_annotations: true }
89
+
+ serializer: { enable_attributes: true }
90
+
```
91
+
92
+
#### Additional Syntax Configuration for All Versions
93
+
94
+
If you want to use YAML or XML for serialization, add the mapping path to the serializer configuration:
62
95
63
-
If you want to use YAML or XML, please add the mapping path in the serializer configuration:
0 commit comments