What does 'required' in OpenAPI really mean

Viewed 27045

Given the following OpenAPI definition

Person:
  required:
    - id
  type: object
  properties:
    id:
      type: string

Which of the below objects are valid? Just 1. or 1. & 2.?

  1. {"id": ""}
  2. {"id": null}
  3. {}

This boils down to the question whether "required = true" means "non-null value" or "property must be present".

The JSON schema validator at https://json-schema-validator.herokuapp.com/ says that 2. be invalid because null doesn't satisfy the type: string constraint. Note that it doesn't complain because id is null but because null is not a string. BUT how relevant is this for OpenAPI/Swagger?

1 Answers
Related