2

I have a problem .

I created openApi request and I want to send to request not empty body

/test
  post:
   .
   .
   .
   requestBody:
     required:true

TestRequest
  type: object
  required:
    - testName
  properties:
    testName:
    type: string
    description: Test

I can send a request empty body like { } on postman.

How can i solve this problem .

Fatih AKSOY
  • 106
  • 1
  • 10
  • Do these links answer your question? -- [How to specify which fields in request body (POST) are required](https://stackoverflow.com/a/63944331/113116), [How to specify if a field is optional or required in OpenAPI/Swagger?](https://stackoverflow.com/q/40113049/113116) – Helen May 21 '21 at 15:30

1 Answers1

0

Your post definition states that a body is required. However, you have not defined what the shape of the data is that must go into that body.

Here is an example that assumes your TestRequest is defined inside components/schemas.

paths:
  /test:
    post:
      description: An example referencing TestRequest
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TestRequest'
Software2
  • 2,358
  • 1
  • 18
  • 28