https://github.com/znsio/specmatic-order-api-python
Python port of Specmatic Order Api
https://github.com/znsio/specmatic-order-api-python
Last synced: about 1 year ago
JSON representation
Python port of Specmatic Order Api
- Host: GitHub
- URL: https://github.com/znsio/specmatic-order-api-python
- Owner: znsio
- Created: 2023-05-02T12:03:55.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-08T00:55:16.000Z (over 1 year ago)
- Last Synced: 2025-03-08T01:30:39.438Z (over 1 year ago)
- Language: Python
- Size: 97.7 KB
- Stars: 0
- Watchers: 10
- Forks: 0
- Open Issues: 1
-
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://specmatic.io/documentation.html)
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/znsio/specmatic-order-contracts/blob/main/io/specmatic/examples/store/openapi/api_order_v3.yaml)
## Tech
1. Flask
2. Specmatic
3. PyTest
4. Coverage
## Setup
1. Install [Python 3.12](https://www.python.org/)
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
```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
```