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

issue with array of strings validation #380

@calibr

Description

@calibr

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"]);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions