Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger API: type error handling a query parameter with csv format #55

Closed
seanpk opened this issue May 18, 2016 · 2 comments
Closed

Swagger API: type error handling a query parameter with csv format #55

seanpk opened this issue May 18, 2016 · 2 comments

Comments

@seanpk
Copy link
Member

seanpk commented May 18, 2016

If you don't provide this optional query parameter, the swagger validor
Here's the stack:

TypeError: str.split is not a function
    at parseArray (/tmp/my-project/node_modules/blueoak-server/lib/swaggerUtil.js:74:16)
    at Object.castValueFromString [as cast] (/tmp/my-project/node_modules/blueoak-server/lib/swaggerUtil.js:48:17)
    at setDefaultQueryParams (/tmp/my-project/node_modules/blueoak-server/handlers/_swagger.js:231:52)
    at /tmp/my-project/node_modules/blueoak-server/handlers/_swagger.js:197:13
    at validateParameters (/tmp/my-project/node_modules/blueoak-server/handlers/_swagger.js:345:12)
    at /tmp/my-project/node_modules/blueoak-server/handlers/_swagger.js:193:9
    at Layer.handle [as handle_request] (/tmp/my-project/node_modules/express/lib/router/layer.js:95:5)
    at next (/tmp/my-project/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/tmp/my-project/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/tmp/my-project/node_modules/express/lib/router/layer.js:95:5)
    at /tmp/my-project/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/tmp/my-project/node_modules/express/lib/router/index.js:330:12)
    at next (/tmp/my-project/node_modules/express/lib/router/index.js:271:10)
    at /tmp/my-project/node_modules/i18next/lib/i18next.js:119:13
    at /tmp/my-project/node_modules/i18next-client/i18next.js:992:21
    at /tmp/my-project/node_modules/i18next/lib/i18nextWrapper.js:317:29
    at /tmp/my-project/node_modules/i18next/lib/i18nextWrapper.js:360:33
    at ReadFileContext.callback (/tmp/my-project/node_modules/i18next/lib/filesync.js:19:17)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:303:13)

Here's an example query definition:

name: types
in: query
required: false
type: array
items:
  type: string
  enum:
    - ANY
    - Type_A
    - Type_R
    - Type_S
collectionFormat: csv
default:
  - ANY
description: |
  A comma-separated list of types to search against , or the value `ANY` for all.
@pwwolf
Copy link

pwwolf commented May 18, 2016

Looking at this now. More specifically it occurs when a default is specified, and the default is an array object.

@pwwolf
Copy link

pwwolf commented May 18, 2016

Fixed in 2.2.5 3e30e33

@pwwolf pwwolf closed this as completed May 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants