Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

issue with array of strings validation #380

Open
calibr opened this issue May 15, 2016 · 2 comments
Open

issue with array of strings validation #380

calibr opened this issue May 15, 2016 · 2 comments

Comments

@calibr
Copy link

calibr commented May 15, 2016

Hello
I use the latest version of swagger-tools(0.10.1).
My swagger.yaml config:

swagger: "2.0"
info:
  version: "0.1.0"
  title: test API
basePath: /
paths:
  /test:
    x-swagger-router-controller: test
    get:
      operationId: operation
      responses:
        "200":
          description: "success"
          schema:
            type: array
            items:
              type: string

if I return in the test operation array of numbers in string representation, for example ["123"], swagger-tools shows an error: Error: Response validation failed: failed schema validation.

It seems that here https://github.com/apigee-127/swagger-tools/blob/master/middleware/swagger-validator.js#L116 swagger-tools converts the array elements to numbers.

Code of my controller(test.js):

exports.operation = function(res, res) {
  res.json(["123"]);
};
@whitlockjc
Copy link
Member

I'll look into it.

calibr pushed a commit to calibr/swagger-tools that referenced this issue May 28, 2016
calibr pushed a commit to calibr/swagger-tools that referenced this issue May 28, 2016
@calibr
Copy link
Author

calibr commented Jun 1, 2016

there is also the same issue with request validation, I've submitted pull request with a test: #387

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

2 participants