Code Monkey home page Code Monkey logo

raml-suggestions's Introduction

RAML Suggestions (beta)

Build Status

This module provides auto-completion suggestions for RAML. See http://raml.org for more information about RAML.

Usage

Implement IEditorStateProvider interface to create editor state provider

  • getText method should return text of the document opened in the editor
  • getPath method should return full path to the document opened in the editor
  • getBaseName method should return file name of the document opened in the editor
  • getOffset method should return editor cursor offset

Implement IFSProvider interface to create File System data provider.

  • contentDirName method should return directory name of the file, opened in the specific editor
  • dirName method should directory name by full path
  • exists method should check whether an item exists by full path
  • resolve method should resolves one path against another
  • isDirectory method should check whether the path points to a directory
  • readDir method should return return directory content list

Set default IEditorStateProvider and IFSProvider using setDefaultEditorStateProvider and setDefaultFSProvider methods.

Call suggestDefault method to get default suggestions list using default providers or call suggest method taking IEditorStateProvider and IFSProvider as arguments.

Suggestions are categorized (optional field "category" in suggestion) as described in "resources/categories.json" file.

raml-suggestions's People

Stargazers

 avatar  avatar  avatar

Watchers

 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

raml-suggestions's Issues

Improvement: insertText for directories should include a slash `/` at the end

When autocompleting a path for an include, it would be good that since you are always targeting files it automatically added the last slash to the insetText.
For instance:

  • Having this filedirectory/file.raml
  • And asking for suggestions in: !include
  • Will return insertText: directory/ instead of just directory
  • End result will be: !include directory/, so asking for suggestions again will return file.raml, making it faster to complete a path.

The following line to an example has no suggestions

When there is an example node, inside of a type or a response, the following line does not have any suggestions, but it should. In the case that the caret in two lines below the example it works fine.
This is the case that doesn't work:
screen shot 2016-10-06 at 5 57 32 pm

This are the suggestions it should provide:
screen shot 2016-10-06 at 5 57 55 pm

No enum completion for annotation instances

#%RAML 1.0 Library

types:
  TestEnum:
    type: string
    enum: [one, two]
    example: one

annotationTypes:
  TestAnnotation: TestEnum

resourceTypes:
  AnnotatedResource:
    (TestAnnotation): one

There is no completion for one value in (TestAnnotation): one

No enum completion for samples

RAML:

#%RAML 1.0 Api

types:
  TestEnum:
    type: string
    enum: [one, two]
    example: one

There is no completion for one value in example: one

Same for

types:
  TestEnum:
    type: string
    enum: [one, two]
    example: one
  TestType2:
    properties: 
      prop: TestEnum
    example: 
      prop: one

prop: one

Does not suggest inherited field from types defined in fragments

Having the next files:

dataTypeA.raml:

type: object
properties:
  name:
    required: true
    type: string
  age:
    required: false
    type: number
  /^note\d+$/: # restrict any properties whose keys start with "note"
                # followed by a string of one or more digits
    type: string

dataTypeB.raml:

type: !include dataTypeA.raml
properties: 
  employeeNo: string

And a api.raml containing:

  get:
    responses: 
      200:
        body: 
          application/json:
            type: !include dataTypeB.raml
            example:
              employeeNo: 2oo

Suggestions under example node does not include name, nor age properties, the only suggestion is employeeNo, nevertheless the parser validates missing name property since it has been defined as required.

Suggestions after certain code are not correct

In the following example:

#%RAML 1.0
title: testShelf

/resourceName:
  #Point 4
  get:
    #POINT 1
    responses: 
      200:
        body: 
          application/json:
            type: string 
        headers:
          Content-Encoding:
            type: object
    #POINT 2
    #POINT 3
  #POINT 5
  #POINT 6

When situated at #Point 1 suggestions displayed in the shelf panel are not the same as those when situated at #Point 2, despite being at the same level.

However, when situated at #Point 3, suggestions are correctly displayed as in# Point 1.

This issue also occurs at "get" level with #Point 4, 5 and 6.

Selecting one of suggested traits after "is" adds closing "]"

When a trait suggestion after a 'is' selected the closing ']' is added but there ir no opening '['

With this example:

#%RAML 1.0
title: testConsumeFragment
traits: 
 secured: !include /exchange_modules/mulesoft-720/e2etrait_j3aczpxg882/1.0.0/trait.raml
/testResource:
  is: s

If you suggest after the last char, and select the 'secured' option, the text to insert is 'secured]', which results in this:

#%RAML 1.0
title: testConsumeFragment
traits: 
 secured: !include /exchange_modules/mulesoft-720/e2etrait_j3aczpxg882/1.0.0/trait.raml

/testResource:
  is: secured]

Inherited field from types defined in fragments are not suggested

Having the following raml fragment and raml specification:

DataTypeA.raml

type: object
properties:
  name:
    required: true
    type: string
  age:
    required: false
    type: number
  /^note\d+$/: # restrict any properties whose keys start with "note"
                # followed by a string of one or more digits
    type: string

Then created another raml fragment named DataTypeB.raml
DataTypeB.raml

type: !include dataTypeA.raml
properties: 
  employeeNo: string

Then, create an api that includes dataTypeB for a response type e.g.:

/resource:
  get:
    responses: 
      200:
        body: 
          application/json:
            type: !include dataTypeB.raml
            example:
              employeeNo: 2oo

When we invoke suggestions under example node, it does not include name, nor age properties, the only suggestion is employeeNo. Nevertheless the parser validates missing name property since it has been defined as required

Include external file suggestion

It would be great to have a suggestion to reference an external file using !include.
image

Although when declaring a type the include external file is not suggested, when writing '!in' the include option is suggested as shown here:
image

It would be great to have this suggestion at first

It suggest options for a node that already have a node

I've notice when there is a node with a value and a new value is suggested, the result of adding this suggested value is an invalid.

Here it happened in in protocols (Here more protocols can be added as a list, but is not the suggested case):
screen shot 2016-10-07 at 4 39 12 pm

Here with a type inside a response:
screen shot 2016-10-07 at 4 39 40 pm

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.