Swagger 在招摇过市中创建我自己的类型
我有这个扬眉吐气的YAML代码,我需要创建自己的类型(名为MyOwnType) 如果使用“MyOwnType”,则会发生编译错误Swagger 在招摇过市中创建我自己的类型,swagger,swagger-2.0,swagger-editor,Swagger,Swagger 2.0,Swagger Editor,我有这个扬眉吐气的YAML代码,我需要创建自己的类型(名为MyOwnType) 如果使用“MyOwnType”,则会发生编译错误 paths: /in/total: get: summary: My summary. description: My description. parameters: - name: total in: query description: Total.
paths:
/in/total:
get:
summary: My summary.
description: My description.
parameters:
- name: total
in: query
description: Total.
required: true
type: MyOwnType # -- THIS LINE OCCURS ERROR --
format: MyOwnType
responses:
201:
description: Respose
schema:
$ref: '#/definitions/MyOwnType'
definitions:
MyOwnType:
properties:
var:
type: string
description: data.
我创建了一个定义“MyOwnType”,我可以这样使用:“$ref:'#/definitions/MyOwnType'”在模式中
但是如何在参数类型上使用“MyOwnType”定义?查询参数不能有JSON模式。如果要为参数设置架构,应将参数的
中的更改为body
或formData
,并使用schema
键:
swagger: '2.0'
info:
version: 0.0.0
title: '<enter your title>'
paths:
/in/total:
get:
summary: My summary.
description: My description.
parameters:
- name: total
in: body
description: Total.
required: true
schema:
$ref: '#/definitions/MyOwnType'
responses:
201:
description: Respose
schema:
$ref: '#/definitions/MyOwnType'
definitions:
MyOwnType:
properties:
var:
type: string
description: data.
swagger:'2.0'
信息:
版本:0.0.0
标题:“”
路径:
/总计:
获取:
小结:我的小结。
描述:我的描述。
参数:
-姓名:总计
在:身体
描述:总计。
必填项:true
模式:
$ref:“#/definitions/MyOwnType”
响应:
201:
描述:回复
模式:
$ref:“#/definitions/MyOwnType”
定义:
肌萎缩类型:
特性:
变量:
类型:字符串
说明:数据。