Using types in connection with bodies resulting in template render error #272

Closed
LairdTurner opened this Issue Nov 2, 2016 · 3 comments

Projects

None yet

2 participants

@LairdTurner
LairdTurner commented Nov 2, 2016 edited

In the types section I got an type like

objectid_array:
description: A list of objectIds
type: string[]
examples:
key:
[
"576bca8b70fddb149c4a9e92",
"576bca8b70fddb149c4a9e93"
]

If I now use this type in a put for example

  put:
    body:
      application/json: objectid_array

I get an template render error
{ Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\template.nunjucks)
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\template.nunjucks)
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\resource.nunjucks)
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\template.nunjucks)
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\resource.nunjucks)
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\resource.nunjucks) [Line 252, Column 50]
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\template.nunjucks)
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\resource.nunjucks)
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\resource.nunjucks)
Template render error: (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\lib\resource.nunjucks) [Line 264, Column 46]
TypeError: type.indexOf is not a function
at Object.exports.prettifyError (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\lib.js:34:15)
at C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\environment.js:486:31
at new_cls.root [as rootRenderFunc] (eval at _compile (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\environment.js:565:24), :191:3)
at new_cls.render (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\environment.js:479:15)
at C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\environment.js:312:35
at createTemplate (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\environment.js:234:25)
at handle (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\environment.js:249:25)
at C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\environment.js:263:21
at next (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\lib.js:207:13)
at Object.exports.asyncIter (C:\Users\r.hoeger\Downloads\raml2html-develop(1)\raml2html-develop\node_modules\nunjucks\src\lib.js:214:5) name: 'Template render error' }

I'm using beta 12.
With beta 9 this has worked!

regards

@kevinrenskers
Member
kevinrenskers commented Nov 2, 2016 edited

Just to make my life a bit easier, can you please add a minimal example RAML file? Please put it between code blocks (triple backticks here on github) so that indentation and stuff is preserved.

    ```
    My code goes here
    ```
@LairdTurner

Hi!

Sure!
Here you are

#%RAML 1.0
title: Test API
version: 1
protocols: [HTTPS]
baseUri: https://test
mediaType: application/json
types:
  objectid:
    description: A valid MongoDB object id.
    type: string
    example: "576bca8b70fddb149c4a9e92"
  objectid_array:
      description: A array of objectIds
      type: string[]
      examples:
        key:
          [
            "576bca8b70fddb149c4a9e92",
            "576bca8b70fddb149c4a9e93"
          ]
/test:
  get:
     description: TEST
     responses:
        200:
          body:
            application/json: objectid_array
@kevinrenskers
Member

Thanks! 4.0.0-beta14 should fix this.

@kevinrenskers kevinrenskers added a commit that referenced this issue Dec 1, 2016
@kevinrenskers kevinrenskers Merge branch 'develop'
* develop: (30 commits)
  4.0.0 final
  4.0.0-beta18: Updated raml2obj
  4.0.0-beta17 - improved rendering of nested properties (#274)
  Display properties of item. (#278)
  4.0.0-beta16 - improved rendering of inherited array properties (#277)
  4.0.0-beta15: fixed rendering of type array of primitives (like string[])
  Fixed template render error (#272)
  Updated raml2obj to 4.0.0-beta13, fixing type expansion in uriParameters (#271)
  4.0.0-beta12: improved array type support (#265)
  4.0.0-beta11
  4.0.0-beta10
  Update version
  Deal with object datatypes
  4.0.0-beta8: updated raml2obj to 4.0.0-beta9, which deals with type inheritance
  Rendering types
  Using raml2obj 4.0.0-beta7
  4.0.0-beta5: fixed files in package.json
  Added basic support for annotations
  - Using raml2obj 4.0.0-beta5 which expands types and always gives consistent examples arrays - Rendering baseUriParameters - Rendering `properties` instead of `formParameters` - Rendering multiple `examples` - Improved rendering of single item enums - Removed rendering of `types` for now
  4.0.0-beta3
  ...

# Conflicts:
#	changelog.md
#	package.json
2cf24ac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment