https://github.com/jackd248/ddev-openapi-mock
🔌 Provides a fake OpenAPI interface for local developing & testing.
https://github.com/jackd248/ddev-openapi-mock
ddev ddev-addon ddev-get openapi openapi-mock
Last synced: 5 months ago
JSON representation
🔌 Provides a fake OpenAPI interface for local developing & testing.
- Host: GitHub
- URL: https://github.com/jackd248/ddev-openapi-mock
- Owner: jackd248
- License: apache-2.0
- Created: 2025-08-04T13:13:29.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-08-04T14:27:18.000Z (6 months ago)
- Last Synced: 2025-08-29T21:40:39.401Z (5 months ago)
- Topics: ddev, ddev-addon, ddev-get, openapi, openapi-mock
- Language: Shell
- Homepage:
- Size: 76.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DDEV OpenAPI Mock
[](https://addons.ddev.com)
[](https://github.com/jackd248/ddev-openapi-mock/actions/workflows/tests.yml?query=branch%3Amain)
[](https://github.com/jackd248/ddev-openapi-mock/commits)
[](https://github.com/jackd248/ddev-openapi-mock/releases/latest)
## ✨ Overview
This add-on integrates [OpenAPI Mock](https://github.com/muonsoft/openapi-mock) into your [DDEV](https://ddev.com/) project to easily test and interact with a fake OpenAPI interface.
For an integrated OpenAPI documentation, the [Swagger UI](https://swagger.io/tools/swagger-ui/) is also available.
## 🔥 Installation
```bash
ddev add-on get jackd248/ddev-openapi-mock
ddev restart
```
After installation, make sure to commit the `.ddev` directory to version control.
## 📂 Configuration
By default, the OpenAPI [petstore specification](https://github.com/readmeio/oas-examples/blob/main/3.0/json/petstore.json) is used for demo purpose.
> [!TIP]
> You can change the location of the OpenAPI specification by setting an DDEV environment variable. See the [Advanced Customization](#advanced-customization) section below for more details.
## 📊 Usage
Regarding your used OpenAPI specification, you can use the following commands to interact with the OpenAPI Mock service, e.g. list all pets:
```bash
# List all pets
ddev launch :8080/v1/pets
# Open Swagger UI
ddev launch :8081
```
## 🗂️ Advanced Customization
### OpenAPI Mock Docker Image
To change the Docker image:
```bash
ddev dotenv set .ddev/.env.openapi-mock --openapi-mock-specification="file:/data/openapi.json"
ddev restart
```
Make sure to commit the `.ddev/.env.openapi-mock` file to version control.
All customization options (use with caution):
| Variable | Flag | Default |
| -------- | ---- |----------------------------------------------------------------------------------------------------|
| `OPENAPI_MOCK_DOCKER_IMAGE` | `--openapi-mock-docker-image` | `muonsoft/openapi-mock:latest` |
| `OPENAPI_MOCK_PORT` | `--openapi-mock-port` | `8080` |
| `OPENAPI_MOCK_SPECIFICATION` | `--openapi-mock-specification` | `https://raw.githubusercontent.com/muonsoft/openapi-mock/refs/heads/master/examples/petstore.yaml` |
| `OPENAPI_MOCK_USE_EXAMPLES` | `--openapi-mock-use-examples` | `if_present` |
| `OPENAPI_MOCK_CORS_ENABLED` | `--openapi-mock-cors-enabled` | `true` |
> [!NOTE]
> If you're using a local OpenAPI specification file, make sure to adjust the `OPENAPI_MOCK_SPECIFICATION` variable accordingly, e.g. `file:/data/openapi.json`.
> Don't forget to update the `OPENAPI_SWAGGER_SPECIFICATION` variable to a similar value, otherwise the Swagger UI will not work properly.
### Swagger UI Docker Image
To change the Swagger UI Docker image:
```bash
ddev dotenv set .ddev/.env.swagger-ui --openapi-swagger-specification="/data/openapi.json"
ddev restart
```
Make sure to commit the `.ddev/.env.swagger-ui` file to version control.
All customization options (use with caution):
| Variable | Flag | Default |
| -------- |--------------------------------------|----------------------------------------------------------------------------------------------------|
| `OPENAPI_SWAGGER_SPECIFICATION` | `--openapi-swagger-specification` | `https://raw.githubusercontent.com/muonsoft/openapi-mock/refs/heads/master/examples/petstore.yaml` |
> [!NOTE]
> If you're using a local OpenAPI specification file, make sure to adjust the `OPENAPI_SWAGGER_SPECIFICATION` variable accordingly, e.g. `/data/openapi.json`.
## 💎 Credits
**Contributed and maintained by [@jackd248](https://github.com/jackd248)**