raml-org / raml-js-parser-2

(deprecated)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem passing multiple query parameters to resource type as an Object

Mukolajko opened this issue · comments

Hi. I got issue on validation when trying to pass multiple query parameters to resource in object.

Here is an error that validator produces
{ code: 'SCALAR_PROHIBITED', message: 'Property \'queryParameters\' can not have scalar value' }

What's weird that if i pass single parameter everything works as expected.

Here is my raml code

/api/ier:
    type: {
      stx-get: {
        queryData: {
          test: {
            type: integer,
            description: some desc
          }
        },
        typeName : AnalyticsFeedsCount,
        desc: Get amount of available analytics feeds in IER server
      }
    }

And the resource part

stx-get:
  usage: Use this resourceType for GET routes
  get:
    queryParameters: <<queryData>>
    description: <<desc>>
    is:
      - hasResponseItem: {typeName: <<typeName>>}

If queryData have only single key it passes and if multiple it will fail with SCALAR_PROHIBITED message.

Now if i just write object in resourceType everything works.

stx-get:
  usage: Use this resourceType for GET routes
  get:
    queryParameters: {
      test: {
        type: integer,
        description: some desc
      },
      page: {
        type: string,
        required: false
      }
    }
    description: <<desc>>
    is:
      - hasResponseItem: {typeName: <<typeName>>}

When i try to debug. I found that raml-1-parser module causing this issue.

To be exactly dist/parser/ast.core/linter.js method validateBasicFlat
This code returns error:

if (node.lowLevel().value() != '~') {
                    if (!checkIfIncludeTagIsMissing(node, v, messageRegistry.SCALAR_PROHIBITED.code, false)) {
                        v.accept(createIssue1(messageRegistry.SCALAR_PROHIBITED, { propName: node.name() }, node));
                    }
                }

I just cant seem to understand what am i missing.
Query parameters allow object to be passed in, but for some reason when i pass it as an argument it fails.

Also when checking styling with https://github.com/raml2html/raml2html everything works fine with all approaches.

Thank you for help.

Note that raml-js-parser-2 has been deprecated, the new official parser is webapi-parcser. Feel free to attempt to reproduce this issue with webapi-parser and report any issue you may have on that repository.