Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Type expansion incomplete for uriParameters and headers #830

Open
olivier-m opened this issue Nov 21, 2018 · 1 comment
Open

Type expansion incomplete for uriParameters and headers #830

olivier-m opened this issue Nov 21, 2018 · 1 comment

Comments

@olivier-m
Copy link

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 :/

@postatum
Copy link
Contributor

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.

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

No branches or pull requests

2 participants