{"id":21528198,"url":"https://github.com/znsio/specmatic-order-bff-python-sanic","last_synced_at":"2025-03-17T18:44:41.959Z","repository":{"id":169355434,"uuid":"645293522","full_name":"znsio/specmatic-order-bff-python-sanic","owner":"znsio","description":"A python port of the Specmatic Order  BFF API using the Sanic framework","archived":false,"fork":false,"pushed_at":"2025-03-04T17:33:14.000Z","size":629,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-04T18:33:05.693Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/znsio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-25T10:37:18.000Z","updated_at":"2025-03-04T17:33:17.000Z","dependencies_parsed_at":"2024-04-19T16:35:02.317Z","dependency_job_id":"34f649ea-7904-458b-9fcb-aa0110dc3262","html_url":"https://github.com/znsio/specmatic-order-bff-python-sanic","commit_stats":null,"previous_names":["znsio/specmatic-order-bff-python-sanic"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znsio%2Fspecmatic-order-bff-python-sanic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znsio%2Fspecmatic-order-bff-python-sanic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znsio%2Fspecmatic-order-bff-python-sanic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/znsio%2Fspecmatic-order-bff-python-sanic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/znsio","download_url":"https://codeload.github.com/znsio/specmatic-order-bff-python-sanic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244091668,"owners_count":20396664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T01:52:08.583Z","updated_at":"2025-03-17T18:44:41.940Z","avatar_url":"https://github.com/znsio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Specmatic Sample: Python-Sanic BFF\n\n* [Specmatic Website](https://specmatic.io)\n* [Specmatic Documentation](https://specmatic.io/documentation.html)\n\nThis example project illustrates the practice of contract-driven development and contract testing within a Sanic (Python) application that relies on an external domain service. In this context, Specmatic is utilized to stub calls to domain API services according to its OpenAPI specification.\n\nHere is the Domain [OpenAPI spec](https://github.com/znsio/specmatic-order-contracts/blob/main/io/specmatic/examples/store/openapi/api_order_v3.yaml)\n\nHere is the BFF [OpenAPI spec](https://github.com/znsio/specmatic-order-contracts/blob/main/io/specmatic/examples/store/openapi/product_search_bff_v4.yaml)\n\n## Definitions\n\n* BFF: Backend for Frontend\n* Domain API: API managing the domain model\n* Specmatic Stub/Mock Server: Generate a server that simulates a real service using its OpenAPI or AsyncAPI specification\n\n## Background\n\nA standard web application setup may resemble the following structure. By leveraging Specmatic, we can engage in contract-driven development and perform comprehensive testing on all the components listed below. In this illustrative project, we demonstrate the process for a Sanic BFF, which relies on the Domain API Service, showcasing OpenAPI support within **Specmatic**.\n\n![HTML client talks to client API which talks to backend API](assets/specmatic-order-bff-architecture.gif)\n\n## Tech\n\n1. Sanic\n2. Specmatic\n3. PyTest\n4. Coverage\n\n## Setup\n\n1. Install [Python 3.12](https://www.python.org/)\n2. Install JRE 17 or later.\n\n## Setup Virtual Environment\n\n1. ### Create a virtual environment named \".venv\" by executing the following command in the terminal from the project's root directory\n\n   ```shell\n    python -m venv .venv\n    ```\n\n2. ### Activate virtual environment by executing\n\n* **on MacOS and Linux**\n\n   ```shell\n   source .venv/bin/activate\n   ```\n\n* **on Windows CMD**\n\n  ```cmd\n  .venv\\Scripts\\activate.bat\n  ```\n\n* **on Windows Powershell (you may need to adjust the ExecutionPolicy)**\n\n  ```powershell\n  .\\.venv\\Scripts\\Activate.ps1\n  ```\n\n## Install Dependencies\n\nTo install all necessary dependencies for this project, navigate to the project's root directory in your terminal and execute\n\n```shell\npip install -r requirements.txt\n```\n\n## Execute Tests and Validate Contracts with Specmatic\n\nExecuting this command will initiate Specmatic and execute the tests on the Sanic application.\n\n```shell\npytest test -v -s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fznsio%2Fspecmatic-order-bff-python-sanic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fznsio%2Fspecmatic-order-bff-python-sanic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fznsio%2Fspecmatic-order-bff-python-sanic/lists"}