gunubin-mock-server
v0.3.9
Published
Mock API Client from JSON Hyper Schema
Downloads
4
Readme
gunubin-mock-server
Installation
npm install --save-dev gunubin-mock-server
Usage
import GunubinMockServer from 'gunubin-mock-server';
const mockServer = new GunubinMockServer();
mockServer.start({
glob: 'pathto/schema.json',
port: 3000
});
mockServer.extend('/todo', {
foo: 'bar'
});
mockServer.extend('/todo', req => {
return {
foo: req.params.param1
}
});
mockServer.extendResource('todo', {
foo: 'bar'
});
mockServer.override('/todo', {
foo: 'foo',
bar: 'bar'
});
mockServer.overrideResource('todo', {
foo: 'foo',
bar: 'bar'
});
mockServer.globalValidResponseSchemata = [{
'title': 'エラー',
'description': 'エラーレスポンスを表します。',
'stability': 'prototype',
'strictProperties': true,
'type': [
'object'
],
'properties': {
'type': {
'description': 'エラーの種別',
'enum': [
'foo_error',
'bar_error',
]
},
'status': {
'status': {
'description': 'ステータスコード',
'example': 400,
'readOnly': true,
'type': [
'integer'
]
}
}
},
'required': [
'type',
'status'
]
}];
mockServer.override('/task', {
type: 'hoge_error',
status: 400
});