Skip to content

znsio/specmatic-order-api-python

Repository files navigation

Specmatic Sample: Python-Flask Order API

This sample project illustrates the implementation of contract-driven development and contract testing within a Flask (Python) application. In this context, Specmatic is utilized to function as a client, making calls to API service according to its OpenAPI specification to validate its functionality.

Here is the API's contract/open api spec

Tech

  1. Flask
  2. Specmatic
  3. PyTest
  4. Coverage

Setup

  1. Install Python 3.12
  2. Install JRE 17 or later.

Setup Virtual Environment

  1. Create a virtual environment named ".venv" by executing the following command in the terminal from the project's root directory

     python -m venv .venv
  2. Activate virtual environment by executing

  • on MacOS and Linux

    source .venv/bin/activate
  • on Windows CMD

    .venv\Scripts\activate.bat
  • on Windows Powershell (you may need to adjust the ExecutionPolicy)

    .\.venv\Scripts\Activate.ps1

Install Dependencies

To install all necessary dependencies for this project, navigate to the project's root directory in your terminal and execute

pip install -r requirements.txt

Execute Tests and Validate Contracts with Specmatic

Executing this command will initiate Specmatic and execute the tests on the Flask application.

pytest test -v -s

About

Python port of Specmatic Order Api

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages