{"id":15025695,"url":"https://github.com/taluu/behapi","last_synced_at":"2025-07-19T23:35:10.157Z","repository":{"id":54814484,"uuid":"61361672","full_name":"Taluu/Behapi","owner":"Taluu","description":"Behat extension for those who want to write acceptances tests for apis","archived":false,"fork":false,"pushed_at":"2022-10-22T13:18:18.000Z","size":411,"stargazers_count":32,"open_issues_count":5,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-18T01:30:47.226Z","etag":null,"topics":["api","bdd","behat","behat-contexts","behat-extension","php","php71","rest"],"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/Taluu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-17T09:18:51.000Z","updated_at":"2022-11-25T15:12:18.000Z","dependencies_parsed_at":"2022-08-14T03:40:29.068Z","dependency_job_id":null,"html_url":"https://github.com/Taluu/Behapi","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/Taluu/Behapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taluu%2FBehapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taluu%2FBehapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taluu%2FBehapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taluu%2FBehapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Taluu","download_url":"https://codeload.github.com/Taluu/Behapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Taluu%2FBehapi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266041879,"owners_count":23867956,"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":["api","bdd","behat","behat-contexts","behat-extension","php","php71","rest"],"created_at":"2024-09-24T20:02:51.147Z","updated_at":"2025-07-19T23:35:10.135Z","avatar_url":"https://github.com/Taluu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Behapi\n======\nBehat extension to help write describe features related to HTTP APIs.\n\nPHP 7.3, Behat 3.7 and a discoverable php-http client are required to make\nthis extension work.\n\nInstalling this extension requires you to require `taluu/behapi` and an\nimplementation of a http client (providing\n`psr/http-client-implementation ^1.0`,\n`psr/http-factory-implementation ^1.0` and\n`psr/http-message-implementation ^1.0`).\n\nYou can find some examples on the `examples/` directory.\n\nHowto\n-----\nAdd this in your behat.yml (it's for the `default` configuration but you can\nuse it for any configurations actually) :\n\n```yaml\ndefault:\n  suites:\n    main:\n      paths: ['%paths.base%/features']\n      services: '@Behapi\\Container'\n      autowire: true\n\n      contexts:\n        #- List\n        #- your\n        #- contexts\n        #- here\n\n        # examples :\n        - Behapi\\Http\\RequestContext: ~\n        - Behapi\\Http\\ResponseContext: ~\n\n  extensions:\n    Behapi\\Behapi:\n      base_url: 'http://localhost'\n```\n\nThe `base_url` is the only requirement in the config for this extension to work.\n\nThere are other configurations keys, such as which formatter to use in a debug\nenvironment, which headers you want to output in request or response while\ndebugging ; Use the `--config-reference` flag when invoking behat to have more\ninformation on the available configuration.\n\nAfter having installed the extension, you can then use the provided contexts\nsuch as the `Behapi\\Http\\RequestContext` for the http api operations. In order\nto use them, you need to use behapi's container (`@Behapi\\Container`), or a\ncontainer capable of using behapi's container.\n\nSome services are provided to be injected in contexts, which are the following:\n\n- `@Http\\Client\\Common\\PluginClientBuilder`, which will build a\n  `Http\\Client\\Common\\PluginClient` when needed\n- `@Behapi\\HttpHistory\\History`, which is a sort of a container with the last\n  requests done and last responses received\n- `@Http\\Message\\MessageFactory`\n- `@Http\\Message\\StreamFactory`\n\n*Note:* You don't really need to bother with the services names, as they are\ncompatible with behat's auto-wiring feature.\n\nIn order to enable the Json assertions, you need to use the\n`Behapi\\Context\\Json` context. Note that if you use the json context, you\nshould have used the client provided by the client builder used in the\n`Behapi\\Http\\RequestContext` context.\n\nIf you need to play with the request being built, or the response created when\nthe request is sent, you need to inject the `@Behapi\\HttpHistory\\History`. It is\nautomatically reseted between scenarios (and scenarios outlines)\n\nA documentation will be made (soon hopefully) with more details.\n\nContributing\n------------\nContributing (issues, pull-requests) are of course always welcome ! Be sure to\nrespect the standards (such as psr-2, ... etc), follow proper git etiquette\n(atomic commits, ...), proper conduct too and it should be fine !\n\nThanks\n------\nThis extension was made while I was working at\n[@Wisembly](https://github.com/Wisembly), and heavily used for writing our\nfeatures and integration tests. Special thanks goes to\n[@lunika](https://github.com/lunika), [@rgazelot](https://github.com/rgazelot)\nand [@krichprollsch](https://github.com/krichprollsch), who helped conceived\nthis extension, and also pushed me to open-source it.\n\nBadges\n------\n[![Type Coverage](https://shepherd.dev/github/Taluu/Behapi/coverage.svg)](https://shepherd.dev/github/Taluu/Behapi)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaluu%2Fbehapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaluu%2Fbehapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaluu%2Fbehapi/lists"}