microcks-openapi-mocking
Skill4 starsChanged 40 days agoApache-2.0View on GitHub
Write OpenAPI examples that work with Microcks dispatchers for API mocking. Covers example pairing rules, JSON body dispatching, Groovy script dispatching, and dispatcher configuration via the Microcks API.
- Sends data out
1 other project uses a version of this.
Adopted by
Most recently taken up by
- emmanuelperu/skillsword for word, first seen Oct 25, 2026
Other versions1 project uses a version of this.
Word for word · 1
- emmanuelperu/skills★ 4100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository2 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Use this skill when:
- Distinctive: line 27
Every named example in path/query parameters and request body must have a corresponding response example with the same name.
- Distinctive: line 75
If you define an error response (400, 404, 500), there must be a matching input example (in parameters or requestBody) with the same …
- Very specific: line 131
No header → returns success
- Distinctive: line 154
Use these standard example names to keep your specs consistent:
- Very specific: line 239
Use the microcks-import-artifacts skill to import the spec and auto-configure dispatchers:
- Distinctive: line 386
[microcks-local-server](../microcks-local-server/): Start a local Microcks server with Docker Compose
- Distinctive: line 391
[microcks-import-artifacts](../microcks-import-artifacts/): Import OpenAPI specs into Microcks and auto-configure dispatchers
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Microcks OpenAPI Mocking
Help write and configure OpenAPI specifications with examples that work correctly in Microcks.
When to Use This Skill
Use this skill when:
- Writing or editing named examples in an OpenAPI spec for Microcks mocking
- Adding a new endpoint to an OpenAPI spec with multiple example scenarios (success, errors)
- Configuring a dispatcher to control how Microcks routes requests to different responses
- Debugging a mock response that isn't returning the expected data
- Setting up example pairing between request and response examples in OpenAPI
Core Rules
Microcks mocking depends on correct example pairing and dispatcher configuration. Here are the key rules:
Rule 1: Example Names Must Match Across Locations
Every named example in path/query parameters and request body must have a corresponding response example with the same name.
paths:
/pets/{petId}:
get:
parameters:
- name: petId
examples:
success: # ← example name
value: 1
not_found: # ← example name
value: 999
responses:
'200':
content:
application/json:
examples:
success: # ← same name
value: { id: 1, name: Fluffy }
'404':
content:
application/json:
examples:
not_found: # ← same name
value: { error: Not found }Details: See example-pairing.md
Rule 2: No-Body Responses Need Content Block with value: null
Responses with no body (204, 304) must still have a content block with explicit value: null:
delete:
responses:
'204':
description: Deleted
content:
application/json:
examples:
success:
value: null # ← Required for no-body responsesRule 3: All Error Examples Need Input Examples
If you define an error response (400, 404, 500), there must be a matching input example (in parameters or requestBody) with the same example name that triggers it.
Rule 4: POST on Collections → Use json_body Dispatcher
For POST /resource operations, use the json_body dispatcher to route requests based on the request body:
paths:
/orders:
post:
x-mocking-microcks-dispatcher: json_body # ← Add this
requestBody:
content:
application/json:
examples:
success:
value: { total: 100, items: [{ id: 1 }] }
invalid_input:
value: { total: -5, items: [] }Details: See json-body-dispatcher.md
Rule 5: Operations Without Discriminant → Use script_header_error Dispatcher
For operations without a discriminating parameter or body (e.g., GET without query, POST with uniform body), use the script_header_error dispatcher. It routes on the HTTP error header:
paths:
/health:
get:
x-mocking-microcks-dispatcher: script_header_error
responses:
'200':
content:
application/json:
examples:
success:
value: { status: "healthy" }
'400':
content:
application/json:
examples:
invalid_input:
value: { error: "Bad request" }
'500':
content:
application/json:
examples:
server_error:
value: { error: "Internal server error" }The import script generates a Groovy dispatcher that reads the error header:
error: 400→ returnsinvalid_inputerror: 500→ returnsserver_error- No header → returns
success
Details: See script-header-error-dispatcher.md
Rule 6: Complex Logic → Use script Dispatcher
For GET/PATCH/DELETE, polymorphic bodies, or multi-field routing logic, use the script dispatcher with an external Groovy file:
paths:
/events:
post:
x-mocking-microcks-dispatcher: scriptThe import script loads the Groovy file from mocking/dispatchers/{METHOD}-{path-slug}.groovy.
Details: See script-dispatcher.md
Naming Conventions
Use these standard example names to keep your specs consistent:
| Example Name | HTTP Status | Meaning |
success | 200, 201, 204 | Successful request |
invalid_input | 400 | Request validation failed |
unauthorized | 401 | Authentication required |
forbidden | 403 | Authorization failed |
not_found | 404 | Resource not found |
conflict | 409 | Conflict (e.g., duplicate) |
server_error | 500 | Server error |
unavailable | 503 | Service unavailable |
Quick Reference: Dispatcher Types
| Dispatcher | When to Use | Example |
json_body | POST operations; route by request body fields | json-body-dispatcher.md |
script_header_error | Operations without discriminating param/body; route by error header | script-header-error-dispatcher.md |
script | Complex logic; route by query params, headers, path, or body | script-dispatcher.md |
Step-by-Step: Create a Complete Example
1. Define the Operation with Examples
openapi: 3.0.0
info:
title: User API
version: 1.0.0
paths:
/users:
post:
operationId: createUser
x-mocking-microcks-dispatcher: json_body # Enable dispatching
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/User'
examples:
success: # ← Example name
value:
name: "Alice"
email: "alice@example.com"
invalid_input: # ← Example name
value:
name: ""
email: "not-an-email"
responses:
'201':
description: User created
content:
application/json:
schema:
$ref: '#/components/schemas/User'
examples:
success: # ← Must match request
value:
id: 1
name: "Alice"
email: "alice@example.com"
'400':
description: Invalid input
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
examples:
invalid_input: # ← Must match request
value:
error: "Validation failed"
fields:
- "name cannot be empty"
- "email must be valid"2. Import and Configure
Use the microcks-import-artifacts skill to import the spec and auto-configure dispatchers:
./mocking/import-openapi.sh path/to/api-spec.yaml3. Test the Mock
# Should return 201 with 'success' example
curl -X POST http://localhost:8080/rest/User%20API/1.0.0/users \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "email": "alice@example.com"}'
# Should return 400 with 'invalid_input' example
curl -X POST http://localhost:8080/rest/User%20API/1.0.0/users \
-H "Content-Type: application/json" \
-d '{"name": "", "email": "not-an-email"}'Reference Files
- example-pairing.md: Rules for matching request and response examples
- json-body-dispatcher.md: Route POST requests based on request body
- script-header-error-dispatcher.md: Route success / 400 / 500 via the
errorHTTP header (no Groovy file needed) - script-dispatcher.md: Complex routing with Groovy scripts
- dispatcher-setup.md: Configure dispatchers via Microcks REST API
Common Patterns
Pattern 1: GET by ID (with not found case)
paths:
/users/{userId}:
get:
parameters:
- name: userId
in: path
examples:
success:
value: 1
not_found:
value: 999
responses:
'200':
content:
application/json:
examples:
success:
value: { id: 1, name: Alice }
'404':
content:
application/json:
examples:
not_found:
value: { error: User not found }Pattern 2: POST with Validation Errors
paths:
/products:
post:
x-mocking-microcks-dispatcher: json_body
requestBody:
content:
application/json:
examples:
success:
value: { sku: "ABC123", price: 29.99 }
invalid_input:
value: { sku: "", price: -5 }
responses:
'201':
content:
application/json:
examples:
success:
value: { id: 1, sku: ABC123, price: 29.99 }
'400':
content:
application/json:
examples:
invalid_input:
value: { error: Validation failed }Pattern 3: DELETE with 204 No Content
paths:
/products/{productId}:
delete:
parameters:
- name: productId
examples:
success:
value: 1
responses:
'204':
description: Deleted
content:
application/json:
examples:
success:
value: nullTroubleshooting
Mock Not Returning Expected Response
Check:
- Are request/response examples named the same? (case-sensitive)
- Is the dispatcher configured? (check Microcks Admin UI)
- Does your request match an example exactly?
Solution: See example-pairing.md and dispatcher-setup.md
Dispatcher Not Triggering
Check:
- Is
x-mocking-microcks-dispatchercorrectly spelled and at operation level? - Have you re-imported the spec after adding the dispatcher?
Solution: See json-body-dispatcher.md or script-dispatcher.md
Script Dispatcher Returns Wrong Example
Check:
- Does the script return a valid example name (must exist in responses)?
- Is the Groovy syntax correct?
Solution: See script-dispatcher.md "Troubleshooting"
Complementary Skills
- microcks-local-server: Start a local Microcks server with Docker Compose
npx skills add emmanuelperu/skills --skill microcks-local-server - microcks-import-artifacts: Import OpenAPI specs into Microcks and auto-configure dispatchers
npx skills add emmanuelperu/skills --skill microcks-import-artifacts - openapi-spec-generation: Write high-quality OpenAPI specifications from scratch
npx skills add https://github.com/wshobson/agents --skill openapi-spec-generation
Related
- Microcks Documentation: https://microcks.io/documentation
- OpenAPI Specification: https://spec.openapis.org
- Groovy Language: https://groovy-lang.org
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

