Forum Discussion

vdkrav's avatar
vdkrav
Occasional Visitor
4 years ago

Would the object be implicitly required if it has some required properties?

if we have an object with 1+ required properties, and then this object is listed in the properties of some other object.

Would this object be implicitly required?

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Would this object be implicitly required?


    No.

    To make this object required you'll need to include it in the "required" list of the parent object:

    A:
      type: object
      required: [b]    # <----------
      properties:
        b:
          $ref: '#/components/schemas/B'
    
    B:
      type: object
      required: [foo, bar]
      properties:
        ...