Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
855d117
doc: update start page
marle3003 Mar 2, 2026
5c290e5
fix: typo in code example
marle3003 Mar 2, 2026
256e7de
fix: quick-start responsiveness
marle3003 Mar 3, 2026
9353590
doc: update readme documentation
marle3003 Mar 4, 2026
a36c52c
doc: add link to npmjs package
marle3003 Mar 4, 2026
c1421e5
test: refactor test
marle3003 Mar 4, 2026
eb0b44e
fix(webui): fix styling
marle3003 Mar 4, 2026
c1b895e
fix(webui): display error
marle3003 Mar 6, 2026
96b11a9
fix(cli): fix env var PROVIDERS_NPM_GLOBAL_FOLDER
marle3003 Mar 6, 2026
f1d8219
build(deps-dev): bump @vue/tsconfig from 0.8.1 to 0.9.0 in /webui
dependabot[bot] Mar 6, 2026
b4fdc0f
Merge pull request #873 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Mar 6, 2026
619168d
build(deps): bump @types/mokapi from 0.34.0 to 0.35.0 in /webui
dependabot[bot] Mar 6, 2026
9256e15
Merge pull request #872 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Mar 6, 2026
1708da9
build(deps-dev): bump vue-tsc from 3.2.4 to 3.2.5 in /webui
dependabot[bot] Mar 6, 2026
ad4868a
Merge pull request #874 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Mar 6, 2026
7b6ac65
build(deps-dev): bump eslint from 10.0.0 to 10.0.2 in /webui
dependabot[bot] Mar 6, 2026
1a5e253
Merge pull request #871 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Mar 6, 2026
4b9c5ee
build(deps): bump @types/nodemailer from 7.0.10 to 7.0.11 in /webui
dependabot[bot] Mar 6, 2026
c16ce1d
Merge pull request #875 from marle3003/dependabot/npm_and_yarn/webui/…
github-actions[bot] Mar 6, 2026
6a10436
fix(openapi): prevent dynamic scope leakage between OpenAPI schemas
marle3003 Mar 7, 2026
8e6c8a3
Merge remote-tracking branch 'origin/develop' into develop
marle3003 Mar 7, 2026
9db8e36
fix(jsonSchema): fix resolving $ref and $dynamicRef
marle3003 Mar 8, 2026
0141dc2
Merge branch 'main' into develop
marle3003 Mar 8, 2026
113f9dc
chore(webui): update styles
marle3003 Mar 8, 2026
feaea93
Merge remote-tracking branch 'origin/develop' into develop
marle3003 Mar 8, 2026
043ebd1
fix(webui): update styles
marle3003 Mar 9, 2026
89a54b1
fix(webui): update styles
marle3003 Mar 9, 2026
8c12fce
fix(openapi): fix of parsing components that have overwritten already…
marle3003 Mar 9, 2026
3046ef0
Merge remote-tracking branch 'origin/develop' into develop
marle3003 Mar 9, 2026
32583e7
doc: update documentation and styles
marle3003 Mar 10, 2026
ae59662
Merge remote-tracking branch 'origin/develop' into develop
marle3003 Mar 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 91 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</a>
</p>

<h3 align="center">Your API Mocking Tool for Agile Development</h3>
<h3 align="center">Mock APIs Across Protocols. Test Faster. Ship Better.</h3>

<p align="center">
<a href="https://github.com/marle3003/mokapi/releases"><img src="https://img.shields.io/github/release/marle3003/mokapi.svg" alt="Github release"></a>
Expand All @@ -17,124 +17,133 @@
<a href="https://mokapi.io/docs/welcome">Documentation</a>
</p>

# 🚀 Overview
## What is Mokapi?

Mokapi is an open-source tool that helps Agile, DevOps, and Continuous
Deployment teams design, test, and validate APIs before implementation.
It enables rapid prototyping of scenarios—like delayed responses,
failures, or edge cases—without needing a live backend. By simulating
real-world conditions early, Mokapi improves API quality and reduces
the risk of bugs in production.
Mokapi is an open-source API mocking tool that lets you develop and test without waiting
for backends. Mock REST APIs, Kafka topics, LDAP directories, and SMTP servers using
OpenAPI and AsyncAPI specifications.

# ✨ Features
Perfect for:
- Frontend developers building UIs before backends exist
- QA teams testing edge cases, errors, and timeouts
- DevOps engineers running reliable CI/CD tests without external dependencies
- API designers prototyping and validating contracts early

- **Multiple Protocol support**: HTTP, HTTPS, Apache Kafka, SMTP, LDAP
- **Everything as Code**: Reusing, version control, consistency and integrate mocks with your CI/CD.
- **An embedded JavaScript engine** to control everything - status, headers, delays, errors or other edge cases.
- **Patch Configuration** changes for mocking needs, rather than changing the original contract
- **Multiple Provider support**: File, HTTP, GIT, NPM to gather configurations and scripts.
- **Dashboard** to see what's going on.
## Quick Start

## 🧩 OpenAPI & AsyncAPI Support
Try Instantly

Mokapi supports mocking REST APIs using **OpenAPI 2.0 / 3.0 / 3.1** and event-driven systems using **AsyncAPI**.

## 🔧 Spin Up Mokapi

Install and start Mokapi using one of the following methods.
Replace the URL with your own OpenAPI or AsyncAPI specification.

Windows
```shell
choco install mokapi
mokapi https://petstore31.swagger.io/api/v31/openapi.json
```

MacOS
```shell
brew tap marle3003/tap
brew install mokapi
mokapi https://petstore31.swagger.io/api/v31/openapi.json
npx go-mokapi https://petstore3.swagger.io/api/v3/openapi.json
```

Docker
```shell
docker run -p 80:80 -p 8080:8080 mokapi/mokapi:latest https://petstore31.swagger.io/api/v31/openapi.json
```
Then test your mock:

# 🎯 Hit Your First Mock
Once Mokapi is running, you can make requests to your mocked API like so:
```shell
curl http://localhost/api/v31/pet/2 -H 'Accept: application/json'
```
curl http://localhost/api/v3/pet/1 -H 'Accept: application/json'
```

## Key Features

# 🧩 Customize Your Mock with JavaScript
### Multi-Protocol Support
Mock HTTP/HTTPS, Apache Kafka, LDAP, and SMTP — all from a single tool.

Mokapi makes it simple to control responses using embedded JavaScript.
### Specification-Driven
Uses OpenAPI and AsyncAPI specs as the source of truth. Your mocks stay aligned with your API contracts.

For example, you can dynamically change the response based on query parameters:
### Dynamic Behavior with JavaScript

```typescript
import { on } from 'mokapi';
Control responses, simulate errors, add delays, or create complex workflows using embedded JavaScript:
```javascript
import { on } from 'mokapi'

export default function() {
on('http', (request, response) => {
switch (request.path.petId) {
case 2:
response.data.name = 'Betty';
case 9:
response.statusCode = 404;
// Return 404 for specific IDs
if (request.path.petId === '999') {
response.statusCode = 404
return
}
});

// Customize response data
response.data.name = 'Custom Pet Name'
})
}
```

# 🖥️ Dashboard
### Everything as Code
Version control your mocks alongside your code. Run them in CI/CD pipelines. No UI configuration required.

Mokapi’s dashboard lets you visualize your mock APIs. View requests and responses in real-time, generate and validate sample data for testing.
### Configuration Patching
Override parts of your OpenAPI spec without modifying the original file. Perfect for testing different scenarios.

<img src="webui.png" alt="Mokapi Web UI" title="Mokapi Web UI" />
### Built-in Dashboard
Visualize requests, responses, and logs in real-time at http://localhost:8080
<img src="https://raw.githubusercontent.com/marle3003/mokapi/refs/heads/main/webui.png" alt="Mokapi Web UI" title="Mokapi Web UI" />

# 🧪 Learn by Example
### Multiple Providers
Load specs from local files, HTTP URLs, Git repositories, or NPM packages.

Explore tutorials that walk you through mocking different protocols and scenarios:
## Common Use Cases

- 🌍 [Get started with REST API](https://mokapi.io/resources/tutorials/get-started-with-rest-api)\
This tutorial will show you how to mock a REST API using an OpenAPI specification.
### Frontend Development
Mock backend APIs while building UIs. Test loading states, errors, and edge cases without waiting for real endpoints.

- ⚡ [Mocking Kafka with AsyncAPI](https://mokapi.io/resources/tutorials/get-started-with-kafka)\
Mocking a Kafka topic using Mokapi and verifying that a producer generates valid messages.
### API Testing
Simulate timeouts, 500 errors, rate limits, and malformed responses. Test how your application handles failures.

- 👨‍💻 [Mocking LDAP Authentication](https://mokapi.io/resources/tutorials/mock-ldap-authentication-in-node)\
Simulate LDAP-based login flows, including group-based permissions.
### CI/CD Integration
Run fast, reliable tests without external dependencies. No flaky tests due to network issues or unavailable services.

- 📧 [Mocking SMTP Mail Servers](https://mokapi.io/resources/tutorials/mock-smtp-server-send-mail-using-node)\
Use Mokapi to simulate sending and receiving emails in Node.js apps.
### Contract Validation
Validate that your requests and responses match your OpenAPI specification. Catch breaking changes early.

- 🖥️ [End-to-End Testing with Jest and GitHub Actions](https://mokapi.io/resources/tutorials/running-mokapi-in-a-ci-cd-pipeline)\
Integrate Mokapi into your CI pipeline for full-stack E2E testing.
# Example Tutorials

> More examples are available on [mokapi.io/resources](https://mokapi.io/resources)
Explore tutorials that walk you through mocking different protocols and scenarios:

- [Get started with REST API](https://mokapi.io/resources/tutorials/get-started-with-rest-api)
Mock a REST API using OpenAPI specification

- [Mock Kafka with AsyncAPI](https://mokapi.io/resources/tutorials/get-started-with-kafka)
Simulate Kafka topics and validate message producers

- [Mock LDAP Authentication](https://mokapi.io/resources/tutorials/mock-ldap-authentication-in-node)\
Test authentication flows without a real LDAP server

# 📚 Documentation
- [Mock SMTP Mail Servers](https://mokapi.io/resources/tutorials/mock-smtp-server-send-mail-using-node)\
Test email workflows without sending real messages

- [Get Started](https://mokapi.io/docs/welcome)
- [HTTP](https://mokapi.io/docs/http/overview)
- [Kafka](https://mokapi.io/docs/kafka/overview)
- [LDAP](https://mokapi.io/docs/ldap/overview)
- [SMTP](https://mokapi.io/docs/mail/overview)
- [Javascript API](https://mokapi.io/docs/javascript-api/overview)
- [Resources](https://mokapi.io/resources)
- [CI/CD Integration with GitHub Actions](https://mokapi.io/resources/tutorials/running-mokapi-in-a-ci-cd-pipeline)\
Run Mokapi in automated test pipelines

# ☕ Support
> More examples [mokapi.io/resources](https://mokapi.io/resources)

Show your love for Mokapi and support the project by grabbing some cool merch!
[Visit the Mokapi Merchandise Store](https://mokapi.myspreadshop.ch) 🔥
## Documentation

If you like Mokapi, consider buying me a coffee:
- [Getting Started Guide](https://mokapi.io/docs/welcome)
- [HTTP/REST API Documentation](https://mokapi.io/docs/http/overview)
- [Kafka Documentation](https://mokapi.io/docs/kafka/overview)
- [LDAP Documentation](https://mokapi.io/docs/ldap/overview)
- [SMTP/Mail Documentation](https://mokapi.io/docs/mail/overview)
- [JavaScript API Reference](https://mokapi.io/docs/javascript-api/overview)
- [Configuration Guide](https://mokapi.io/docs/configuration/overview)

## Support the Project

If Mokapi helps your team ship faster, consider supporting development:

<a href="https://www.buymeacoffee.com/mokapi" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>

# 📄 License
## License

MIT License - see [LICENSE](https://github.com/marle3003/mokapi/blob/main/LICENSE) for details.

## Links

This project is licensed under the MIT License. See the [LICENSE](https://github.com/marle3003/mokapi/blob/main/LICENSE) file for details.
- Website: [mokapi.io](https://mokapi.io)
- GitHub: [github.com/marle3003/mokapi](https://github.com/marle3003/mokapi)
- NPM Package: [npmjs.com/package/go-mokapi](https://npmjs.com/package/go-mokapi)
- Documentation: [mokapi.io/docs](https://mokapi.io/docs)
- Tutorials: [mokapi.io/resources/tutorials](https://mokapi.io/resources/tutorials)
- Blog: [mokapi.io/resources/blogs](https://mokapi.io/resources/blogs)
32 changes: 17 additions & 15 deletions api/handler_fileserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package api_test

import (
"fmt"
"github.com/stretchr/testify/require"
"mokapi/api"
"mokapi/config/dynamic"
"mokapi/config/static"
Expand All @@ -14,6 +13,8 @@ import (
"net/url"
"strings"
"testing"

"github.com/stretchr/testify/require"
)

func TestHandler_FileServer(t *testing.T) {
Expand Down Expand Up @@ -168,7 +169,7 @@ func TestOpenGraphInDashboard(t *testing.T) {
app := runtime.New(cfg)
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
openapitest.WithPath("/pet/{petId}", openapitest.NewPath()),
openapitest.WithPath("/pet/{petId}"),
)},
)
h := api.New(app, static.Api{Path: "/mokapi", Dashboard: true})
Expand All @@ -192,9 +193,9 @@ func TestOpenGraphInDashboard(t *testing.T) {
app := runtime.New(cfg)
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
openapitest.WithPath("/pet/{petId}", openapitest.NewPath(
openapitest.WithPath("/pet/{petId}",
openapitest.WithPathInfo("foo", "bar"),
)),
),
),
})
h := api.New(app, static.Api{Path: "/mokapi", Dashboard: true})
Expand All @@ -218,9 +219,9 @@ func TestOpenGraphInDashboard(t *testing.T) {
app := runtime.New(cfg)
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
openapitest.WithPath("/pet/{petId}", openapitest.NewPath(
openapitest.WithPath("/pet/{petId}",
openapitest.WithPathInfo("", "bar"),
))),
)),
})
h := api.New(app, static.Api{Path: "/mokapi", Dashboard: true})
try.Handler(t,
Expand All @@ -243,9 +244,9 @@ func TestOpenGraphInDashboard(t *testing.T) {
app := runtime.New(cfg)
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
openapitest.WithPath("/pet/{petId}", openapitest.NewPath(
openapitest.WithOperation("GET", openapitest.NewOperation()),
))),
openapitest.WithPath("/pet/{petId}",
openapitest.WithOperation("GET"),
)),
})
h := api.New(app, static.Api{Path: "/mokapi", Dashboard: true})
try.Handler(t,
Expand All @@ -268,12 +269,13 @@ func TestOpenGraphInDashboard(t *testing.T) {
app := runtime.New(cfg)
app.AddHttp(&dynamic.Config{Info: dynamic.ConfigInfo{Url: mustParse("https://foo.bar")}, Data: openapitest.NewConfig("3.0",
openapitest.WithInfo("Swagger Petstore", "1.0", "This is a sample server Petstore server."),
openapitest.WithPath("/pet/{petId}", openapitest.NewPath(
openapitest.WithOperation("GET", openapitest.NewOperation()),
)),
openapitest.WithPath("/pet/{petId}/foo", openapitest.NewPath(
openapitest.WithOperation("GET", openapitest.NewOperation()),
))),
openapitest.WithPath("/pet/{petId}",
openapitest.WithOperation("GET"),
),
openapitest.WithPath("/pet/{petId}/foo",
openapitest.WithOperation("GET"),
),
),
})
h := api.New(app, static.Api{Path: "/mokapi", Dashboard: true})
try.Handler(t,
Expand Down
Loading
Loading