Asanka
Asanka

Reputation: 618

Swagger validation , email type not working

I tried with both way in .yaml file ,

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

can some one point out the correct way?

Upvotes: 1

Views: 12104

Answers (3)

Chintan Pandya
Chintan Pandya

Reputation: 368

Please refer This release note

It says that by default format validation is disabled and for more complex formats such as email addresses, support will probably still vary significantly. It’s unclear how many implementations have ever provided this level of support.

Upvotes: 0

isaacfi
isaacfi

Reputation: 310

At the schema, you have to put the value of the example. Sometimes the email format is not interpreted well, it happens me with the Swashbuckle Nuget library. I mean, even if the format is email, it wouldn't generate the right example value in Swagger-UI.

email:
  name: email 
  description: Client email
  required: true
  type: string
  format: email
  example: [email protected]
  in: formData

Upvotes: 2

SebaReal
SebaReal

Reputation: 161

Name is only a field of any resource. If you have a user, for example, the definition will be like this:

User:
  title: Simple user
  type: object
  properties:
    email:
      type: string
      format: email
    password:
      type: string

Upvotes: 1

Related Questions