Git Product home page Git Product logo

Comments (5)

patrickhousley avatar patrickhousley commented on July 26, 2024 4

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.

Rotzbua avatar Rotzbua commented on July 26, 2024 1

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.

dmartinezg avatar dmartinezg commented on July 26, 2024

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.

FredericHeem avatar FredericHeem commented on July 26, 2024

I was bitten by the same bug so it's a real one.

from raml-js-parser.

dmartinezg avatar dmartinezg commented on July 26, 2024

I don't doubt it, can you share a RAML that I can use? @FredericHeem

from raml-js-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.