https://github.com/specmatic/specmatic-order-api-python
Python port of Specmatic Order Api
https://github.com/specmatic/specmatic-order-api-python
sample-project
Last synced: about 2 months ago
JSON representation
Python port of Specmatic Order Api
- Host: GitHub
- URL: https://github.com/specmatic/specmatic-order-api-python
- Owner: specmatic
- Created: 2023-05-02T12:03:55.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-03-03T00:27:23.000Z (about 2 months ago)
- Last Synced: 2026-03-03T03:41:43.643Z (about 2 months ago)
- Topics: sample-project
- Language: Python
- Size: 147 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Specmatic Sample: Python-Flask Order API
* [Specmatic Website](https://specmatic.io)
* [Specmatic Documentation](https://docs.specmatic.io)
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](https://github.com/specmatic/specmatic-order-contracts/blob/main/io/specmatic/examples/store/openapi/api_order_v3.yaml)
## Tech
1. Flask
2. Specmatic
3. PyTest
4. Coverage
5. Docker Desktop
## Setup
1. Install [Python 3.12](https://www.python.org/)
2. Install JRE 17 or later.
3. Install Docker Desktop
## Setup Virtual Environment
1. ### Create a virtual environment named ".venv" by executing the following command in the terminal from the project's root directory
```shell
python -m venv .venv
```
2. ### Activate virtual environment by executing
* **on MacOS and Linux**
```shell
source .venv/bin/activate
```
* **on Windows CMD**
```cmd
.venv\Scripts\activate.bat
```
* **on Windows Powershell (you may need to adjust the ExecutionPolicy)**
```powershell
.\.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
```shell
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.
```shell
pytest test -v -s
```