Skip to content

Commit 4d5930a

Browse files
authored
Merge pull request #538 from marle3003/develop
Develop
2 parents 0ac01a3 + 37ebac8 commit 4d5930a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1156
-508
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ Explore tutorials that walk you through mocking different protocols and scenario
122122
- [LDAP](https://mokapi.io/docs/guides/ldap/overview)
123123
- [SMTP](https://mokapi.io/docs/guides/smtp/overview)
124124
- [Javascript API](https://mokapi.io/docs/javascript-api)
125-
- [Examples & Tutorials](https://mokapi.io/docs/resources)
126-
- [Blogs](https://mokapi.io/docs/blogs)
125+
- [Resources](https://mokapi.io/docs/resources)
127126

128127
# ☕ Support
129128

api/handler_schema_validate.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"mokapi/schema/json/parser"
1414
jsonSchema "mokapi/schema/json/schema"
1515
"net/http"
16+
"strings"
1617
)
1718

1819
type validateRequest struct {
@@ -89,6 +90,11 @@ func parseByOpenApi(data []byte, s *schema.Schema, ct media.ContentType) (interf
8990
var v interface{}
9091
var err error
9192
if ct.IsXml() {
93+
str := strings.TrimSpace(string(data))
94+
if !strings.HasPrefix(str, "<") {
95+
return nil, fmt.Errorf("input does not appear to be valid XML")
96+
}
97+
9298
v, err = schema.UnmarshalXML(bytes.NewReader(data), s)
9399
if err != nil {
94100
return v, err

api/handler_schema_validate_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,23 @@ func TestHandler_Schema_Validate(t *testing.T) {
168168
)
169169
},
170170
},
171+
{
172+
name: "validating xml but send json data",
173+
app: &runtime.App{
174+
Monitor: monitor.New(),
175+
},
176+
fn: func(t *testing.T, h http.Handler, app *runtime.App) {
177+
try.Handler(t,
178+
http.MethodGet,
179+
"http://foo.api/api/schema/validate",
180+
nil,
181+
`{ "schema": {"type": ["object"], "properties": { "foo":{ "type": ["string"] } }, "xml": { "name": "root" } }, "data":"{\"foo\":\"bar\"}", "format": "application/vnd.oai.openapi;version=3.0.0", "contentType": "application/xml" }`,
182+
h,
183+
try.HasBody(`["input does not appear to be valid XML"]`),
184+
try.HasStatusCode(400),
185+
)
186+
},
187+
},
171188
}
172189

173190
for _, tc := range testcases {

docs/config.json

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,20 @@
147147
"component": "examples",
148148
"hideNavigation": true,
149149
"hideInNavigation": true,
150-
"title": "Learn with Mokapi's tutorials & examples",
151-
"description": "Learn how to get started with Mokapi and simulate APIs that don't even exist yet."
150+
"canonical": "/docs/resources",
151+
"title": "Explore Mokapi Resources: Tutorials, Examples, and Blog Articles",
152+
"description": "Explore Mokapi's resources including tutorials, examples, and blog articles. Learn to mock APIs, validate schemas, and streamline your development."
152153
},
153154
"items": {
154155
"Tutorials": {
155-
"expanded": true,
156+
"index": {
157+
"component": "examples",
158+
"hideNavigation": true,
159+
"hideInNavigation": true,
160+
"canonical": "/docs/resources",
161+
"title": "Explore Mokapi Resources: Tutorials, Examples, and Blog Articles",
162+
"description": "Explore Mokapi's resources including tutorials, examples, and blog articles. Learn to mock APIs, validate schemas, and streamline your development."
163+
},
156164
"items": {
157165
"Get started with REST API": "resources/tutorials/simple-http-api.md",
158166
"Mock OpenAPI Authentication API Key & Bearer Token": "resources/tutorials/mock-openapi-auth-apikey-bearer.md",
@@ -167,26 +175,37 @@
167175
}
168176
},
169177
"Examples": {
170-
"expanded": true,
178+
"index": {
179+
"component": "examples",
180+
"hideNavigation": true,
181+
"hideInNavigation": true,
182+
"canonical": "/docs/resources",
183+
"title": "Explore Mokapi Resources: Tutorials, Examples, and Blog Articles",
184+
"description": "Explore Mokapi's resources including tutorials, examples, and blog articles. Learn to mock APIs, validate schemas, and streamline your development."
185+
},
171186
"items": {
172187
"Mokapi behind Reverse Proxy": "resources/examples/mokapi-behind-proxy.md",
173188
"Mokapi with custom base image": "resources/examples/mokapi-with-custom-base-image.md"
174189
}
190+
},
191+
"Blogs": {
192+
"index": {
193+
"component": "examples",
194+
"hideNavigation": true,
195+
"hideInNavigation": true,
196+
"canonical": "/docs/resources",
197+
"title": "Explore Mokapi Resources: Tutorials, Examples, and Blog Articles",
198+
"description": "Explore Mokapi's resources including tutorials, examples, and blog articles. Learn to mock APIs, validate schemas, and streamline your development."
199+
},
200+
"items": {
201+
"Automation Testing in Agile Development": "resources/blogs/automation-testing-agile-development.md",
202+
"Contract Testing": "resources/blogs/contract-testing.md",
203+
"End to End Testing with Mocked APIs": "resources/blogs/end-to-end-testing-mocked-apis.md",
204+
"Debugging Mokapi Scripts": "resources/blogs/debugging-mokapi-scripts.md"
205+
}
175206
}
176207
}
177208
},
178-
"Blogs": {
179-
"index": {
180-
"component": "blogs",
181-
"hideInNavigation": true,
182-
"title": "Mocking and Testing",
183-
"description": "Learn about API mocking and contract testing. Improve your development skills."
184-
},
185-
"items": {
186-
"Automation Testing in Agile Development": "blogs/automation-testing-agile-development.md",
187-
"Contract Testing": "blogs/contract-testing.md"
188-
}
189-
},
190209
"References": {
191210
"items": {
192211
"Declarative Data": "references/declarative-data.md",
Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
---
2-
title: Configure your Mokapi with powerful providers
3-
description: Mokapi gathers configurations and scripts via providers.
2+
title: Configure your Mokapi with powerful configuration providers
3+
description: Learn how Mokapi gathers configurations and scripts using powerful providers. Customize your API mocks dynamically for flexible testing and development.
44
---
55

6-
# Providers
6+
# What Is Dynamic Configuration?
77

8-
Mokapi gathers configurations and scripts via providers.
8+
Dynamic configuration in Mokapi allows you to modify mock services, API behaviors, and test scenarios
9+
in real-time without restarting the application. This capability is essential for agile
10+
development and continuous integration workflows, enabling rapid iteration and testing of various
11+
API responses.
912

10-
## Supported Providers
13+
## Features
1114

12-
Below is the list of supported providers in Mokapi
15+
- **Live Updates:** Modify configurations on-the-fly to simulate different API behaviors.
16+
- **Multi-Source Support:** Load configurations from various sources such as files, HTTP endpoints, Git repositories, or NPM packages.
17+
- **JavaScript Integration:** Utilize embedded JavaScript to define dynamic behaviors, including conditional responses and simulated delays.
18+
- **Patch-Based Changes:** Apply changes using patch configurations, preserving the original contract while customizing behaviors.
19+
- **Dashboard Monitoring:** Visualize and manage configurations through an intuitive web interface.​
1320

14-
- [File](/docs/configuration/dynamic/file.md)
15-
- [HTTP](/docs/configuration/dynamic/http.md)
16-
- [GIT](/docs/configuration/dynamic/git.md)
17-
- [NPM](/docs/configuration/dynamic/npm.md)
21+
## Configuration Sources
22+
23+
Mokapi supports multiple configuration sources, providing flexibility in how you manage and deploy your mock services:
24+
25+
- [**File System:**](/docs/configuration/dynamic/file.md) Store configurations locally for quick access and version control.
26+
- [**HTTP:**](/docs/configuration/dynamic/http.md) Fetch configurations from remote servers, facilitating centralized management.
27+
- [**Git:**](/docs/configuration/dynamic/git.md) Integrate with Git to leverage version control and collaborative workflows.
28+
- [**NPM Packages:**](/docs/configuration/dynamic/npm.md) Distribute and manage configurations as NPM packages for consistency across projects.
29+
30+
## Best Practices
31+
32+
- **Use Version Control:** Store your configuration files in a version control system like Git to track changes and collaborate effectively.
33+
- **Modularize Configurations:** Break down configurations into modular components for reusability and easier maintenance.
34+
- **Validate Configurations:** Regularly validate your configurations to ensure they meet the expected schema and behavior.
35+
- **Monitor Changes:** Utilize Mokapi's dashboard to monitor configuration changes and their impact on mock services.

docs/configuration/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Introduction
3-
description: This page will introduce you to the startup and dynamic configurations.
2+
title: Introduction to Mokapi Configuration | Static & Dynamic Setup Explained
3+
description: Discover how to configure Mokapi using static files or dynamic updates. Learn startup options, hot-reloading, and flexible setup for your mocked APIs.
44
---
55
# Introduction
66

docs/guides/get-started/running.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Running Your First Mocked REST API
3-
description: Learn how to mock a REST API and analyze HTTP request and response in the dashboard.
2+
title: Running Your First Mocked REST API with Mokapi
3+
description: Learn how to run your first mocked REST API using Mokapi. Monitor HTTP requests and responses in the dashboard—ideal for testing and debugging APIs.
44
---
55
# Running Your First Mocked REST API with Mokapi
66

docs/guides/get-started/welcome.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: "Getting Started with Mokapi: Mock APIs and Validate Against Schemas"
3-
description: Learn to set up Mokapi for mocking APIs, no account required, free and open-source.
2+
title: "Getting Started with Mokapi | Mock APIs & Validate with OpenAPI and AsyncAPI"
3+
description: Learn how to set up Mokapi to mock APIs and validate requests using OpenAPI or AsyncAPI. No account needed—free, open-source, and easy to use.
44
cards:
55
items:
66
- title: Run your first mocked REST API

docs/guides/ldap/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: How to mock LDAP with Mokapi
3-
description: Integrate your App with a mock LDAP server
3+
description: Learn how to mock and test LDAP authentication using Mokapi. Simulate user login, group permissions, and directory structure for development and testing.
44
cards:
55
items:
66
- title: Run your first mocked LDAP

docs/javascript-api/mokapi-http/args.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Args
3-
description: Args is an object used by functions in the module mokapi/http
2+
title: Args Object | Mokapi HTTP Module Function Parameters
3+
description: The Args object is used by functions in the Mokapi HTTP module to access request parameters, headers, body data, and more for API mocking logic.
44
---
55
# Args
66

0 commit comments

Comments
 (0)