响应验证失败Swagger

时间:2016-02-29 16:22:43

标签: node.js swagger

我使用swagger定义API。我有一个应该返回这样的操作。

int solution(int A[], int N) {
    // write your code in C99 (gcc 4.8.2)
    int X = 0, count = 0, i;

    for(i = 0; i < N; i++)
    {
        if(A[i] == 0)
          X++;
        else {
            count += X;
        }        

        if(count > 1000000000) {
            return -1;
        }
    }

    return count;
}

问题是&#34; isDeviceLoaded:false&#34;我不想返回所有属性,所以在这种情况下返回值应该只是。

{"isDeviceLoaded":true,"loadedDeviceProperties":  {"deviceType":"Gadget","deviceProp1":0,"deviceLoadedConfigurations":[{"width":0,"length":0,"distanceToTopLeft":0}]}}

我在Swagger - Specify Optional Object Property or Multiple Responses

之后定义了我的模型
{"isDeviceLoaded":false}

但是在我的代码中,我尝试只返回isDeviceLoaded属性,我得到的响应验证失败了。这就是我在JS和&#34;对象&#34;中做的事情。有数据。

DeviceMediaStatus: 
type: "object"
required: ["isDeviceLoaded"]
properties: 
  isDeviceLoaded: 
    type: "boolean"
  loadedDeviceProperties: 
    type: "object"
    $ref: "#/definitions/LoadedDeviceProperties"

0 个答案:

没有答案
相关问题