This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
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 #95 from apiaryio/pksunkara/drafter-4
Update protagonist
- Loading branch information
Showing
9 changed files
with
304 additions
and
14 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
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
Submodule protagonist
updated
27 files
+63 −0 | .circleci/config.yml | |
+1 −0 | .travis.yml | |
+6 −0 | CHANGELOG.md | |
+50 −37 | README.md | |
+0 −5 | binding.gyp | |
+0 −20 | circle.yml | |
+1 −1 | drafter | |
+6 −5 | package.json | |
+1 −0 | src/parse_sync.cc | |
+4 −2 | src/refractToV8.cc | |
+1 −1 | test/async-test.coffee | |
+41 −0 | test/fixtures-test.js | |
+2 −1 | test/fixtures/invalid-api-error.apib | |
+4 −48 | test/fixtures/invalid-api-error.json | |
+0 −0 | test/fixtures/invalid-api-warning.apib | |
+0 −0 | test/fixtures/invalid-api-warning.json | |
+49 −0 | test/fixtures/sample-api-error.json | |
+1 −1 | test/fixtures/sample-api-refract-sourcemap.json | |
+1 −1 | test/fixtures/sample-api-refract.json | |
+1 −1 | test/handle-unrecognized-options-test.coffee | |
+61 −54 | test/options-test.coffee | |
+9 −4 | test/parser-mson-test.coffee | |
+15 −0 | test/protagonist.js | |
+1 −1 | test/refract-test.coffee | |
+1 −1 | test/sourcemap-test.coffee | |
+1 −1 | test/sync-test.coffee | |
+70 −28 | test/validate-test.coffee |
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,139 @@ | ||
var assert = require('chai').assert; | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var drafter = require('../lib/drafter.nomem.js'); | ||
|
||
var fixture_path = path.join(__dirname, '../ext/protagonist/test/fixtures/sample-api.apib'); | ||
var expected_err = require('../ext/protagonist/test/fixtures/sample-api-error.json'); | ||
|
||
describe('Requiring Blueprint name with sourcemaps', function () { | ||
var refract_err = null; | ||
|
||
before(function (done) { | ||
fs.readFile(fixture_path, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
drafter.parse(data, { requireBlueprintName: true, generateSourceMap: true }, function (err, result) { | ||
// if (err) { | ||
// return done(err); | ||
// } | ||
|
||
refract_err = result; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('conforms to the refract spec', function () { | ||
assert.deepEqual(refract_err, expected_err); | ||
}); | ||
}); | ||
|
||
describe('Requiring Blueprint name without sourcemaps', function () { | ||
var refract_err = null; | ||
|
||
before(function (done) { | ||
fs.readFile(fixture_path, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
drafter.parse(data, { requireBlueprintName: true, generateSourceMap: false }, function (err, result) { | ||
// if (err) { | ||
// return done(err); | ||
// } | ||
|
||
refract_err = result; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('conforms to the refract spec', function () { | ||
assert.deepEqual(refract_err, expected_err); | ||
}); | ||
}); | ||
|
||
describe('Requiring Blueprint name with sourcemaps using sync', function () { | ||
var refract_err = null; | ||
|
||
before(function (done) { | ||
fs.readFile(fixture_path, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
refract_err = drafter.parseSync(data, { requireBlueprintName: true, generateSourceMap: true }); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('conforms to the refract spec', function () { | ||
assert.deepEqual(refract_err, expected_err); | ||
}); | ||
}); | ||
|
||
describe('Requiring Blueprint name without sourcemaps using sync', function () { | ||
var refract_err = null; | ||
|
||
before(function (done) { | ||
fs.readFile(fixture_path, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
refract_err = drafter.parseSync(data, { requireBlueprintName: true, generateSourceMap: false }); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('conforms to the refract spec', function () { | ||
assert.deepEqual(refract_err, expected_err); | ||
}); | ||
}); | ||
|
||
describe('Requiring Blueprint name with validate', function () { | ||
var refract_err = null; | ||
|
||
before(function (done) { | ||
fs.readFile(fixture_path, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
drafter.validate(data, { requireBlueprintName: true }, function (err, result) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
refract_err = result; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('conforms to the refract spec', function () { | ||
assert.deepEqual(refract_err, expected_err); | ||
}); | ||
}); | ||
|
||
describe('Requiring Blueprint name with validate sync', function () { | ||
var refract_err = null; | ||
|
||
before(function (done) { | ||
fs.readFile(fixture_path, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
refract_err = drafter.validateSync(data, { requireBlueprintName: true }); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('conforms to the refract spec', function () { | ||
assert.deepEqual(refract_err, expected_err); | ||
}); | ||
}); |
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,143 @@ | ||
var assert = require('chai').assert; | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var drafter = require('../lib/drafter.nomem.js'); | ||
|
||
var valid_fixture = path.join(__dirname, '../ext/protagonist/test/fixtures/sample-api.apib'); | ||
var warning_fixture = path.join(__dirname, '../ext/protagonist/test/fixtures/invalid-api-warning.apib'); | ||
var error_fixture = path.join(__dirname, '../ext/protagonist/test/fixtures/invalid-api-error.apib'); | ||
|
||
var warning_refract = require('../ext/protagonist/test/fixtures/invalid-api-warning.json'); | ||
var error_refract = require('../ext/protagonist/test/fixtures/invalid-api-error.json'); | ||
|
||
describe('Validate Blueprint with error - Sync', function () { | ||
var parsed = null; | ||
|
||
before(function (done) { | ||
fs.readFile(error_fixture, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
parsed = drafter.validateSync(data); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Result contains annotations only', function () { | ||
assert.deepEqual(parsed, error_refract); | ||
}); | ||
}); | ||
|
||
describe('Validate Blueprint with warning - Sync', function () { | ||
var parsed = null; | ||
|
||
before(function (done) { | ||
fs.readFile(warning_fixture, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
parsed = drafter.validateSync(data); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('Result contains annotations only', function () { | ||
assert.deepEqual(parsed, warning_refract); | ||
}); | ||
}); | ||
|
||
describe('Validate valid Blueprint - Sync', function () { | ||
var parsed = 1; | ||
|
||
before(function (done) { | ||
fs.readFile(valid_fixture, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
parsed = drafter.validateSync(data); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('will return null', function () { | ||
assert.isNull(parsed); | ||
}); | ||
}); | ||
|
||
describe('Validate Blueprint with error - Async', function () { | ||
var parsed = null; | ||
|
||
before(function (done) { | ||
fs.readFile(error_fixture, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
drafter.validate(data, {}, function (err, result) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
parsed = result; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('Result contains annotations only', function () { | ||
assert.deepEqual(parsed, error_refract); | ||
}); | ||
}); | ||
|
||
describe('Validate Blueprint with warning - Async', function () { | ||
var parsed = null; | ||
|
||
before(function (done) { | ||
fs.readFile(warning_fixture, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
drafter.validate(data, {}, function (err, result) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
parsed = result; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('Result contains annotations only', function () { | ||
assert.deepEqual(parsed, warning_refract); | ||
}); | ||
}); | ||
|
||
describe('Validate valid Blueprint - Async', function () { | ||
var parsed = 1; | ||
|
||
before(function (done) { | ||
fs.readFile(valid_fixture, 'utf8', function (err, data) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
drafter.validate(data, {}, function (err, result) { | ||
if (err) { | ||
return done(err); | ||
} | ||
|
||
parsed = result; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
it('will return null', function () { | ||
assert.isNull(parsed); | ||
}); | ||
}); |