Skip to content

Documentation #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,67 @@

SDK to generate Http JSON-RPC server documentation for OpenAPI v3.0.0

See [`yoanm/symfony-jsonrpc-http-server-openapi-doc`](https://github.com/yoanm/symfony-jsonrpc-http-server-openapi-doc) for automatic dependency injection.

## How to use

Create the normalizer :
```php
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ErrorDocNormalizer;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ExternalSchemaListDocNormalizer;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\OperationDocNormalizer;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\RequestDocNormalizer;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ResponseDocNormalizer;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\SchemaTypeNormalizer;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\ShapeNormalizer;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Normalizer\Component\TypeDocNormalizer;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\App\Resolver\DefinitionRefResolver;
use Yoanm\JsonRpcHttpServerOpenAPIDoc\Infra\Normalizer\DocNormalizer;

$shapeNormalizer = new ShapeNormalizer();
$definitionRefResolver = new DefinitionRefResolver();
$typeDocNormalizer = new TypeDocNormalizer(
new SchemaTypeNormalizer()
);

$normalizer = new DocNormalizer(
new ExternalSchemaListDocNormalizer(
$definitionRefResolver,
$typeDocNormalizer,
new ErrorDocNormalizer(
$typeDocNormalizer,
$shapeNormalizer
)
),
new OperationDocNormalizer(
$definitionRefResolver,
new RequestDocNormalizer(
$definitionRefResolver,
$shapeNormalizer
),
new ResponseDocNormalizer(
$definitionRefResolver,
$shapeNormalizer
)
)
);
```

Then you can convert `ServerDoc` or `HttpServerDoc` by doing :
```php
use Yoanm\JsonRpcServerDoc\Domain\Model\ServerDoc;

$serverDoc = new ServerDoc();
// Configure server doc
...
// Add methods documentation
...
// Then normalize
/** @var array $openAPIDoc */
$openAPIDoc = $normalizer->normalize($serverDoc);
```



## Contributing
See [contributing note](./CONTRIBUTING.md)
3 changes: 1 addition & 2 deletions features/bootstrap/DocNormalizerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,9 @@ public function givenLastMethodDocWillHaveACustomErrorDoc()
public function whenINormalizeServerDoc()
{
$shapeNormalizer = new ShapeNormalizer();
$schemaTypeNormalizer = new SchemaTypeNormalizer();
$definitionRefResolver = new DefinitionRefResolver();
$typeDocNormalizer = new TypeDocNormalizer(
$schemaTypeNormalizer
new SchemaTypeNormalizer()
);
$normalizer = new DocNormalizer(
new ExternalSchemaListDocNormalizer(
Expand Down