From f49d042fc68cfd3a21f75d148c6ab855c0dbcf84 Mon Sep 17 00:00:00 2001 From: Yoanm Date: Thu, 20 Dec 2018 23:15:15 +0100 Subject: [PATCH] Documentation --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6451b9e..700ed2e 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,54 @@ Symfony bundle for easy JSON-RPC server OpenAPI 3.0.0 documentation +Symfony bundle for [yoanm/jsonrpc-http-server-openapi-doc-sdk](https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk) + ## How to use -   + +Once configured, your project is ready to handle HTTP `GET` request on `/doc/openapi.json` endpoint. Result will be a openapi compatible file. + +See below how to configure it. + +## Configuration + +[Behat demo app configuration folders](./features/demo_app) can be used as examples. + + - Add the bundles in your config/bundles.php file: + ```php + // config/bundles.php + return [ + ... + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Yoanm\SymfonyJsonRpcHttpServer\JsonRpcHttpServerBundle::class => ['all' => true], + Yoanm\SymfonyJsonRpcHttpServerDoc\JsonRpcHttpServerDocBundle::class => ['all' => true], + Yoanm\SymfonyJsonRpcHttpServerOpenAPIDoc\JsonRpcHttpServerOpenAPIDocBundle::class => ['all' => true], + ... + ]; + ``` + + - Configure `yoanm/symfony-jsonrpc-http-server` as described on [yoanm/symfony-jsonrpc-http-server](https://github.com/yoanm/symfony-jsonrpc-http-server) documentation. + + - 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. + + - Query your project at `/doc/openapi.json` endpoint and you will have a OpenAPI json documentation file of your server. + +## Event + +You are able to enhance resulting documentation by listening on `json_rpc_http_server_openapi_doc.array_created` event. + +See below an example of listener service configuration: +```yaml + method_doc_created.listener: + class: Full\Namespace\DocCreatedListener # <-- replace by your class name + tags: + - name: 'kernel.event_listener' + event: 'json_rpc_http_server_openapi_doc.array_created' + method: 'enhanceMethodDoc' # <-- replace by your method name +``` + +You will receive an event of type [`OpenAPIDocCreatedEvent`](./src/Event/OpenAPIDocCreatedEvent.php). + +You can take example on Behat [`DocCreatedListener`](./features/demo_app/src/Listener/DocCreatedListener.php)   ## Contributing See [contributing note](./CONTRIBUTING.md)