Comments (5)
Test:
it('should dereference schemas and load the raml object', function (done) {
raml.loadFile(__dirname + '/../raml-files/dereference-json-schema.raml', { dereferenceSchemas: true }).then(function (ramlObj) {
done();
}, function (err) {
done(err);
});
});
dereference-json-schema.raml:
#%RAML 0.8
---
title: example
resourceTypes:
- collection: !include resourceTypes/collection.yaml
resourceTypes/collection.yaml
get:
description: Get a collection of <<resourcePathName>>.
responses:
200:
body:
schema: <<resourcePathName>>
example: <<get-example>>
post:
description: Creates a <<resourcePathName | !singularize>>.
body:
schema: <<resourcePathName | !singularize>>
example: <<post-example>>
responses:
201:
description: Successfully created the resource.
headers:
Location:
description: The location of the created resource.
type: string
Result:
patrickhousley@phousley-mac ~/Documents/projects/github/raml-js-parser (master *+)$ npm tst
> [email protected] test /Users/patrickhousley/Documents/projects/github/raml-js-parser
> grunt test
Running "coffeelint:app" (coffeelint) task
>> 21 files lint free.
Running "coffee:files" (coffee) task
File lib/composer.js created.
File lib/construct.js created.
File lib/errors.js created.
File lib/events.js created.
File lib/joiner.js created.
File lib/loader.js created.
File lib/nodes.js created.
File lib/parser.js created.
File lib/protocols.js created.
File lib/raml.js created.
File lib/reader.js created.
File lib/resolver.js created.
File lib/resourceTypes.js created.
File lib/scanner.js created.
File lib/schemas.js created.
File lib/securitySchemes.js created.
File lib/tokens.js created.
File lib/traits.js created.
File lib/transformations.js created.
File lib/util.js created.
File lib/validator.js created.
Running "connect:server" (connect) task
Started connect web server on 127.0.0.1:9001.
Running "mochacli:all" (mochacli) task
(node:93590) DeprecationWarning: child_process: options.customFds option is deprecated. Use options.stdio instead.
․․․․
3 passing (581ms)
1 failing
1) Schemas should dereference schemas and load the raml object:
SyntaxError: Unexpected token < in JSON at position 0
at Object.parse (native)
at /Users/patrickhousley/Documents/projects/github/raml-js-parser/lib/raml.js:302:25
at Array.map (native)
at RamlParser.__dirname.RamlParser.RamlParser.dereferenceSchemas (/Users/patrickhousley/Documents/projects/github/raml-js-parser/lib/raml.js:295:36)
at RamlParser.dereferenceSchemas (/Users/patrickhousley/Documents/projects/github/raml-js-parser/lib/raml.js:5:61)
at /Users/patrickhousley/Documents/projects/github/raml-js-parser/lib/raml.js:233:24
at _fulfilled (/Users/patrickhousley/Documents/projects/github/raml-js-parser/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/Users/patrickhousley/Documents/projects/github/raml-js-parser/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/Users/patrickhousley/Documents/projects/github/raml-js-parser/node_modules/q/q.js:760:13)
at /Users/patrickhousley/Documents/projects/github/raml-js-parser/node_modules/q/q.js:574:44
at flush (/Users/patrickhousley/Documents/projects/github/raml-js-parser/node_modules/q/q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Warning: Use --force to continue.
Aborted due to warnings.
npm ERR! Test failed. See above for more details.
patrickhousley@phousley-mac ~/Documents/projects/github/raml-js-parser (master *+)$
from raml-js-parser.
I used https://github.com/raml2html/raml2html which depends on this library.
The bug is there also, if you use <<placeholder>>
statements. So I think it is an bug of this library. Would be nice if this can be fixed :).
from raml-js-parser.
Hi @patrickhousley I cannot seem to be able to reproduce this. How are you testing?
this is the RAML I am using (with you collection.yaml
file)
#%RAML 0.8
title: Example API
mediaType: application/json
resourceTypes:
- collection: !include collection.yaml
/carts:
type:
collection:
get-example: foo
post-example: bar
maybe there is something weird in your types/carts.yaml
file, which is not included in the issue
from raml-js-parser.
I was bitten by the same bug so it's a real one.
from raml-js-parser.
I don't doubt it, can you share a RAML that I can use? @FredericHeem
from raml-js-parser.
Related Issues (20)
- extending with yaml anchors HOT 2
- securedBY: [null] produces error HOT 3
- Please push updated package to npm HOT 1
- RAML v1.0 HOT 2
- Can't parse valid yaml definition because of apostrophe character HOT 3
- object2raml HOT 2
- Parsing schemas cause replacing reference of schema by schema object HOT 15
- oauth_2_0 is not inherited at endpoint level HOT 2
- Restricting the compilation of Includes in RAML HOT 3
- Parsing resourcetypes with optional methods do not inherit in the resources HOT 4
- CORS: implement setting to perform XHR requests with withCredentials=true HOT 1
- Error parsing: while validating trait properties resource type cannot define child resources HOT 1
- Circular $ref dependencies are not allowed with dereferencing
- Browser distribution is bit heavy for browsers HOT 1
- Schema references in resource methods aren't code generation friendly
- Cannot read included files with directory containing spaces on Windows HOT 1
- loadFileSync
- Parser does not include description of high-level uri parameter.
- `Types` is not an alias of `schemas` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raml-js-parser.