OpenAPI-backed API testing in PHP projects: Laravel example

Click for: original source

OpenAPI is a specification intended to describe RESTful APIs in JSON and YAML, with the aim of being understandable by humans and machines alike. By Yannick Chenot.

In this article, we will see how to combine OpenAPI 3.0.x definitions with integration tests to validate whether an API behaves the way it’s supposed to, using the OpenAPI HttpFoundation Testing package.

The article has these sections:

  • The issue
  • A solution
  • PSR-7
  • A Laravel example

OpenAPI definition as a reference for code and tests

Source: https://tech.osteel.me/posts/openapi-backed-api-testing-in-php-projects-a-laravel-example

The OpenAPI specification has become a popular choice to describe APIs over time, but whether we use it or not doesn’t change the fact that the corresponding definitions need to be maintained; in other words, using OpenAPI does not automagically make the aforementioned issues go away. Good read!

[Read More]

Tags agile tdd web-development php