1

.yaml我在文件中尝试了两种方式,

email:
  name: email 
  description: Client email
  required: true
  type: string
  format: email
  in: formData


email:
  name: email 
  description: Client email
  required: true
  type: email
  in: formData

有人能指出正确的方法吗?

4

3 回答 3

2

在模式中,您必须输入示例的值。有时电子邮件格式没有得到很好的解释,它发生在我使用 Swashbuckle Nuget 库时。我的意思是,即使格式是电子邮件,它也不会在 Swagger-UI 中生成正确的示例值。

email:
  name: email 
  description: Client email
  required: true
  type: string
  format: email
  example: user@example.com
  in: formData
于 2019-12-12T17:25:51.623 回答
1

名称只是任何资源的一个字段。例如,如果您有一个用户,则定义将如下所示:

User:
  title: Simple user
  type: object
  properties:
    email:
      type: string
      format: email
    password:
      type: string
于 2018-03-20T20:42:55.103 回答
0

请参阅此发行说明

它表示默认情况下禁用格式验证,对于更复杂的格式(例如电子邮件地址),支持可能仍会有很大差异。目前还不清楚有多少实现曾经提供过这种级别的支持。

于 2020-04-07T10:20:13.440 回答