How do I apply patch in vendor directory using composer? Background:


Drupal 8
Managing dependencies with compose


I want to apply one patch to vendor/behat/web_api_extension project.

I tried with this in composer.json but it doesn't works or no error.

"extra": {
    "enable-patching": true,
    "patches": {
        "drupal/better_formats": {
           "Settings have no affect on the field if it is in a Paragraph bundle - https://www.drupal.org/node/2754029": "https://www.drupal.org/files/issues/better_formats_paragraphs-2754029-15.patch"
        },
        "vendor/behat/web-api-extension": {
            "behat web api definition conflicts with mink extensions": "patches/behat_web_api/alter-definitions-text.patch"
        }
    }
}
You will need cweagans vendor to make composer able to parse the extra->patches lines. 

This line is wrong I think: "vendor/behat/web-api-extension"
You always need the package name (without version) and not the relative path.
In your case it should be "behat/behat"