'Dependant fields for required true Swagger

I have these 2 fields.

- name: cropping
  in: query
  description: Is cropping a specific area from the snapshot.
  required: false
  style: form
  explode: true
  schema:
    type: boolean
- name: coordinates
  in: query
  description: Percentages (%) for all 4 dimentions you want to crop.
  content:
    application/json:
      schema:
        type: object
        required:
          - width
          - height
          - left
          - top
        properties:
          width:
            type: integer
          height:
            type: integer
          left:
            type: integer
          top:
            type: integer
  1. cropping, which is not required and It's optional but when it's filled by the user, as true. I am trying to make the coordinates field to be required true as well.

  2. Also In the coordinates object, all 4 keys need to be present. I have added the required to that but it's not working.

Any help would be wonderful. my open API specs as openapi: 3.0.0



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source