Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何包装JSON对象?_Json_Swagger_Swagger Ui_Swagger 2.0_Swagger Editor - Fatal编程技术网

如何包装JSON对象?

如何包装JSON对象?,json,swagger,swagger-ui,swagger-2.0,swagger-editor,Json,Swagger,Swagger Ui,Swagger 2.0,Swagger Editor,我目前正在寻找一种在Swagger UI组件中封装JSON的方法 在YAML中,我的对象声明是: restException: properties: message: type: string Swagger UI生成的输出是(我同意,是正确的): { “消息”:“字符串” } 我想要的是: "restException": { "message": "string" } 我刚刚找到了一种丑陋的方法,在YAML文件中明确声明包装器。但它非常糟

我目前正在寻找一种在Swagger UI组件中封装JSON的方法

在YAML中,我的对象声明是:

  restException:
    properties:
      message:
        type: string
Swagger UI生成的输出是(我同意,是正确的):

{
“消息”:“字符串”
}

我想要的是:

"restException": {
  "message": "string"
}
我刚刚找到了一种丑陋的方法,在YAML文件中明确声明包装器。但它非常糟糕,因为当我使用“Swagger Codegen”生成客户端或服务器代码时,它也会生成


restExceptionContainer:
restException:
特性:
信息:
类型:字符串


如果需要,我可以在Swagger UI文件中添加代码!需要您的帮助才能找到位置:)

您应该将restException作为一个对象(类型:object)记录下来

请参考作为一个例子,看看如何定义宠物和类别

  Pet:
    type: object
    required:
      - name
      - photoUrls
    properties:
      id:
        type: integer
        format: int64
      category:
        $ref: '#/definitions/Category'
其中,类别定义为:

  Category:
    type: object
    properties:
      id:
        type: integer
        format: int64
      name:
        type: string

您应该将restException作为对象(类型:object)进行记录

请参考作为一个例子,看看如何定义宠物和类别

  Pet:
    type: object
    required:
      - name
      - photoUrls
    properties:
      id:
        type: integer
        format: int64
      category:
        $ref: '#/definitions/Category'
其中,类别定义为:

  Category:
    type: object
    properties:
      id:
        type: integer
        format: int64
      name:
        type: string