|
9 | 9 |
|
10 | 10 | Symfony bundle for easy JSON-RPC server OpenAPI 3.0.0 documentation |
11 | 11 |
|
| 12 | +Symfony bundle for [yoanm/jsonrpc-http-server-openapi-doc-sdk](https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk) |
| 13 | + |
12 | 14 | ## How to use |
13 | | - |
| 15 | + |
| 16 | +Once configured, your project is ready to handle HTTP `GET` request on `/doc/openapi.json` endpoint. Result will be a openapi compatible file. |
| 17 | + |
| 18 | +See below how to configure it. |
| 19 | + |
| 20 | +## Configuration |
| 21 | + |
| 22 | +[Behat demo app configuration folders](./features/demo_app) can be used as examples. |
| 23 | + |
| 24 | + - Add the bundles in your config/bundles.php file: |
| 25 | + ```php |
| 26 | + // config/bundles.php |
| 27 | + return [ |
| 28 | + ... |
| 29 | + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], |
| 30 | + Yoanm\SymfonyJsonRpcHttpServer\JsonRpcHttpServerBundle::class => ['all' => true], |
| 31 | + Yoanm\SymfonyJsonRpcHttpServerDoc\JsonRpcHttpServerDocBundle::class => ['all' => true], |
| 32 | + Yoanm\SymfonyJsonRpcHttpServerOpenAPIDoc\JsonRpcHttpServerOpenAPIDocBundle::class => ['all' => true], |
| 33 | + ... |
| 34 | + ]; |
| 35 | + ``` |
| 36 | + |
| 37 | + - Configure `yoanm/symfony-jsonrpc-http-server` as described on [yoanm/symfony-jsonrpc-http-server](https://github.com/yoanm/symfony-jsonrpc-http-server) documentation. |
| 38 | + |
| 39 | + - Configure `yoanm/symfony-jsonrpc-http-server-doc` as described on [yoanm/symfony-jsonrpc-http-server-doc](https://github.com/yoanm/symfony-jsonrpc-http-server-doc) documentation. |
| 40 | + |
| 41 | + - Query your project at `/doc/openapi.json` endpoint and you will have a OpenAPI json documentation file of your server. |
| 42 | + |
| 43 | +## Event |
| 44 | + |
| 45 | +You are able to enhance resulting documentation by listening on `json_rpc_http_server_openapi_doc.array_created` event. |
| 46 | + |
| 47 | +See below an example of listener service configuration: |
| 48 | +```yaml |
| 49 | + method_doc_created.listener: |
| 50 | + class: Full\Namespace\DocCreatedListener # <-- replace by your class name |
| 51 | + tags: |
| 52 | + - name: 'kernel.event_listener' |
| 53 | + event: 'json_rpc_http_server_openapi_doc.array_created' |
| 54 | + method: 'enhanceMethodDoc' # <-- replace by your method name |
| 55 | +``` |
| 56 | +
|
| 57 | +You will receive an event of type [`OpenAPIDocCreatedEvent`](./src/Event/OpenAPIDocCreatedEvent.php). |
| 58 | + |
| 59 | +You can take example on Behat [`DocCreatedListener`](./features/demo_app/src/Listener/DocCreatedListener.php) |
14 | 60 |
|
15 | 61 | ## Contributing |
16 | 62 | See [contributing note](./CONTRIBUTING.md) |
0 commit comments