Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Problem passing multiple query parameters to resource type as an Object #180

Open
Mukolajko opened this issue Dec 10, 2018 · 0 comments
Open

Comments

@Mukolajko
Copy link

Mukolajko commented Dec 10, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant