-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from smollweide/develop
v0.16.0
- Loading branch information
Showing
38 changed files
with
631 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ node_modules | |
/tmp | ||
npm-debug.log | ||
/func-imported | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello world'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"validation": { | ||
"example.png": { | ||
"counter": 0 | ||
}, | ||
"success": { | ||
"counter": 0 | ||
}, | ||
"document.txt": { | ||
"counter": 0 | ||
}, | ||
"example.gif": { | ||
"counter": 0 | ||
}, | ||
"example.jpg": { | ||
"counter": 0 | ||
}, | ||
"example.xml": { | ||
"counter": 0 | ||
}, | ||
"javascript.js": { | ||
"counter": 0 | ||
}, | ||
"success.json": { | ||
"counter": 0 | ||
}, | ||
"styles.css": { | ||
"counter": 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"desc": "Returns product image", | ||
"security": [], | ||
"protected": false, | ||
"status": "open", | ||
"request": { | ||
"uri": { | ||
"parameters": [ | ||
{ | ||
"name": "productCode", | ||
"required": true, | ||
"type": "string", | ||
"desc": "Product identifier" | ||
} | ||
] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"schema": { | ||
"type": "application/json" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hi |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 120 additions & 0 deletions
120
demo/rest/products/#{productCode}#static/GET/mock/example.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?xml version="1.0"?> | ||
<catalog> | ||
<book id="bk101"> | ||
<author>Gambardella, Matthew</author> | ||
<title>XML Developer's Guide</title> | ||
<genre>Computer</genre> | ||
<price>44.95</price> | ||
<publish_date>2000-10-01</publish_date> | ||
<description>An in-depth look at creating applications | ||
with XML.</description> | ||
</book> | ||
<book id="bk102"> | ||
<author>Ralls, Kim</author> | ||
<title>Midnight Rain</title> | ||
<genre>Fantasy</genre> | ||
<price>5.95</price> | ||
<publish_date>2000-12-16</publish_date> | ||
<description>A former architect battles corporate zombies, | ||
an evil sorceress, and her own childhood to become queen | ||
of the world.</description> | ||
</book> | ||
<book id="bk103"> | ||
<author>Corets, Eva</author> | ||
<title>Maeve Ascendant</title> | ||
<genre>Fantasy</genre> | ||
<price>5.95</price> | ||
<publish_date>2000-11-17</publish_date> | ||
<description>After the collapse of a nanotechnology | ||
society in England, the young survivors lay the | ||
foundation for a new society.</description> | ||
</book> | ||
<book id="bk104"> | ||
<author>Corets, Eva</author> | ||
<title>Oberon's Legacy</title> | ||
<genre>Fantasy</genre> | ||
<price>5.95</price> | ||
<publish_date>2001-03-10</publish_date> | ||
<description>In post-apocalypse England, the mysterious | ||
agent known only as Oberon helps to create a new life | ||
for the inhabitants of London. Sequel to Maeve | ||
Ascendant.</description> | ||
</book> | ||
<book id="bk105"> | ||
<author>Corets, Eva</author> | ||
<title>The Sundered Grail</title> | ||
<genre>Fantasy</genre> | ||
<price>5.95</price> | ||
<publish_date>2001-09-10</publish_date> | ||
<description>The two daughters of Maeve, half-sisters, | ||
battle one another for control of England. Sequel to | ||
Oberon's Legacy.</description> | ||
</book> | ||
<book id="bk106"> | ||
<author>Randall, Cynthia</author> | ||
<title>Lover Birds</title> | ||
<genre>Romance</genre> | ||
<price>4.95</price> | ||
<publish_date>2000-09-02</publish_date> | ||
<description>When Carla meets Paul at an ornithology | ||
conference, tempers fly as feathers get ruffled.</description> | ||
</book> | ||
<book id="bk107"> | ||
<author>Thurman, Paula</author> | ||
<title>Splish Splash</title> | ||
<genre>Romance</genre> | ||
<price>4.95</price> | ||
<publish_date>2000-11-02</publish_date> | ||
<description>A deep sea diver finds true love twenty | ||
thousand leagues beneath the sea.</description> | ||
</book> | ||
<book id="bk108"> | ||
<author>Knorr, Stefan</author> | ||
<title>Creepy Crawlies</title> | ||
<genre>Horror</genre> | ||
<price>4.95</price> | ||
<publish_date>2000-12-06</publish_date> | ||
<description>An anthology of horror stories about roaches, | ||
centipedes, scorpions and other insects.</description> | ||
</book> | ||
<book id="bk109"> | ||
<author>Kress, Peter</author> | ||
<title>Paradox Lost</title> | ||
<genre>Science Fiction</genre> | ||
<price>6.95</price> | ||
<publish_date>2000-11-02</publish_date> | ||
<description>After an inadvertant trip through a Heisenberg | ||
Uncertainty Device, James Salway discovers the problems | ||
of being quantum.</description> | ||
</book> | ||
<book id="bk110"> | ||
<author>O'Brien, Tim</author> | ||
<title>Microsoft .NET: The Programming Bible</title> | ||
<genre>Computer</genre> | ||
<price>36.95</price> | ||
<publish_date>2000-12-09</publish_date> | ||
<description>Microsoft's .NET initiative is explored in | ||
detail in this deep programmer's reference.</description> | ||
</book> | ||
<book id="bk111"> | ||
<author>O'Brien, Tim</author> | ||
<title>MSXML3: A Comprehensive Guide</title> | ||
<genre>Computer</genre> | ||
<price>36.95</price> | ||
<publish_date>2000-12-01</publish_date> | ||
<description>The Microsoft MSXML3 parser is covered in | ||
detail, with attention to XML DOM interfaces, XSLT processing, | ||
SAX and more.</description> | ||
</book> | ||
<book id="bk112"> | ||
<author>Galos, Mike</author> | ||
<title>Visual Studio 7: A Comprehensive Guide</title> | ||
<genre>Computer</genre> | ||
<price>49.95</price> | ||
<publish_date>2001-04-16</publish_date> | ||
<description>Microsoft Visual Studio 7 is explored in depth, | ||
looking at how Visual Basic, Visual C++, C#, and ASP+ are | ||
integrated into a comprehensive development | ||
environment.</description> | ||
</book> | ||
</catalog> |
1 change: 1 addition & 0 deletions
1
demo/rest/products/#{productCode}#static/GET/mock/javascript.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('hello world'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.a-button { | ||
border: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ | |
}, | ||
"deep-validation": { | ||
"counter": 0 | ||
}, | ||
"deep-validation.json": { | ||
"counter": 1 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Express Middleware | ||
|
||
For static content delivery beside the mock response itself, you can define express middleware. | ||
Read more in [express documentation](http://expressjs.com/en/4x/api.html#app.use). | ||
|
||
Each entry needs to be a function witch returns the `app.use` arguments. | ||
|
||
``` | ||
expressMiddleware: [ | ||
function (express) { | ||
return ['/public', express.static(__dirname + '/public')]; | ||
}, | ||
function (express) { | ||
return ['/dist', express.static(__dirname + '/dist')]; | ||
} | ||
], | ||
``` | ||
|
||
Express result: | ||
``` | ||
app.use('/public', express.static(__dirname + '/public')); | ||
app.use('/dist', express.static(__dirname + '/dist')); | ||
``` | ||
|
||
[example](/demo/index.js#L37) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Using the node-mock-server UI | ||
|
||
The mock server UI is available at _http://localhost:3003_ (or at the port you have defined via options). | ||
|
||
If the service you want to mock provides a Swagger definition and you have provided a swagger definition, you may perform an import via the small triangle button in the head of the UI page. | ||
|
||
In the same location you also find general preferences such as a response delay and you can trigger a validation of all responses. | ||
|
||
In addition to Swagger imports, you may also [define a resource path with a ReST method folder containing a mock directory](https://github.com/smollweide/node-mock-server/blob/master/doc/readme-folder-structure.md) manually by creating the appropriate folders in the file system. Once a resource has been defined that way, you can continue to work with the resource in the UI. Refresh the browser to see new resources after you have added them in the file system. | ||
|
||
The UI shows you a list of known resources. Alongside each resource there are buttons which allow you to work with the responses for that method. | ||
|
||
Click the button for a ReST method (e.g. GET) to define possible responses for that method. A popup appears that shows the possible responses and allows to add new responses. Initially there are no `success` and `error` responses defined, therefore you only see a `middleware` response. The node-mock-server can respond through a [middleware definition](https://github.com/smollweide/node-mock-server/blob/master/doc/readme-middleware.md), so *middleware* is always available. | ||
|
||
Hit *+Add* to add a new response and call it `success`. Your favorite JSON editor is fired up where you can enter the response. It will be stored as _success.json_ inside the _mock_ directory. | ||
|
||
After storing the response you can select the radiobutton in front of your new `success` response. A file _response.txt_ will be created alongside your possible responses, which stores your decision. All decisions can be captured, restored, reset and shared by means of a [collection](https://github.com/smollweide/node-mock-server/blob/master/doc/readme-collections.md). | ||
|
||
You can also add an `error` response and use the radiobutton in front of it to specify that the resource should respond with an error response. For an error response the default HTTP status code is 500, but you can specify a different status code by suffixing the name of your error response with the appropriate status code, like error-401. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.