Skip to content

Json Schema: How to get a [string] result? #4741

Closed
@rushairer

Description

@rushairer

API return : ["abc", "def"]

json-schemas.json

{
    "definitions": {
        "Test": {
            "type": "array",
            "title": "Test",
            "description": "Test Object",
            "items": {
                "type": "string"
            }
        }
    }
}

.meshrc.yaml

- name: TestApi
      handler:
          jsonSchema:
              baseUrl: http://api-host
              operations:
                  - type: Query
                    field: getTest
                    path: /test
                    method: GET
                    responseSchema: ./json-schemas.json#/definitions/Test
query test {
    getTest
}

I got error like:

{
"errors": [
{
"message": "String cannot represent value: { 0: "x", 1: "2", 2: "3", 3: "-", 4: "3", $url: "http://.....", $method: "GET", $request: { query: [Object], path: [Object], header: {} }, $response: { url: "http://......", method: "GET", status: 200, statusText: "OK", body: "x23-3" } }",
"path": [
"didManufacturerList",
0
]
},
{
.....
}
],
"data": {
"getTest": [
null,
null
]
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions