In my swagger Open API document I am giving Object Definition like below:
"definitions": {
  "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
     
          "firstName": {
            "type": "string"
          },
        
          "email": {
            "type": "string"
          },
          "shipDate": {
            "type": "string",
           "format": "date-time"
          },
         "status": {
          "type": "string",
          "description": "Order Status",
        "enum": [
          "placed",
          "approved",
          "delivered"
        ]
      }
}
I am not able to find format to be metioned for email address like :
 "email": {
        "type": "string",
        "format" : "####"
      }
I went through official Doc, they are saying :
Formats such as "email", "uuid", and so on, MAY be used even though undefined by this specification. Types that are not accompanied by a format property follow the type definition in the JSON Schema.
I am struggling to achieve this, Any hint how can I achieve this?
You can use a regex pattern to limit acceptable email domains. For example, if the email must end with .io you can use the \.[Ii][Oo]$ pattern:
"email": {
  "type": "string",
  "format": "email",
  "pattern": "\\.[Ii][Oo]$"
}
Note that the \ character inside a string is escaped as \\.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With