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
Right now it is not possible for psalm to trace headers you set this way, so they will not be validated by psalm.
279
-
Use the `setHeaders` method instead.
279
+
Use the ``setHeaders`` method instead.
280
280
281
281
.. collapse:: Examples
282
282
@@ -525,7 +525,7 @@ What you want to do now is to firstly create the correct parameter annotations a
525
525
The next step is to add the return types.
526
526
This is the most important step to get your API documented.
527
527
528
-
It is best to start with helper methods that are used multiple times like the `formatTodo` method in this example:
528
+
It is best to start with helper methods that are used multiple times like the ``formatTodo`` method in this example:
529
529
530
530
.. code-block:: php
531
531
@@ -537,7 +537,7 @@ It is best to start with helper methods that are used multiple times like the `f
537
537
}
538
538
539
539
Afterwards you can add the return types to all the other methods.
540
-
If two different status codes return the same data structure and headers, you can use the union operator to indicate it: `Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND`.
540
+
If two different status codes return the same data structure and headers, you can use the union operator to indicate it: ``Http::STATUS_BAD_REQUEST|Http::STATUS_NOT_FOUND``.
541
541
542
542
You are required to add a description for every status code returned by the method.
543
543
@@ -600,7 +600,7 @@ How to add response definitions to share type definitions
600
600
601
601
In the previous steps we have been re-using the same data structure multiple times, but it was copied every time.
602
602
This is tedious and error prone, therefore we want to create some shared type definitions.
603
-
Create a new file called `ResponseDefinitions.php` in the `lib` folder of your app.
603
+
Create a new file called ``ResponseDefinitions.php`` in the ``lib`` folder of your app.
604
604
It will only work with that file name at that location.
605
605
606
606
.. code-block:: php
@@ -628,14 +628,14 @@ To import and use the type definition you have to import it in your controller:
628
628
...
629
629
}
630
630
631
-
Now you can replace every occurrence of `array{id: int, title: string, description: ?string, image: ?string}` with `TodoItem`.
631
+
Now you can replace every occurrence of ``array{id: int, title: string, description: ?string, image: ?string}`` with ``TodoItem``.
632
632
633
633
How to handle exceptions
634
634
------------------------
635
635
636
636
Sometimes you want to end with an exception instead of returning a response.
637
637
It is better to not do it, but when migrating existing APIs you might have to deal with exceptions.
638
-
For this example our `update` will throw an exception when the ETag does not match:
638
+
For this example our ``update`` will throw an exception when the ETag does not match:
639
639
640
640
.. code-block:: php
641
641
@@ -670,7 +670,7 @@ How to ignore certain endpoints
670
670
-------------------------------
671
671
672
672
The tool already ignores all the endpoints that are not reachable from the outside, but some apps have reachable endpoints that are not APIs (e.g. serving some HTML).
673
-
To ignore those you can add the `#[IgnoreOpenAPI]` attribute or if you still support PHP 7 the `@IgnoreOpenAPI` annotation to the controller method or the controller class:
673
+
To ignore those you can add the ``#[IgnoreOpenAPI]`` attribute or if you still support PHP 7 the ``@IgnoreOpenAPI`` annotation to the controller method or the controller class:
674
674
675
675
.. code-block:: php
676
676
@@ -726,6 +726,6 @@ The capabilities will automatically appear in the generated specification.
726
726
How to generate the specification
727
727
---------------------------------
728
728
729
-
If you followed the installation instructions for openapi-extractor you can run `composer exec generate-spec` in your apps root folder and you will have a new file called `openapi.json`.
729
+
If you followed the installation instructions for openapi-extractor you can run ``composer exec generate-spec`` in your apps root folder and you will have a new file called ``openapi.json``.
730
730
If the tool fails somewhere it will tell you what is wrong and often times also how to fix the problem.
731
731
Additionally you should run psalm to check for any problems.
0 commit comments