Comments (4)
I definitely like the idea. I think it's worth playing with how to represent this in the RESTful API. I didn't completely follow how the schema gets to mountebank in your example above, but given the AutoFixture-like response (AutoFixture is great, btw), it somehow needs to know how to generate the response. One idea could be as a different behavior with the schema inside the behavior definition:
{
"port": 4545,
"protocol": "http",
"stubs": [
{
"responses": [
{
"is": {
"statusCode": 200,
"body": "{\"id\": #{id}, \"name\": \"#{name}\"}"
},
"_behaviors": {
"generate": {
"id": {
"type": "number"
},
"name": {
"type": "string"
}
}
}
}
]
}
]
}
That has the advantage of working with other content types (e.g. XML) and other response fields (e.g. TCP data and HTTP statusCode) in a consistent way. If more robust generation is required (including randomly including/excluding optional fields), maybe:
{
"port": 4545,
"protocol": "http",
"stubs": [
{
"responses": [
{
"is": {
"statusCode": 200,
"body": "#{order}"
},
"_behaviors": {
"generate": {
"order": {
"type": "json",
"fields": [
{
"name": "id",
"type": "number"
},
{
"name": "name",
"type": "string",
"required": false
}
]
}
}
}
}
]
}
]
}
Definitely open to suggestions - did you have other ideas on how to structure the API?
from mountebank.
No, as far as I can tell - Stub resolvers decorated with a hypothetical new behavior sounds great :) I think create
or build
are probably more precise names for this particular behavior definition.
from mountebank.
Sounds good to me. If you're still interested in working on it, let me know if you need any help getting started. Definitely open to questions or even a skype if it helps.
from mountebank.
Sounds good! Thanks, I will let you know! It might take me a couple of days before I open a pull request.
from mountebank.
Related Issues (20)
- Add binary body representation for http(s) requests for /imposters/{key} endpoint
- Stable release with ARM support
- Master commits break projects using the latest version HOT 3
- Creating & deleting imposters in a load balanced setup HOT 1
- EACCES: permission denied, open 'mb.pid' with version `2.8.1` HOT 2
- Expect field in the header HOT 1
- Mountebank doesn't show imposters metrics
- QUESTION: How to copy (behavior) integer value from path to body field? HOT 1
- ee key too small HOT 6
- How to close tcp connection by Imposter HOT 1
- [Feature Request] Allow mountebank to send back statusMesage
- Mongodb as log transport
- bug in src/util/helpers.js merge function for case with an Array field
- Mountebank beautifies JSON responses from proxies before replying to the caller.
- Copied request object coming back as `[object Object]`
- Mocha test hangs after all tests pass when `imposters` endpoint is called. HOT 1
- How to configure mountebank to handle subdomains?
- GET imposter(s) with `replayable: true` does not return `allowCORS` property
- Can Mountebank proxy batch request?
- Async Support for imposterRepository needs to be deeper.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mountebank.