关于Swagger,哪一种是编写yaml文件的正确方法?
写yaml文件的正确方法是什么? 我有以下错误:“不是有效的参数定义” 在每个参数声明中关于Swagger,哪一种是编写yaml文件的正确方法?,swagger,Swagger,写yaml文件的正确方法是什么? 我有以下错误:“不是有效的参数定义” 在每个参数声明中 我还想知道将Sails JS与Swagger集成的正确方法?关于您的参数:我认为您必须使用“类型”,而不是“数据类型”: 参数: -姓名:电邮 swagger: "2.0" info: version: "1.0.0" title: "CCA API" host: localhost:1337 basePath: /v1 schemes: - http consumes: - appli
我还想知道将Sails JS与Swagger集成的正确方法?关于您的参数:我认为您必须使用“类型”,而不是“数据类型”: 参数: -姓名:电邮
swagger: "2.0"
info:
version: "1.0.0"
title: "CCA API"
host: localhost:1337
basePath: /v1
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/user/login:
post:
description: Access a user account
summary: User Account Access
operationId: loginAccount
parameters:
- name: email
dataType: string
in: body
required: true
description: Your email
- name: password
dataType: string
in: body
required: true
description: Your password
responses:
"200":
description: Successfully signed in
schema:
type: object
properties:
email:
type: string
firstName:
type: string
lastName:
type: string
token:
type: string
userType:
type: string
401:
description: Invalid email or password.
-名称:密码
type: string
in: body
required: true
description: Your email
正如Vantroys所说,数据类型不是正确的密钥。这是我喜欢的类型。 但是在本例中,您尝试定义一个post方法,并且需要定义某种类型的输入数据,如下面的示例所示。 让我们从swagger自身看一下宠物店的例子:
和的可能副本。更多信息:您使用
type
而不是dataType
是正确的,但是您的示例仍然不是描述JSON请求体的正确方法。应该是。
type: string
in: body
required: true
description: Your password
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"