openapi spec with regx

Hi, Hope you are doing well!!

I have a scenario like I have to create open api spec for a particular payload like 

{
    "inta": "1234567890",
    "intb": 13243567890098,
    "new": ["a","aa","aaa"]
}

For inta : This is required field ,I have to apply regex in first field that should be a string and should be only 10 digit

For intb:   In second field ,This is optional and fix it as it should be 5 digits in integer format without regex

For new : This is required field and it should be list of array of strings

And then I have to validate using OpenApiSpec Policy

I have created a spec for that but I don't have any idea for regex pattern how I can check this in body and one thing also that I want to apply required :true in inta and new field and intb is optional

openapi: 3.0.0
info:
  title: A dummy title
  version: 1.0.0
paths:
  /post:
    post:
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - msisdn
                - network
              properties:
                msisdn:
                  type: string
                  pattern: ^[0-9]{10}$
                  example: "12345678976"
                IMEI:
                  type: integer
                Network:
                  type: string
              example:   # Sample object
                msisdn: "10"
                IMEI: 20
                Network:
                - Vodafone
                - Jio
                - Airtel
        required: true        
            
      responses:
        '200':
          description: OK
servers:
  - url: http://httpbin.org

 Please also let me know this is my spec is correct for my requirement and please help me with regex pattern and required tag in spec?

It would be really appreciate

0 0 399
0 REPLIES 0