Giter Club home page Giter Club logo

raml-js-parser-2's Introduction

RAML.org Website

This repository contains the source code for the raml.org website written in Jekyll

Requirements

Running locally

Pull the code locally:

$ git clone [email protected]:raml-org/raml-org.git

Enter directory:

$ cd raml-org

Install all dependencies:

$ bundle install

Build & run the site:

$ bundle exec jekyll serve

How to add projects to the projects page?

RAML.org includes a projects page that lists tools around RAML that either are community or commercial driven. If you think, your project should be in this list, please fork this repository, add it into the projects.yml file, and send us a PR. We will review and let you know if we will be able to list it.

Another way to make sure your project is linked to our projects page is through assigning topics to your Github project. Links to each topics are below the list of projects on the projects page. The following topics are available:

Topic Description
raml-design Includes projects that specifically support people with the design of RAML documents.
raml-document Includes projects that focus on the documentation of APIs using RAML documents.
raml-build Includes projects that focus on build client or server code based on RAML documents.
raml-parser Includes projects that parses/validates RAML documents.
raml-test Includes projects that support people testing APIs based on RAML documents.
raml-utilities Includes other projects that do not fall into the other topics like converters.

Topics need to be assigned and managed by the owner of a project. Additionally, we still recommend people to search on Github for more projects that might not have these topics assigned.

Contribution

RAML's website is in fact an open source project and your contribution is very much appreciated. Before you start, you should check for open issues or open a fresh issue to start a discussion around an idea that you'd like to see on our website or a bug. If you want to support us fixing issues, please follow the steps below:

  1. Fork the repository on Github and make your changes on the develop branch (or branch off of it).
  2. Run the website to see if you fixed the issue.
  3. Send a pull request (with the develop branch as the target).

We will review your PR, comment if necessary, and merge it into our staging branch stg.

You can contribute to the following:

  • spelling mistakes
  • new projects
  • blog posts
  • and others, after carefully reviewing the issue you created

raml-js-parser-2's People

Contributors

aldonline avatar baoti avatar blakeembrey avatar ddenisenko avatar dependabot[bot] avatar dreamflyer avatar greenkeeper[bot] avatar jstoiko avatar juancoen avatar konstantinsviridov avatar nnance avatar petrochenko-pavel-a avatar postatum avatar santam85 avatar sichvoge avatar svc-scm avatar usarid avatar vasiliylysokobylko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raml-js-parser-2's Issues

Put the documentation on `gh-pages`

I'm not sure how I can read the documentation directory without having to clone it and read it locally. It would be nice if it was available on gh-pages so I could read it online.

Parsing inexisting file could throw or return a "readable" error

Sorry if this is not the place to "ask a question / make a suggestion" like that.

I have tried the following really useless code:

'use strict';
var raml = require( 'raml-1-0-parser' );
try
{
   var foo = raml.loadApi( './file-that-does-not-exists.file' );
   console.log( foo );
}
catch( e )
{
   console.log( e );
}

Although I realize the code is not realistic, the error (mistyping a file path) is. I wanted to know what happens in this situation while trying to determine the error behavior of raml-js-parser-2 to use it in another project.

The result I have had is that null is returned in foo and printed to the console. No error is thrown and nothing to indicate the source of the error.

If this is normal behavior, I would like to suggest that it should not be. Wouldn't it be possible to throw an error saying that the file does not exist.

getting media types of post bodies

/login:
  description: Redirect to accounts api login
  get:
    (handler):
      path: 'login.page'
  post:
    (handler):
      path: 'login.post'
    body:
      application/json:
        type: object
        properties:
          username: string
          password: string
      application/x-www-form-urlencoded:
        type: object
        properties:
          username: string
          password: string

I can't find any way to get the post body media types. From a method node I can get bodies but that is just the object definitions underneath the media types.

Array in "example" has only half of elements

Hi,
After the last update I found out that boolean arrays in "example" part have only halt of elements.
For example, I have the description:

example:
aesOutput1:
[ true, false, false, false ]
aesOutput2:
[ false, true, false, false ]

and when I try to output them by toString() I have:

true,false
false,true

Although in the previous version of raml-js-parser-2 I had four elements for each array.

Why convert a collection of objects to an object with numeric keys?

RAML parser parses this structure:

resourceTypes:
    - readOnlyCollection:
          description: Collection of available <<resourcePathName>> in Jukebox.
          get:
          ⋮
    - collection:
          description: Collection of available <<resourcePathName>> in Jukebox.
          get:
          ⋮

to this:

{
    resourceTypes:  {
        '0': { readOnlyCollection: [Object] },
        '1': { collection: [Object] },
        '2': { 'collection-item': [Object] }
    }
}

instead of this:

{
    resourceTypes:  [
        { readOnlyCollection: [Object] },
        { collection: [Object] },
        { 'collection-item': [Object] }
    ]
}

Why?

Parsing a file that includes a remote file with relative includes fails

With this RAML:

#%RAML 0.8
!include https://raw.githubusercontent.com/raml-apis/XKCD/production/api.raml

the parser fails (the relative includes in api.raml are not resolved correctly) and errors cannot be traversed

api.errors().forEach(function(x){

produces this error:

TypeError: Cannot read property 'position' of null
    at /Users/juan/Projects/raml-js-parser-2/src/raml1Parser.js:9059:35
    at Array.forEach (native)
    at ASTNodeImpl.BasicASTNode.validate (/Users/juan/Projects/raml-js-parser-2/src/raml1Parser.js:9054:39)
    at ASTNodeImpl.validate (/Users/juan/Projects/raml-js-parser-2/src/raml1Parser.js:9953:40)
    at ASTNodeImpl.BasicASTNode.errors (/Users/juan/Projects/raml-js-parser-2/src/raml1Parser.js:9035:15)
    at ApiImpl.BasicNodeImpl.errors (/Users/juan/Projects/raml-js-parser-2/src/raml1Parser.js:28337:44)
    at /Users/juan/Projects/raml-js-parser-2/test/testAsync01.js:8:9
    at runMicrotasksCallback (node.js:337:7)
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)

Body type inheritance support

Currently when parsing a method request body or a response body, it appears that the body object does not inherit properties or examples or from the parent type.

Given the following example:

#%RAML 1.0
title: Pet shop
version: 1
baseUri: /shop

types:
  Pet:
    properties:
      name: string
      kind: string
      price: number
    example:
      name: "Snoopy"
      kind: "Mammal"
      price: 100
/pets:
  /{id}:
    get:
    reponses:
      200:
        body:
          application/json:
            type: Pet

When we run this RAML through through the parser and try to retrieve the body for the response. We get an error.

api.resources()[0].resources()[0].methods()[0].responses()[0].body()[0].properties();
TypeError: api.resources(...)[0].resources(...)[0].methods(...)[0].responses(...)[0].body(...)[0].properties is not a function

Ideally the parser should return the properties and example(s) from the parent type.

Is this feature currently on the roadmap?

map type expression not supported

When trying to use map type expression, as stated here
I get "Syntax error:Expected "|" or end of input but "{" found.

Example:

#%RAML 1.0
title: My Api
/maps:
    get:
      responses:
        200:
          body:
            type: number{}

Error parsing markdown starting with an html tag

Hi, I have some documentation content where the first line starts with an html tag. The parser then throws an error. If I stick a letter in-front of the tag all works again.

#%RAML 1.0 DocumentationItem

title: Data API
content: |
  <center>
  ![Black Swan Logo](images/logo_name_bottom.png)
  </center>
{ code: 7,
  message: 'String is expected documentation/index.raml',
  path: null,
  start: 164,
  end: 188,
  line: 10,
  column: 13,
  range: 
   [ { line: 10, column: 13, position: 164 },
     { line: 10, column: 37, position: 188 } ],
  isWarning: true }

Parser error interpretation

This RAML:

#%RAML 0.8

---
title: API 1
...
title: API 2

Produces 3 errors in the Workbench:
screen shot 2015-11-23 at 6 29 27 pm

but the parser returns only one:

{
  "code": 1,
  "message": "JS-YAML: can not read an implicit mapping pair; a colon is missed at line 3, column 1",
  "path": null,
  "start": 28,
  "end": 29,
  "isWarning": false
}

Why are the two other errors not returned?
How should start and end be interpreted?

TypeError: node.highLevel is not a function

I get this error when trying to parse this API:

C:\desarrollo\mulesoft\raml-dotnet-parser-raml1-bundle\Raml.Parser.Tester\bin\De
bug\node_modules\raml-1-0-parser\src\bundle.js:75
            return json2lowlevel.serialize(node.highLevel().lowLevel(), serializ
eOptions);
                                                ^
TypeError: node.highLevel is not a function
    at Object.toJSON (C:\desarrollo\mulesoft\raml-dotnet-parser-raml1-bundle\Ram
l.Parser.Tester\bin\Debug\node_modules\raml-1-0-parser\src\bundle.js:75:42)
    at Object.<anonymous> (C:\desarrollo\mulesoft\raml-dotnet-parser-raml1-bundl
e\Raml.Parser.Tester\bin\Debug\test.js:16:18)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)
    at node.js:951:3

Annotations

Hi, I'm unclear how to get info about my annotations. I have annotations on my methods. I just want to know how to get the annotation name and value.

raml

annotationTypes:
  handler:
    parameters:
      value: string

  /clients:
    get:
      (handler): routes.resources.clients.list

ast

[ AnnotationRefImpl {
    attr: 
     ASTPropImpl {
       _node: [Object],
       _parent: [Object],
       _implicit: false,
       values: {},
       _def: [Object],
       _prop: [Object],
       fromKey: false } } ]

Api.expand() not working with modules

var api = ramlParser.loadApiSync('api.raml', [ 'module1.raml', 'module2.raml' ]);
api.resources().forEach(function(resource) {
        console.log('Adding resource: ' + resource.displayName());
});

This logs all resources in module1 and module2.

But when I add the api.expand(), it only logs resources in module2.

var api = ramlParser.loadApiSync('api.raml', [ 'module1.raml', 'module2.raml' ]);
api.expand().resources().forEach(function(resource) {
        console.log('Adding resource: ' + resource.displayName());
});

Did I misinterpret the expand function?

Can't find type name for ArrayTypeDeclaration imported from library

Example:

uses:
  AnimalLibrary: !include Animals.raml

types:
  Zoo:
   type: object
   properties:
     animal: AnimalLibrary.Animal
     animals: AnimalLibrary.Animal[]


For the animal property of type Zoo (ObjectTypeDeclaration):
typeDeclaration.runtimeType().superTypes[0].nameId() returns "Animal", (which is GOOD)

However, for the animals property of type Zoo (ArrayTypeDeclaration):
typeDeclaration.runtimeType().componentType().superTypes[0].nameId() returns "ValueType"
and
typeDeclaration.runtimeType().componentType().nameId() returns "StringType"

How do I figure out the type for the property animals? Things seem to work fine if the Animal type isn't defined in a library. Is this a bug, or am I doing something wrong?

Status codes have strange prefix in generated JSON

All status codes (200, 400, etc.) are prefixed with __$EscapedKey$__ in the generated JSON. Why is that needed? Can it be removed?

Example:

var api = RAML.loadApi(apiPath).getOrElse(null);
var apiJSON = RAML.toJSON(api);
console.log(apiJSON);

Result (fragment):

"errorCodes": {
        "responses": {
          "__$EscapedKey$__400": {
            "description": "Bad Request.",

Publish on NPM

I would like to be able to use the RAML 1.0 parser as a dependency of my projects, can this be published on NPM?

Invalid error in expanded RAML

In expanded version of

resourceTypes: 
  - base:
      get:
        responses:
          200:
            body:
              schema: get-<<resourcePathName>> # e.g. get-machines

the line

schema: get-<<resourcePathName>> # e.g. get-machines

contains error:

Error: when parsingError: Syntax error:Expected "|" or end of input but "<" found.

Array type

Hi,
Is it OK that

response.body()[0].type() is SysManagementTypes.Channel[]

but

response.body()[0].definition().allSuperTypes()[0] is String[]

?

BTW, How can I get access to properties/examples of properties of type from response.body()[idx] ?

For example, I have response body type SysManagementTypes.Channel which have some properties:

    properties:
      id: number
      name: string
      protocol: ChannelProtocol
      ipAddress: IpAddress
      port: number
      status: ChannelStatus
    example:
      id: 1
      name: Sample Channel
      protocol: Udp
      ipAddress: 192.168.218.109
      port: 2077
      status: Playing

and I can get this type by response.body()[0].type(). But I need to iterate all properties of the Channel type. How to do that?

And what if body type is Channel[] (an array)?

TraitRef must have better helpers

Right now we have to jump to High-level in order to obtain resource trait appliance parameters, trait name could also be directly provided from TraitRef method.

fsResolver being called for includes with URLs

When parsing a RAML in the filesystem that includes a remote file using a URL, and providing a fsResolver and httpResolver, the fsResolver is being called for the included URL instead of the httpResolver.

License is wrong

According to the package.json, it says it's ISC. According to license.txt, it's Apache-2.0.

ResourceTypeRef must have better helpers

Right now we have to jump to High-level in order to obtain resource type appliance parameters, type name could also be directly provided from ResourceTypeRef method.

RAML.loadApi should be asynchronous

Parsing a RAML can be a heavy load operation, so it makes sense to make the operation asynchronous. It's also a good practice to do it using Promises.

How to help?

Hi,

I noticed that there were a few issues with the help wanted tag. How do i go about this?

It appears as though the source code for this project is held elsewhere and a compiled version is committed into this project. Is that correct?

Keen to help get RAML 1.0 parsers to a point where I can use them in my daily work.

Add support to parse RAML API fromt text instead of using a file path

Currently, the only way to use the parser is to do:

var apiFilePath = 'api.raml';
var api = RAML.loadApi(apiFilePath).getOrElse(null);

There should be a way to pass the RAML text directly, for example:

var ramlText = '#%RAML 0.8\ntitle: Anypoint Exchange';
var api = RAML.loadApiText(ramlText).getOrElse(null);

Cleanup dependencies

It seems that some of the dependencies make no sense for this package (for example, typescript). Please check which ones are actually used and remove the rest.

Thanks!

Throws an error when "extensions and overlays" are undefined

            throw new Error("Extensions and overlays list should be defined");
            ^

Error: Extensions and overlays list should be defined
    at Object.loadApiAsync (/Users/blakeembrey/Projects/mulesoft-labs/raml-generator/node_modules/raml-1-parser/src/raml1Parser.js:27600:16)
    at Object.loadApi (/Users/blakeembrey/Projects/mulesoft-labs/raml-generator/node_modules/raml-1-parser/src/raml1Parser.js:4147:23)
    at Object.loadApi (/Users/blakeembrey/Projects/mulesoft-labs/raml-generator/node_modules/raml-1-parser/src/raml1Parser.js:54:25)
    at Object.bin (/Users/blakeembrey/Projects/mulesoft-labs/raml-generator/dist/bin.js:28:28)
    at Object.<anonymous> (/Users/blakeembrey/Projects/mulesoft-labs/raml-javascript-generator/dist/bin.js:4:7)
    at Module._compile (module.js:399:26)
    at Object.Module._extensions..js (module.js:406:10)
    at Module.load (module.js:345:32)
    at Function.Module._load (module.js:302:12)
    at Function.Module.runMain (module.js:431:10)
    at startup (node.js:141:18)
    at node.js:977:3

The second argument is undefined.

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.