raml-org / raml-js-parser-2

(deprecated)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type expansion incomplete for uriParameters and headers

olivier-m opened this issue · comments

It seems there's an issue with some data (description and example) from types in uriParameters and headers.

#%RAML 1.0
---

title: Test API


types:
  PhoneNumber:
    type: string
    description: A phone number with international prefix


/user/{phone}/{id}:
  uriParameters:
    phone: PhoneNumber
    id:
      type: string
      description: An ID

  get:
    responses:
      200:
        headers:
          x-phone: PhoneNumber
        body:
          application/json:
            type: object
            properties:
              phone: PhoneNumber

After calling raml.load (with expandTypes), I end up with this result:

{
 "specification": {
  "types": [
   {
    "name": "PhoneNumber",
    "typePropertyKind": "TYPE_EXPRESSION",
    "type": [
     "string"
    ],
    "description": "A phone number with international prefix",
    "displayName": "PhoneNumber"
   }
  ],
  "title": "Test API",
  "resources": [
   {
    "methods": [
     {
      "responses": [
       {
        "code": "200",
        "headers": [
         {
          "name": "x-phone",
          "typePropertyKind": "TYPE_EXPRESSION",
          "type": [
           "string"
          ],
          "displayName": "x-phone",
          "required": true
         }
        ],
        "body": [
         {
          "name": "application/json",
          "typePropertyKind": "TYPE_EXPRESSION",
          "type": [
           "object"
          ],
          "properties": [
           {
            "name": "phone",
            "typePropertyKind": "TYPE_EXPRESSION",
            "type": [
             "string"
            ],
            "description": "A phone number with international prefix",
            "displayName": "phone",
            "required": true
           }
          ],
          "displayName": "application/json"
         }
        ]
       }
      ],
      "method": "get",
      "parentUri": "/user/{phone}/{id}",
      "absoluteParentUri": "/user/{phone}/{id}",
      "uriParameters": [
       {
        "name": "phone",
        "typePropertyKind": "TYPE_EXPRESSION",
        "type": [
         "string"
        ],
        "displayName": "phone",
        "required": true
       },
       {
        "name": "id",
        "typePropertyKind": "TYPE_EXPRESSION",
        "type": [
         "string"
        ],
        "description": "An ID",
        "displayName": "id",
        "required": true
       }
      ]
     }
    ],
    "uriParameters": [
     {
      "name": "phone",
      "typePropertyKind": "TYPE_EXPRESSION",
      "type": [
       "string"
      ],
      "displayName": "phone",
      "required": true
     },
     {
      "name": "id",
      "typePropertyKind": "TYPE_EXPRESSION",
      "type": [
       "string"
      ],
      "description": "An ID",
      "displayName": "id",
      "required": true
     }
    ],
    "relativeUri": "/user/{phone}/{id}",
    "displayName": "/user/{phone}/{id}",
    "relativeUriPathSegments": [
     "user",
     "{phone}",
     "{id}"
    ],
    "absoluteUri": "/user/{phone}/{id}",
    "completeRelativeUri": "/user/{phone}/{id}",
    "parentUri": "",
    "absoluteParentUri": ""
   }
  ]
 },
 "ramlVersion": "RAML10",
 "type": "Api",
 "errors": []
}

As you can see, there is no description for the expanded type Phone in headers or uriParameters, whereas it's present when directly declared.

I tried to fix and submit a PR but I can't even run the tests without error :/

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.