├── .nvmrc ├── .node-version ├── .npmrc ├── test ├── data │ ├── class-templates │ │ └── test.ejs │ └── dto-2-class │ │ ├── normalize_02.js │ │ ├── normalize_03.js │ │ └── normalize_01.js ├── expected │ ├── get-response │ │ ├── 03.json │ │ ├── 01.json │ │ └── 02.json │ ├── mock-server │ │ ├── 01.json │ │ ├── 04.json │ │ ├── 07-2.json │ │ ├── 07.json │ │ ├── 02.json │ │ ├── 02-2.json │ │ ├── 07-1.json │ │ ├── 06.json │ │ ├── 05.json │ │ └── 03.json │ ├── dto-import │ │ ├── AddressResponseWsDTO.json │ │ ├── CountryWsDTO.json │ │ ├── ComplexDTO.json │ │ └── AddressWsDTO.json │ ├── swagger-import │ │ ├── response_schema_02.json │ │ ├── request_schema_02.json │ │ ├── response_schema_01.json │ │ ├── desc_01.json │ │ └── desc_02.json │ ├── dto-2-class │ │ ├── normalize_03.js │ │ ├── ComplexDTO-es6flow.js │ │ ├── normalize_01.js │ │ ├── AddressWsDTO-es6flow-4.js │ │ └── ComplexDTO-es6.js │ └── dto-response-func │ │ ├── RuleWsDTO.js │ │ ├── success-faker.json │ │ └── ResponseFuncTestDTO.js ├── tests-dto-response-func.js ├── tests-validator-responses.js ├── tests-dto-import.js ├── tests-preferences.js ├── tests-swagger-import.js ├── tests.js └── tests-get-response.js ├── demo ├── rest │ ├── products │ │ ├── # │ │ │ ├── GET │ │ │ │ ├── request_schema.json │ │ │ │ ├── mock │ │ │ │ │ ├── success.json │ │ │ │ │ ├── tunnel-latest.json │ │ │ │ │ ├── success.headers.json │ │ │ │ │ └── error.json │ │ │ │ ├── response_schema.json │ │ │ │ ├── desc.json │ │ │ │ └── .store.json │ │ │ └── OPTIONS │ │ │ │ ├── request_schema.json │ │ │ │ ├── mock │ │ │ │ ├── success.json │ │ │ │ └── error.json │ │ │ │ ├── response_schema.json │ │ │ │ ├── .store.json │ │ │ │ └── desc.json │ │ ├── #search │ │ │ └── GET │ │ │ │ ├── request_schema.json │ │ │ │ ├── mock │ │ │ │ ├── success.json │ │ │ │ └── error.json │ │ │ │ ├── response_schema.json │ │ │ │ ├── .store.json │ │ │ │ └── desc.json │ │ ├── #{productCode} │ │ │ ├── GET │ │ │ │ ├── mock │ │ │ │ │ ├── error.json │ │ │ │ │ ├── success-2.json │ │ │ │ │ ├── success-207.json │ │ │ │ │ ├── success-default.json │ │ │ │ │ ├── .request_data.json │ │ │ │ │ ├── func.json │ │ │ │ │ ├── request-data.json │ │ │ │ │ ├── success-1.json │ │ │ │ │ ├── faker.json │ │ │ │ │ ├── success.json │ │ │ │ │ └── deep-validation.json │ │ │ │ ├── request_schema.json │ │ │ │ ├── desc.json │ │ │ │ ├── .store.json │ │ │ │ └── response_schema.json │ │ │ └── POST │ │ │ │ ├── mock │ │ │ │ ├── error.json │ │ │ │ ├── .success_validation │ │ │ │ ├── tunnel-latest.json │ │ │ │ └── success.json │ │ │ │ ├── request_schema.json │ │ │ │ ├── response_schema.json │ │ │ │ ├── .store.json │ │ │ │ └── desc.json │ │ └── #{productCode}#static │ │ │ └── GET │ │ │ ├── mock │ │ │ ├── error.json │ │ │ ├── document.txt │ │ │ ├── success.json │ │ │ ├── javascript.js │ │ │ ├── styles.css │ │ │ ├── example.gif │ │ │ ├── example.jpg │ │ │ ├── example.png │ │ │ └── example-202.png │ │ │ ├── request_schema.json │ │ │ ├── response_schema.json │ │ │ ├── desc.json │ │ │ └── .store.json │ ├── _DTO │ │ ├── RuleWsDTO.json │ │ ├── AddressResponseWsDTO.json │ │ ├── PriceDTO.json │ │ ├── ResponseFuncLoopDTO.json │ │ ├── CountryWsDTO.json │ │ ├── Geocode.json │ │ ├── AddressComponent.json │ │ ├── GeocodeResult.json │ │ ├── ComplexDTO.json │ │ ├── AddressWsDTO.json │ │ ├── ResponseFuncTestDTO.json │ │ └── CardDTO.json │ ├── search │ │ ├── #search.{query}.results.json │ │ │ └── GET │ │ │ │ ├── request_schema.json │ │ │ │ ├── response_schema.json │ │ │ │ ├── mock │ │ │ │ ├── success.json │ │ │ │ ├── error-401.json │ │ │ │ └── error.json │ │ │ │ ├── .store.json │ │ │ │ └── desc.json │ │ └── #users#{userId}#products#{productCode}#available │ │ │ └── GET │ │ │ ├── request_schema.json │ │ │ ├── response_schema.json │ │ │ ├── mock │ │ │ ├── success.json │ │ │ └── error.json │ │ │ ├── .store.json │ │ │ └── desc.json │ ├── _fallbacks │ │ └── # │ │ │ └── OPTIONS │ │ │ ├── mock │ │ │ └── success.json │ │ │ └── desc.json │ └── _collections │ │ └── bug12.json ├── public │ └── js │ │ └── javascript.js ├── index.js ├── func2 │ └── image.js ├── func │ └── price.js ├── options.js └── tunnel.js ├── .travis.yml ├── init.js ├── src ├── templates │ ├── func-array.tpl │ ├── response_func_header.tpl │ ├── func.tpl │ └── dto_es6.ejs ├── libraries │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ └── css │ │ ├── highlight.min.css │ │ └── json-formatter-js.min.css └── app │ └── css │ └── styles.css ├── .eslintignore ├── lib ├── constants │ ├── ignore-general.js │ └── ignore-in-rest-root.js ├── cli │ ├── swagger-import-cli.js │ ├── version-cli.js │ ├── ask │ │ ├── func-path.js │ │ ├── path.js │ │ ├── naming.js │ │ ├── default-config.js │ │ ├── ssl.js │ │ ├── url-settings.js │ │ ├── tunnel.js │ │ ├── swagger-import.js │ │ └── headers.js │ ├── validate-cli.js │ ├── help-cli.js │ └── collections-cli.js ├── getCertificate.js ├── commands │ ├── get-collection.js │ ├── delete-collection.js │ ├── get-currently-selected-responses.js │ ├── create-defined-directories.js │ └── activate-collection.js ├── defaults │ └── options-defaults.js ├── controller │ ├── FileOpenController.js │ ├── PreferencesController.js │ ├── SwaggerImportController.js │ ├── DTOController.js │ ├── UiController.js │ ├── ValidatorController.js │ ├── SchemaController.js │ └── CollectionController.js ├── SwaggerDefinition.js ├── SwaggerUtils.js ├── SwaggerPath.js ├── SwaggerLog.js ├── ValidatorLog.js └── ValidatorResponse.js ├── doc ├── readme-faker.md ├── readme-collections.md ├── readme-mock-functions.md ├── readme-query-params.md ├── readme-path-params.md ├── readme-response-header.md ├── readme-response-validation.md ├── readme-expected-response.md ├── readme-tunnel.md ├── readme-express-middleware.md ├── readme-dto-2-class.md ├── readme-swagger-import.md ├── readme-middleware.md ├── readme-ui-documentation.md ├── readme-folder-structure.md └── readme-usage-examples.md ├── .gitignore ├── .eslintrc.js ├── views ├── menu.ejs ├── method-panel.ejs ├── method-badge.ejs ├── scripts.ejs ├── group.ejs ├── head.ejs ├── validate-result-modal.ejs ├── parameter-desc.ejs ├── validate-modal.ejs ├── validate-single-modal.ejs ├── swagger-import-modal.ejs ├── tab-pane-response.ejs ├── service.ejs ├── collection-modal.ejs ├── collection-new-modal.ejs ├── preferences-modal.ejs ├── tab-pane-request.ejs ├── service-schema.ejs ├── add-endpoint-modal.ejs ├── default.ejs ├── method-modal.ejs ├── default-page-header.ejs ├── dto-modal.ejs └── tab-pane-mock.ejs ├── .editorconfig ├── .npmignore ├── LICENSE ├── dash4.config.js ├── package.json ├── mock-server.js └── readme.md /.nvmrc: -------------------------------------------------------------------------------- 1 | 12.14.0 -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | 12.14.0 -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | save-exact=true -------------------------------------------------------------------------------- /test/data/class-templates/test.ejs: -------------------------------------------------------------------------------- 1 | Test 2 | -------------------------------------------------------------------------------- /demo/rest/products/#/GET/request_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/rest/products/#/OPTIONS/request_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/rest/products/#search/GET/request_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/error.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/get-response/03.json: -------------------------------------------------------------------------------- 1 | {"success":true} -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/request_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/POST/mock/error.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/POST/request_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "12" 4 | -------------------------------------------------------------------------------- /demo/public/js/javascript.js: -------------------------------------------------------------------------------- 1 | console.log('hello world'); 2 | -------------------------------------------------------------------------------- /demo/rest/_DTO/RuleWsDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "value": "string" 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/error.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/POST/response_schema.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /test/expected/mock-server/01.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true 3 | } -------------------------------------------------------------------------------- /test/expected/mock-server/04.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/request_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/response_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/get-response/01.json: -------------------------------------------------------------------------------- 1 | {"success":true,"productData":{}} -------------------------------------------------------------------------------- /demo/rest/products/#/GET/mock/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/document.txt: -------------------------------------------------------------------------------- 1 | hi 2 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/success.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /demo/rest/search/#search.{query}.results.json/GET/request_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /init.js: -------------------------------------------------------------------------------- 1 | var initCli = require('./lib/cli/init-cli'); 2 | initCli(); 3 | -------------------------------------------------------------------------------- /demo/rest/_DTO/AddressResponseWsDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": "boolean" 3 | } -------------------------------------------------------------------------------- /demo/rest/_fallbacks/#/OPTIONS/mock/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "ok": true 3 | } 4 | -------------------------------------------------------------------------------- /demo/rest/products/#/GET/mock/tunnel-latest.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#/OPTIONS/mock/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#search/GET/mock/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true 3 | } -------------------------------------------------------------------------------- /test/expected/mock-server/07-2.json: -------------------------------------------------------------------------------- 1 | 2 | 3 | {"success":true,"productCode":2} -------------------------------------------------------------------------------- /test/expected/mock-server/07.json: -------------------------------------------------------------------------------- 1 | 2 | 3 | {"success":true,"productData":{}} -------------------------------------------------------------------------------- /demo/rest/products/#/GET/response_schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": "boolean" 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#/OPTIONS/response_schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": "boolean" 3 | } -------------------------------------------------------------------------------- /demo/rest/search/#search.{query}.results.json/GET/response_schema.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } -------------------------------------------------------------------------------- /src/templates/func-array.tpl: -------------------------------------------------------------------------------- 1 | _getArray(function () { 2 | return <%=data%>; 3 | }) -------------------------------------------------------------------------------- /demo/rest/_DTO/PriceDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "currency": "string", 3 | "price": "number" 4 | } -------------------------------------------------------------------------------- /demo/rest/products/#search/GET/response_schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": "boolean" 3 | } -------------------------------------------------------------------------------- /test/expected/dto-import/AddressResponseWsDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": "boolean" 3 | } -------------------------------------------------------------------------------- /test/expected/swagger-import/response_schema_02.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": "boolean" 3 | } -------------------------------------------------------------------------------- /demo/rest/_DTO/ResponseFuncLoopDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "funcLoop": "$ref-ResponseFuncLoopDTO" 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/POST/mock/.success_validation: -------------------------------------------------------------------------------- 1 | { 2 | "counter": 1 3 | } -------------------------------------------------------------------------------- /demo/rest/search/#users#{userId}#products#{productCode}#available/GET/request_schema.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/expected/mock-server/02.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "productData": {} 4 | } 5 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/javascript.js: -------------------------------------------------------------------------------- 1 | console.log('hello world'); 2 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/styles.css: -------------------------------------------------------------------------------- 1 | .a-button { 2 | border: 0; 3 | } 4 | -------------------------------------------------------------------------------- /demo/rest/search/#search.{query}.results.json/GET/mock/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true 3 | } -------------------------------------------------------------------------------- /demo/rest/search/#users#{userId}#products#{productCode}#available/GET/response_schema.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/success-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "productCode": 2 4 | } -------------------------------------------------------------------------------- /demo/rest/_DTO/CountryWsDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "string", 3 | "name": "string", 4 | "value": "string" 5 | } -------------------------------------------------------------------------------- /demo/rest/_DTO/Geocode.json: -------------------------------------------------------------------------------- 1 | { 2 | "results": [ 3 | "$ref-GeocodeResult" 4 | ], 5 | "status": "string" 6 | } -------------------------------------------------------------------------------- /demo/rest/products/#/GET/mock/success.headers.json: -------------------------------------------------------------------------------- 1 | { 2 | "Response-Custom-Header": "Response-Custom-Header" 3 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/success-207.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "productData": {} 4 | } 5 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/success-default.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "productData": {} 4 | } -------------------------------------------------------------------------------- /demo/rest/search/#users#{userId}#products#{productCode}#available/GET/mock/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true 3 | } -------------------------------------------------------------------------------- /test/expected/dto-import/CountryWsDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": "string", 3 | "name": "string", 4 | "value": "string" 5 | } -------------------------------------------------------------------------------- /test/expected/mock-server/02-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "currentPage": 12, 4 | "productCode": "31221" 5 | } 6 | -------------------------------------------------------------------------------- /test/expected/mock-server/07-1.json: -------------------------------------------------------------------------------- 1 | 2 | 3 | {"success":true,"productCode":1,"productCodeDynamic":"1","productData":{}} -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /node_modules/ 3 | /test/ 4 | /src/libraries/ 5 | /src/swagger/ 6 | /src/templates/ 7 | /demo/ 8 | -------------------------------------------------------------------------------- /demo/rest/_DTO/AddressComponent.json: -------------------------------------------------------------------------------- 1 | { 2 | "long_name": "string", 3 | "short_name": "string", 4 | "types": [ "string" ] 5 | } -------------------------------------------------------------------------------- /lib/constants/ignore-general.js: -------------------------------------------------------------------------------- 1 | 2 | var ignoreGeneral = [ 3 | '.DS_Store', 4 | ]; 5 | 6 | module.exports = ignoreGeneral; 7 | -------------------------------------------------------------------------------- /demo/rest/products/#/OPTIONS/.store.json: -------------------------------------------------------------------------------- 1 | { 2 | "validation": { 3 | "success": { 4 | "counter": 0 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /demo/rest/products/#search/GET/.store.json: -------------------------------------------------------------------------------- 1 | { 2 | "validation": { 3 | "success": { 4 | "counter": 0 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /demo/index.js: -------------------------------------------------------------------------------- 1 | 2 | var mockServer = require('./../mock-server.js'); 3 | var options = require('./options'); 4 | 5 | mockServer(options); 6 | -------------------------------------------------------------------------------- /demo/rest/_DTO/GeocodeResult.json: -------------------------------------------------------------------------------- 1 | { 2 | "address_components": [ 3 | "$ref-AddressComponent" 4 | ], 5 | "formatted_address": "string" 6 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/.request_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "currentPage": 3, 3 | "params": { 4 | "productCode": "test" 5 | } 6 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/func.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": <%-image();%>, 3 | "highlight": true, 4 | "quantity": 3423 5 | } 6 | -------------------------------------------------------------------------------- /demo/rest/search/#search.{query}.results.json/GET/.store.json: -------------------------------------------------------------------------------- 1 | { 2 | "validation": { 3 | "success": { 4 | "counter": 1 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /test/expected/mock-server/06.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "Unauthorized", 5 | "type": "ConversionError" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /src/libraries/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smollweide/node-mock-server/HEAD/src/libraries/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/libraries/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smollweide/node-mock-server/HEAD/src/libraries/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/POST/mock/tunnel-latest.json: -------------------------------------------------------------------------------- 1 | { 2 | "test": "dsfsd", 3 | "productCode": "12", 4 | "query": { 5 | "queryKey": "value2" 6 | } 7 | } -------------------------------------------------------------------------------- /demo/rest/search/#users#{userId}#products#{productCode}#available/GET/.store.json: -------------------------------------------------------------------------------- 1 | { 2 | "validation": { 3 | "success": { 4 | "counter": 1 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /src/libraries/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smollweide/node-mock-server/HEAD/src/libraries/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/libraries/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smollweide/node-mock-server/HEAD/src/libraries/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smollweide/node-mock-server/HEAD/demo/rest/products/#{productCode}#static/GET/mock/example.gif -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smollweide/node-mock-server/HEAD/demo/rest/products/#{productCode}#static/GET/mock/example.jpg -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smollweide/node-mock-server/HEAD/demo/rest/products/#{productCode}#static/GET/mock/example.png -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/request-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "currentPage": <%=query.currentPage%>, 4 | "productCode": "<%=params.productCode%>" 5 | } 6 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}#static/GET/mock/example-202.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smollweide/node-mock-server/HEAD/demo/rest/products/#{productCode}#static/GET/mock/example-202.png -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/success-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "productCode": 1, 4 | "productCodeDynamic": "<%-params.productCode%>", 5 | "productData": {} 6 | } 7 | -------------------------------------------------------------------------------- /demo/rest/search/#search.{query}.results.json/GET/mock/error-401.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "Unauthorized", 5 | "type": "ConversionError" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /doc/readme-faker.md: -------------------------------------------------------------------------------- 1 | # Faker in mock data 2 | 3 | - [Faker](https://www.npmjs.com/package/faker) 4 | - [Use Faker in mock data](/demo/rest/products/%23%7BproductCode%7D/GET/mock/faker.json#L4) 5 | -------------------------------------------------------------------------------- /test/expected/mock-server/05.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "No valid SearchConfig found for the current context", 5 | "type": "ConversionError" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | yarn.lock 3 | node_modules 4 | /preferences.json 5 | /demo/rest/*/*/*/mock/response.txt 6 | /test/tmp 7 | /test/func-imported 8 | /tmp 9 | npm-debug.log 10 | /func-imported 11 | -------------------------------------------------------------------------------- /demo/rest/products/#/GET/mock/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "No valid SearchConfig found for the current context", 5 | "type": "ConversionError" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /demo/rest/products/#/OPTIONS/mock/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "No valid SearchConfig found for the current context", 5 | "type": "ConversionError" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /demo/rest/products/#search/GET/mock/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "No valid SearchConfig found for the current context", 5 | "type": "ConversionError" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/GET/mock/faker.json: -------------------------------------------------------------------------------- 1 | { 2 | "price": <%-price(12,'CHF');%>, 3 | "email": "<%-faker.internet.email();%>", 4 | "cards": [<%-JSON.stringify(faker.helpers.createCard());%>] 5 | } 6 | -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/POST/.store.json: -------------------------------------------------------------------------------- 1 | { 2 | "validation": { 3 | "success": { 4 | "counter": 9 5 | }, 6 | "tunnel-latest": { 7 | "counter": 4 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /demo/rest/search/#search.{query}.results.json/GET/mock/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "No valid SearchConfig found for the current context", 5 | "type": "ConversionError" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /doc/readme-collections.md: -------------------------------------------------------------------------------- 1 | 2 | # Collections 3 | 4 | Collections allow you to store your current selected responses and share it with your team members. 5 | For that you can use the UI or the both [CLI commands](/readme.md#L121). 6 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'extends': '@namics/eslint-config/configurations/es5-node.js', 3 | 'rules': { 4 | 'complexity': 0, 5 | 'valid-jsdoc': 0, 6 | 'require-jsdoc': 0, 7 | 'no-useless-escape': 0, 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /test/data/dto-2-class/normalize_02.js: -------------------------------------------------------------------------------- 1 | module.export = { 2 | 'results': [ 3 | { 4 | 'address_components': [ 5 | '$ref-AddressComponent' 6 | ], 7 | 'formatted_address': 'string' 8 | } 9 | ], 10 | 'status': 'string' 11 | }; -------------------------------------------------------------------------------- /demo/rest/_collections/bug12.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "NUM-12", 3 | "description": "Sticky header - see spec for details", 4 | "selectedResponses": { 5 | "products/#{productCode}/GET": "success", 6 | "products/#search/GET": "error" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /demo/rest/search/#users#{userId}#products#{productCode}#available/GET/mock/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "errors": [ 3 | { 4 | "message": "No valid SearchConfig found for the current context", 5 | "type": "ConversionError" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /doc/readme-mock-functions.md: -------------------------------------------------------------------------------- 1 | # Functions in mock data 2 | 3 | - [Add function](/demo/func/price.js) 4 | - [Add function folder to option](/demo/options.js#L15) 5 | - [Use function in mock data](/demo/rest/products/%23%7BproductCode%7D/GET/mock/func.json#L2) 6 | -------------------------------------------------------------------------------- /test/expected/get-response/02.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "body": "", 4 | "query": "", 5 | "param": "test", 6 | "faker": "Benjamin8@hotmail.com", 7 | "price": { 8 | "currency": "CHF", 9 | "price": { 10 | "value": 12 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demo/rest/_DTO/ComplexDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [ 3 | { 4 | "country": "$ref-CountryWsDTO", 5 | "email": "string" 6 | } 7 | ], 8 | "items": [ 9 | "$ref-ImageDTO" 10 | ], 11 | "parameters": { 12 | "additional": "string" 13 | } 14 | } -------------------------------------------------------------------------------- /demo/rest/products/#{productCode}/POST/mock/success.json: -------------------------------------------------------------------------------- 1 | { 2 | "success": true, 3 | "body": "<%-body.test%>", 4 | "query": "<%-query.test%>", 5 | "param": "<%-params.productCode%>", 6 | "faker": "<%-faker.internet.email();%>", 7 | "price": <%-price(12,'CHF');%> 8 | } 9 | -------------------------------------------------------------------------------- /demo/func2/image.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | 4 | image: function (url, alt) { 5 | 6 | url = url || 'http://lorempixel.com/100/100/people'; 7 | alt = alt || 'Alt'; 8 | 9 | return JSON.stringify({ 10 | url: url, 11 | alt: alt 12 | }); 13 | } 14 | 15 | }; -------------------------------------------------------------------------------- /demo/rest/products/#/GET/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "Returns a list of products", 3 | "security": [], 4 | "protected": false, 5 | "status": "open", 6 | "response": { 7 | "statusCode": 200, 8 | "schema": { 9 | "type": "application/json" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/data/dto-2-class/normalize_03.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'list': [ 3 | { 4 | 'country': '$ref-CountryWsDTO', 5 | 'email': 'string' 6 | } 7 | ], 8 | 'items': [ 9 | '$ref-ImageDTO' 10 | ], 11 | 'parameters': { 12 | 'additional': 'string' 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /test/expected/dto-import/ComplexDTO.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [ 3 | { 4 | "country": "$ref-CountryWsDTO", 5 | "email": "string" 6 | } 7 | ], 8 | "items": [ 9 | "$ref-ImageDTO" 10 | ], 11 | "parameters": { 12 | "additional": "string" 13 | } 14 | } -------------------------------------------------------------------------------- /views/menu.ejs: -------------------------------------------------------------------------------- 1 |
11 | -------------------------------------------------------------------------------- /demo/rest/_fallbacks/#/OPTIONS/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "Default Response for OPTIONS request", 3 | "security": [], 4 | "protected": false, 5 | "status": "open", 6 | "response": { 7 | "statusCode": 200, 8 | "schema": { 9 | "type": "application/json" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /demo/rest/products/#/OPTIONS/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "desc": "Returns a list of products (Options)", 3 | "security": [], 4 | "protected": false, 5 | "status": "open", 6 | "response": { 7 | "statusCode": 200, 8 | "schema": { 9 | "type": "application/json" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /demo/func/price.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | 4 | price: function (price, currency) { 5 | 6 | price = price || 0; 7 | currency = currency || '€'; 8 | 9 | return JSON.stringify({ 10 | currency: currency, 11 | price: { 12 | value: price 13 | } 14 | }); 15 | } 16 | 17 | }; -------------------------------------------------------------------------------- /views/method-panel.ejs: -------------------------------------------------------------------------------- 1 |<%=method.desc.desc%>
5 |.json" response file.
5 | By using the collections you can easily switch between tunneling or not.
6 |
7 | * `$ node collections tunnel` will activate the tunnel everwhere
8 | * `$ node collections tunnel-latest` will activate all latest tunnel responses
9 | * `$ node collections reset` set all responses to default
10 |
11 | [example](/demo/options.js#L57)
12 |
--------------------------------------------------------------------------------
/demo/rest/products/#{productCode}#static/GET/.store.json:
--------------------------------------------------------------------------------
1 | {
2 | "validation": {
3 | "example.png": {
4 | "counter": 0
5 | },
6 | "success": {
7 | "counter": 0
8 | },
9 | "document.txt": {
10 | "counter": 0
11 | },
12 | "example.gif": {
13 | "counter": 0
14 | },
15 | "example.jpg": {
16 | "counter": 0
17 | },
18 | "example.xml": {
19 | "counter": 0
20 | },
21 | "javascript.js": {
22 | "counter": 0
23 | },
24 | "success.json": {
25 | "counter": 0
26 | },
27 | "styles.css": {
28 | "counter": 0
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/demo/rest/_DTO/AddressWsDTO.json:
--------------------------------------------------------------------------------
1 | {
2 | "country": "$ref-CountryWsDTO",
3 | "countryIsocode": "string",
4 | "country2": "$ref-CountryWsDTO",
5 | "email": "string",
6 | "firstName": "string",
7 | "id": "string",
8 | "lastName": "string",
9 | "line1": "string",
10 | "phone": "string",
11 | "postalCode": "string",
12 | "streetName": "string",
13 | "streetNumber": "string",
14 | "title": "string",
15 | "titleCode": "string",
16 | "town": "string",
17 | "list": [
18 | {
19 | "country": "$ref-CountryWsDTO",
20 | "email": "string"
21 | }
22 | ],
23 | "items": [
24 | "$ref-CountryWsDTO"
25 | ]
26 | }
--------------------------------------------------------------------------------
/views/validate-result-modal.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/expected/dto-import/AddressWsDTO.json:
--------------------------------------------------------------------------------
1 | {
2 | "country": "$ref-CountryWsDTO",
3 | "countryIsocode": "string",
4 | "country2": "$ref-CountryWsDTO",
5 | "email": "string",
6 | "firstName": "string",
7 | "id": "string",
8 | "lastName": "string",
9 | "line1": "string",
10 | "phone": "string",
11 | "postalCode": "string",
12 | "streetName": "string",
13 | "streetNumber": "string",
14 | "title": "string",
15 | "titleCode": "string",
16 | "town": "string",
17 | "list": [
18 | {
19 | "country": "$ref-CountryWsDTO",
20 | "email": "string"
21 | }
22 | ],
23 | "items": [
24 | "$ref-CountryWsDTO"
25 | ]
26 | }
--------------------------------------------------------------------------------
/test/expected/swagger-import/request_schema_02.json:
--------------------------------------------------------------------------------
1 | {
2 | "country": "$ref-CountryWsDTO",
3 | "countryIsocode": "string",
4 | "country2": "$ref-CountryWsDTO",
5 | "email": "string",
6 | "firstName": "string",
7 | "id": "string",
8 | "lastName": "string",
9 | "line1": "string",
10 | "phone": "string",
11 | "postalCode": "string",
12 | "streetName": "string",
13 | "streetNumber": "string",
14 | "title": "string",
15 | "titleCode": "string",
16 | "town": "string",
17 | "list": [
18 | {
19 | "country": "$ref-CountryWsDTO",
20 | "email": "string"
21 | }
22 | ],
23 | "items": [
24 | "$ref-CountryWsDTO"
25 | ]
26 | }
--------------------------------------------------------------------------------
/test/expected/swagger-import/response_schema_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "country": "$ref-CountryWsDTO",
3 | "countryIsocode": "string",
4 | "country2": "$ref-CountryWsDTO",
5 | "email": "string",
6 | "firstName": "string",
7 | "id": "string",
8 | "lastName": "string",
9 | "line1": "string",
10 | "phone": "string",
11 | "postalCode": "string",
12 | "streetName": "string",
13 | "streetNumber": "string",
14 | "title": "string",
15 | "titleCode": "string",
16 | "town": "string",
17 | "list": [
18 | {
19 | "country": "$ref-CountryWsDTO",
20 | "email": "string"
21 | }
22 | ],
23 | "items": [
24 | "$ref-CountryWsDTO"
25 | ]
26 | }
--------------------------------------------------------------------------------
/lib/cli/ask/default-config.js:
--------------------------------------------------------------------------------
1 | var inquirer = require('inquirer');
2 | var Promise = require('es6-promise-polyfill').Promise;
3 |
4 | function askForDefaultConfig() {
5 | return new Promise((resolve, reject) => {
6 | inquirer.prompt([
7 | {
8 | type: 'list',
9 | name: 'defaultConfig',
10 | choices: ['Yes', 'No'],
11 | message: 'Do you want to use the default configuration?',
12 | default: 'Yes',
13 | },
14 | ]).then(function (answers) {
15 | if (answers.defaultConfig.toUpperCase() === 'YES') {
16 | reject();
17 | return;
18 | }
19 | resolve({});
20 | });
21 | });
22 | }
23 |
24 | module.exports = askForDefaultConfig;
25 |
--------------------------------------------------------------------------------
/demo/rest/products/#{productCode}/GET/.store.json:
--------------------------------------------------------------------------------
1 | {
2 | "validation": {
3 | "faker": {
4 | "counter": 6
5 | },
6 | "func": {
7 | "counter": 0
8 | },
9 | "request-data": {
10 | "counter": 1
11 | },
12 | "success-1": {
13 | "counter": 3
14 | },
15 | "success-2": {
16 | "counter": 1
17 | },
18 | "success-default": {
19 | "counter": 1
20 | },
21 | "success": {
22 | "counter": 1
23 | },
24 | "deep-validation": {
25 | "counter": 0
26 | },
27 | "deep-validation.json": {
28 | "counter": 1
29 | },
30 | "success-207": {
31 | "counter": 1
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/demo/rest/products/#{productCode}/GET/response_schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "productCode": "string",
3 | "price": "$ref-PriceDTO",
4 | "email": "string",
5 | "success": "boolean",
6 | "highlight": "boolean",
7 | "quantity": "integer",
8 | "currentPage": "string",
9 | "cards": [
10 | "$ref-CardDTO"
11 | ],
12 | "arrayString": [
13 | "string"
14 | ],
15 | "arrayNumber": [
16 | "number"
17 | ],
18 | "arrayObject": [
19 | {
20 | "name": "string"
21 | }
22 | ],
23 | "arrayArray": [
24 | [
25 | {
26 | "name": "string"
27 | }
28 | ]
29 | ],
30 | "image": {
31 | "url": "string",
32 | "alt": "string"
33 | }
34 | }
--------------------------------------------------------------------------------
/views/parameter-desc.ejs:
--------------------------------------------------------------------------------
1 | <% if (itemsObj && items.length > 0) { %>
2 | <%=itemsTitle%>
3 |
4 | <% for(var m=0; m
5 | <% var item = items[m]; %>
6 | -
7 | <%=item.name%>:
8 |
9 | <% if (item.required) { %>
10 | required
11 | <% } %>
12 | (<%=item.type%>)
13 |
14 |
<%-item.desc%>
15 |
16 | <% if (item.descList && item.descList.length > 0) { %>
17 | <% for(var n=0; n
18 | - <%-item.descList[n]%>
19 | <% } %>
20 | <% } %>
21 |
22 |
23 | <% } %>
24 |
25 | <% } %>
--------------------------------------------------------------------------------
/lib/cli/validate-cli.js:
--------------------------------------------------------------------------------
1 | /* eslint no-console: 0 */
2 |
3 | var util = require('util');
4 | var extend = util._extend;
5 | var _defaults = require('../defaults/options-defaults');
6 | var ValidatorResponses = require('../ValidatorResponses');
7 |
8 | function validateCli(runServer, options) {
9 |
10 | options = extend(_defaults, options || {});
11 | options = extend(options, {
12 | onServerStarted: function (app, server) {
13 | var validatorResponses = new ValidatorResponses({
14 | restPath: options.restPath,
15 | }, options);
16 |
17 | server.close();
18 | return validatorResponses;
19 | },
20 | });
21 |
22 | runServer(options);
23 | }
24 |
25 | module.exports = validateCli;
26 |
--------------------------------------------------------------------------------
/views/validate-modal.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/lib/cli/help-cli.js:
--------------------------------------------------------------------------------
1 | /* eslint no-console: 0 */
2 |
3 | function helpCli() {
4 | console.log('');
5 | console.log('usage: node
21 |
22 | (
23 | Errors: <%=validation.counter.error%>,
24 | Warnings: <%=validation.counter.warn%>,
25 | Infos: <%=validation.counter.info%>,
26 | Success: <%=validation.counter.success%>
27 | )
28 |
29 |
35 | Open Result
36 |
37 |
38 | <% } %>
39 | <% for(var i=0; i
40 | <% var group = apiData[i]; %>
41 | <% include group.ejs %>
42 | <% } %>
43 |
49 | + add new endpoint
50 |
51 |
52 |
53 |
54 |
55 |
58 |
59 |
60 |
61 | <% include add-endpoint-modal.ejs %>
62 | <% include swagger-import-modal.ejs %>
63 | <% include preferences-modal.ejs %>
64 | <% include validate-result-modal.ejs %>
65 | <% include validate-single-modal.ejs %>
66 | <% include validate-modal.ejs %>
67 | <% include scripts.ejs %>
68 |