Comparing version 1.1.6 to 1.1.7
@@ -0,1 +1,31 @@ | ||
<a name="1.1.7"></a> | ||
## 1.1.7 (2017-12-24) | ||
### chore | ||
* chore(travis): add support version v8.9 | ||
([dfab280](https://github.com/rymizuki/node-hariko/commit/dfab280)) | ||
* Add cors option | ||
([871635c](https://github.com/rymizuki/node-hariko/commit/871635c)) | ||
* feat(resource/parser): support carriage '\r' in source data | ||
([1114bba](https://github.com/rymizuki/node-hariko/commit/1114bba)) | ||
* Merge pull request #10 from ichiwa/patch-1 | ||
([db8127a](https://github.com/rymizuki/node-hariko/commit/db8127a)) | ||
* Merge pull request #12 from rymizuki/fix_failing_tests | ||
([ebaf9cb](https://github.com/rymizuki/node-hariko/commit/ebaf9cb)) | ||
* Merge pull request #13 from rymizuki/issue/11 | ||
([ab79538](https://github.com/rymizuki/node-hariko/commit/ab79538)) | ||
* refactor(resource/parser): fix semicolon | ||
([034109e](https://github.com/rymizuki/node-hariko/commit/034109e)) | ||
* test(hariko/resource): fix getEntry response data | ||
([606d55f](https://github.com/rymizuki/node-hariko/commit/606d55f)) | ||
* test(hariko/server-middleware/routing): fix content-type | ||
([888ee32](https://github.com/rymizuki/node-hariko/commit/888ee32)) | ||
* test(resource/parser): fix code style | ||
([af2db91](https://github.com/rymizuki/node-hariko/commit/af2db91)) | ||
<a name="1.1.6"></a> | ||
@@ -2,0 +32,0 @@ ## 1.1.6 (2017-02-03) |
@@ -63,4 +63,10 @@ var URL = require('url'), | ||
warnings = null; | ||
// the use of carriage return(s) '\r' in source data supported | ||
rawdata = rawdata.replace(/\r/g, '\n'); | ||
var data = protagonist.parseSync(rawdata, {type: 'ast'}); | ||
if (data.warnings) warnings = data.warnings; | ||
for (var i = 0; i < data.ast.resourceGroups.length; i++) { | ||
@@ -67,0 +73,0 @@ var resourceGroup = data.ast.resourceGroups[i]; |
{ | ||
"name": "hariko", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "Mock Server that implements the API Blueprint specification.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -127,2 +127,10 @@ # node-hariko | ||
## CORS | ||
Send CORS header. | ||
By default `false`. | ||
``` | ||
hariko -f 'docs/**/*.md' --cors | ||
``` | ||
### log-level | ||
@@ -129,0 +137,0 @@ |
@@ -248,6 +248,6 @@ var expect = require('expect.js'), | ||
expect(entry).to.be.eql({ | ||
file: "api/item/index?page=2-GET.json", | ||
file: "api/item/index?page-GET.json", | ||
request: { | ||
method: 'GET', | ||
uri: {path: '/api/item/', template: '/api/item/{?page}', queries: [{name: 'page', value: '2'}]} | ||
uri: {path: '/api/item/', template: '/api/item/{?page}', queries: ['page']} | ||
}, | ||
@@ -257,4 +257,4 @@ response: { | ||
headers: [{name: 'Content-Type', value: 'application/json'}], | ||
body: ' {"page": 2}\n', | ||
data: {page: 2} | ||
body: ' {"page": 1}\n', | ||
data: {page: 1} | ||
} | ||
@@ -261,0 +261,0 @@ }); |
@@ -15,179 +15,213 @@ var expect = require('expect.js'), | ||
describe('.parse(markdown_data)', function () { | ||
it('should be parse content', function () { | ||
var data = parser.parse(fs.readFileSync(path.join(path.dirname(__filename), 'fixture.md')).toString()); | ||
expect(data).to.be.eql({ | ||
entries: [ | ||
{ | ||
"file": "index-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/", | ||
"template": "/", | ||
"queries": [] | ||
describe('basic cases', function () { | ||
it('should be parse content', function () { | ||
var data = parser.parse(fs.readFileSync(path.join(path.dirname(__filename), 'fixture.md')).toString()); | ||
expect(data).to.be.eql({ | ||
entries: [ | ||
{ | ||
"file": "index-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/", | ||
"template": "/", | ||
"queries": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{"name": "Content-Type", "value": "text/plain"}], | ||
"body": "Hello world\n", | ||
"data": null | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{"name": "Content-Type", "value": "text/plain"}], | ||
"body": "Hello world\n", | ||
"data": null | ||
} | ||
}, | ||
{ | ||
"file": "api/app-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/app", | ||
"template": "/api/app", | ||
"queries": [] | ||
{ | ||
"file": "api/app-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/app", | ||
"template": "/api/app", | ||
"queries": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
{ | ||
"file": "api/user?page-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/user", | ||
"template": "/api/user{?page}", | ||
"queries": ['page'] | ||
{ | ||
"file": "api/user?page-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/user", | ||
"template": "/api/user{?page}", | ||
"queries": ['page'] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
{ | ||
"file": "api/user/user_id-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/user/:user_id", | ||
"template": "/api/user/{user_id}", | ||
"queries": [] | ||
{ | ||
"file": "api/user/user_id-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/user/:user_id", | ||
"template": "/api/user/{user_id}", | ||
"queries": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
{ | ||
"file": "api/user-POST.json", | ||
"request": { | ||
"method": "POST", | ||
"uri": { | ||
"path": "/api/user", | ||
"template": "/api/user", | ||
"queries": [] | ||
{ | ||
"file": "api/user-POST.json", | ||
"request": { | ||
"method": "POST", | ||
"uri": { | ||
"path": "/api/user", | ||
"template": "/api/user", | ||
"queries": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
{ | ||
"file": "api/user/user_id-PUT.json", | ||
"request": { | ||
"method": "PUT", | ||
"uri": { | ||
"path": "/api/user/:user_id", | ||
"template": "/api/user/{user_id}", | ||
"queries": [] | ||
{ | ||
"file": "api/user/user_id-PUT.json", | ||
"request": { | ||
"method": "PUT", | ||
"uri": { | ||
"path": "/api/user/:user_id", | ||
"template": "/api/user/{user_id}", | ||
"queries": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " {}\n", | ||
"data": {}, | ||
} | ||
}, | ||
{ | ||
"file": "api/item/hariko-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/item/hariko", | ||
"template": "/api/item/{item_id}", | ||
"queries": [] | ||
{ | ||
"file": "api/item/hariko-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/item/hariko", | ||
"template": "/api/item/{item_id}", | ||
"queries": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " []\n", | ||
"data": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " []\n", | ||
"data": [] | ||
} | ||
}, | ||
{ | ||
"file": "api/item/deco-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/item/deco", | ||
"template": "/api/item/{item_id}", | ||
"queries": [] | ||
{ | ||
"file": "api/item/deco-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/item/deco", | ||
"template": "/api/item/{item_id}", | ||
"queries": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " []\n", | ||
"data": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " []\n", | ||
"data": [] | ||
} | ||
}, | ||
{ | ||
"file": "api/item/item_id-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/item/:item_id", | ||
"template": "/api/item/{item_id}", | ||
"queries": [] | ||
{ | ||
"file": "api/item/item_id-GET.json", | ||
"request": { | ||
"method": "GET", | ||
"uri": { | ||
"path": "/api/item/:item_id", | ||
"template": "/api/item/{item_id}", | ||
"queries": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " []\n", | ||
"data": [] | ||
} | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"headers": [{name: 'Content-Type', value: 'application/json'}], | ||
"body": " []\n", | ||
"data": [] | ||
], | ||
warnings: [ | ||
{ | ||
"code": 5, | ||
"message": "unexpected header block, expected a group, resource or an action definition, e.g. '# Group <name>', '# <resource name> [<URI>]' or '# <HTTP method> <URI>'", | ||
"location": [ | ||
{"index": 686, "length": 7} | ||
] | ||
}, | ||
{ | ||
"code": 6, | ||
"message": "action is missing a response", | ||
"location": [ | ||
{"index":693,"length":26} | ||
] | ||
} | ||
}, | ||
], | ||
warnings: [ | ||
{ | ||
"code": 5, | ||
"message": "unexpected header block, expected a group, resource or an action definition, e.g. '# Group <name>', '# <resource name> [<URI>]' or '# <HTTP method> <URI>'", | ||
"location": [ | ||
{"index": 686, "length": 7} | ||
] | ||
}, | ||
{ | ||
"code": 6, | ||
"message": "action is missing a response", | ||
"location": [ | ||
{"index":693,"length":26} | ||
] | ||
} | ||
] | ||
] | ||
}); | ||
}); | ||
}); | ||
describe('when linebreak by \r', function () { | ||
var data; | ||
beforeEach(function () { | ||
data = parser.parse("\r# GET /api/message\r\r+ Response 200 (application/json)\r\r + Body\r\r {message: \"hello\"}\r\r"); | ||
}); | ||
it('should be enable parse', function () { | ||
expect(data).to.be.eql({ | ||
entries: [ | ||
{ | ||
file: "api/message-GET.json", | ||
request: { | ||
method: "GET", | ||
uri: { | ||
path: "/api/message", | ||
queries: [], | ||
template: "/api/message" | ||
} | ||
}, | ||
response: { | ||
body: "{message: \"hello\"}\n", | ||
data: {message: "hello"}, | ||
headers: [ | ||
{ name: "Content-Type", value: "application/json" } | ||
], | ||
statusCode: 200, | ||
} | ||
} | ||
], | ||
warnings: [] | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -43,3 +43,3 @@ var expect = require('expect.js'), | ||
.get('/') | ||
.expect('Content-Type', 'application/json') | ||
.expect('Content-Type', 'application/json; charset=utf-8') | ||
.expect(JSON.stringify({ message: 'hello world'})) | ||
@@ -46,0 +46,0 @@ .expect(200, done); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87565
2288
175