{"id":16668360,"url":"https://github.com/kielabokkie/jsonapi-behat-extension","last_synced_at":"2025-07-01T11:40:05.274Z","repository":{"id":34316072,"uuid":"38233778","full_name":"kielabokkie/jsonapi-behat-extension","owner":"kielabokkie","description":"Extension for Behat to test RESTful JSON APIs with support for OAuth","archived":false,"fork":false,"pushed_at":"2022-06-29T08:13:22.000Z","size":62,"stargazers_count":15,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-01T10:14:36.994Z","etag":null,"topics":["behat","behat-extension","json-apis","oauth","testing"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kielabokkie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-29T07:29:56.000Z","updated_at":"2022-06-29T08:02:35.000Z","dependencies_parsed_at":"2022-07-15T17:17:10.641Z","dependency_job_id":null,"html_url":"https://github.com/kielabokkie/jsonapi-behat-extension","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/kielabokkie/jsonapi-behat-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fjsonapi-behat-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fjsonapi-behat-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fjsonapi-behat-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fjsonapi-behat-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kielabokkie","download_url":"https://codeload.github.com/kielabokkie/jsonapi-behat-extension/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fjsonapi-behat-extension/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262954362,"owners_count":23390404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["behat","behat-extension","json-apis","oauth","testing"],"created_at":"2024-10-12T11:24:44.587Z","updated_at":"2025-07-01T11:40:05.132Z","avatar_url":"https://github.com/kielabokkie.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON API Behat Extension\n\n[![Author](http://img.shields.io/badge/follow-@kielabokkie-blue.svg?logo=twitter\u0026style=flat-square)](https://twitter.com/kielabokkie)\n[![Packagist Version](https://img.shields.io/packagist/v/kielabokkie/jsonapi-behat-extension.svg?style=flat-square)](https://packagist.org/packages/kielabokkie/jsonapi-behat-extension)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n\n\nThe JSON API Behat Extension provides step definitions for common testing scenarios specific to JSON APIs. It comes with easy ways to handle authentication through OAuth.\n\n## Requirements\n\n* PHP \u003e= 5.4\n\n| PHP | Package Version |\n|-----|-----------------|\n| 5.4 | v3.0.0          |\n| 8.x | v4.0+           |\n\n## Installation\n\nRecommended installation is by running the composer require command. This will install the latest stable version of this extension.\n\n    composer require kielabokkie/jsonapi-behat-extension --dev\n\n## Configuration\n\nTo use this extension you will have to add it under the `extensions` in your `behat.yml` file.\n\n    default:\n        extensions:\n            Kielabokkie\\BehatJsonApi: ~\n\n### Default parameters\n\nOut of the box this extension has the following default parameters:\n\n| parameter                                        | value                 |\n|--------------------------------------------------|-----------------------|\n| base_url                                         | http://localhost:8000 |\n| oauth_uri                                        | /v1/oauth/token       |\n| oauth_client_id                                  | testclient            |\n| oauth_client_secret                              | testsecret            |\n| oauth_use_bearer_token                           | false                 |\n| oauth_password_grant_requires_client_credentials | false                 |\n\nYou can overwrite any of these parameters in the `behat.yml` file as needed.\n\n    default:\n        extensions:\n            Kielabokkie\\BehatJsonApi:\n                base_url: http://api.yourapp.dev\n                parameters:\n                    oauth:\n                        uri: /v1/oauth/token\n                        client_id: myClientId\n                        client_secret: myClientSecret\n                        use_bearer_token: true\n                        password_grant_requires_client_credentials: true\n\n\n### Optional parameters\n\nTo avoid having to use OAuth to retrieve an access token for each API call you can also specify an optional `access_token` in the parameters:\n\n    default:\n        extensions:\n            Kielabokkie\\BehatJsonApi:\n                parameters:\n                    access_token: 90dabed99acef998fd3e35280f2a0a3c30c00c8d\n\n## Usage\n\nTo use the step definitions provided by this extension just load the context class in your suites:\n\n```yaml\ndefault:\n  suites:\n    default:\n      contexts:\n        - Kielabokkie\\BehatJsonApi\\Context\\JsonApiContext\n```\nYou will then have access to the following step definitions:\n\n    @Given I use the access token\n    @Given I use access token :token\n    @Given I oauth with :username and :password\n    @Given I oauth with :username and :password and scope :scope\n    @Given I oauth using the client credentials grant\n    @Given I oauth using the client credentials grant with scope :scope\n    @Given I oauth using the client credentials grant with :id and :secret\n    @Given I oauth using the client credentials grant with :id and :secret and scope :scope\n    @Given I add a :header header with the value :value\n    @Given I have the payload:\n    @When /^I request \"(GET|PUT|PATCH|POST|DELETE) ([^\"]*)\"$/\n    @Then I get a :statuscode response\n    @Then scope into the :scope property\n    @Then scope into the first :scope element\n    @Then the structure matches:\n    @Then the :field property is an object\n    @Then the :field property is an array\n    @Then the :field property is an array with :count items\n    @Then the :field property is an empty array\n    @Then the :field property is an integer\n    @Then the :field property is a integer equaling/equalling :expected\n    @Then the :field property is a string\n    @Then the :field property is a string equaling/equalling :expected\n    @Then the :field property is a boolean\n    @Then the :field property is a boolean equaling/equalling :expected\n    @Then /^echo last request$/\n    @Then /^echo last response$\n\nNote: The last two definitions are for debugging purposes and only show output when you use the `pretty` formatting option of Behat, i.e. `./vendor/bin/behat -f pretty`.\n\nTo get a list of all available step definitions including examples you can run the following command:\n\n    $ vendor/bin/behat -di\n\n### Override the base url\n\nIn some cases you might want to override the base url for a specific suite. Below is an example of a `behat.yml` file. Here the custom url `http://hooks.yourapp.dev` is passed to the FeatureContext under the hooks suite.\n\n    default:\n        autoload:\n            - %paths.base%/tests/Behat/features/bootstrap\n        suites:\n            api:\n                paths:\n                    - %paths.base%/tests/Behat/features/api\n                contexts:\n                    - Kielabokkie\\BehatJsonApi\\Context\\JsonApiContext: ~\n            hooks:\n                paths:\n                    - %paths.base%/tests/Behat/features/hooks\n                contexts:\n                    - Kielabokkie\\BehatJsonApi\\Context\\JsonApiContext:\n                        - http://hooks.yourapp.dev\n        extensions:\n            Kielabokkie\\BehatJsonApi: ~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkielabokkie%2Fjsonapi-behat-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkielabokkie%2Fjsonapi-behat-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkielabokkie%2Fjsonapi-behat-extension/lists"}