Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/macpaw/behat-nelmio-describer

Bundle for adding sample responses behat test nelmio to api doc
https://github.com/macpaw/behat-nelmio-describer

behat macpaw nelmio swagger symfony symfony-bundle

Last synced: about 1 month ago
JSON representation

Bundle for adding sample responses behat test nelmio to api doc

Awesome Lists containing this project

README

        

Behat Nelmio Describer
=================================

| Version | Build Status | Code Coverage |
|:---------:|:-------------:|:-----:|
| `master`| [![CI][master Build Status Image]][master Build Status] | [![Coverage Status][master Code Coverage Image]][master Code Coverage] |
| `develop`| [![CI][develop Build Status Image]][develop Build Status] | [![Coverage Status][develop Code Coverage Image]][develop Code Coverage] |

Installation
============

Step 1: Install Bundle
----------------------------------
Open a command console, enter your project directory and execute:

```console
$ composer require macpaw/behat-nelmio-describer
```

This command requires you to have Composer installed globally, as explained
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
of the Composer documentation.

Step 2: Enable the Bundle
----------------------------------
Then, enable the bundle by adding it to the list of registered bundles
in the `app/AppKernel.php` file of your project:

```php
['all' => true]
);

// ...
}

// ...
}
```

Step 3: Create Behat Nelmio Describer Config:
----------------------------------
`config/packages/behat_nelmio_describer.yaml `

Configurating behat nelmio describer

```yaml
behat_nelmio_describer:
behat_test_path:
```

Step 4: Add annotation to controller [OPTIONAL]
=============

```php
")]
final class SomeController extends AbstractController{
// ...
}
```

Step 5: Add annotation to route
=============

```php
", file: '', anchors: [
// array of anchors
])]
public function handleRequestFunction() {
// ...
}
}
```

For each anchor path from config, path from BehatFeaturesPath annotation (optional) and path/filename from BehatFeature annotation are concatenated to find the right feature file.

Additionally, each BehatFeature annotation represents folder in api doc which contains all sample responses defined by anchors.

An example of usage
=============

If your feature file is located in `src/tests/Behat/Features/api/version/route/example.feature`

Configuration

```yaml
behat_nelmio_describer:
behat_test_path: '%kernel.project_dir%/tests/Behat/Features'
```
Used in Controller:
```php

[master Build Status]: https://github.com/macpaw/behat-nelmio-describer/actions?query=workflow%3ACI+branch%3Amaster
[master Build Status Image]: https://github.com/macpaw/behat-nelmio-describer/workflows/CI/badge.svg?branch=master
[develop Build Status]: https://github.com/macpaw/behat-nelmio-describer/actions?query=workflow%3ACI+branch%3Adevelop
[develop Build Status Image]: https://github.com/macpaw/behat-nelmio-describer/workflows/CI/badge.svg?branch=develop
[master Code Coverage]: https://codecov.io/gh/macpaw/behat-nelmio-describer/branch/master
[master Code Coverage Image]: https://img.shields.io/codecov/c/github/macpaw/behat-nelmio-describer/master?logo=codecov
[develop Code Coverage]: https://codecov.io/gh/macpaw/behat-nelmio-describer/branch/develop
[develop Code Coverage Image]: https://img.shields.io/codecov/c/github/macpaw/behat-nelmio-describer/develop?logo=codecov