Speakeasy Logo
Skip to Content

objects in OpenAPI

The object type allows simple and complex objects, dictionaries and free form objects, along with a number of attributes to control validation.

Fully typed object

Fully typed objects can be described by providing a properties attribute that lists each property of the object and its associated type.

Objects with properties have access to some additional attributes that allow the objects to be validated in various ways:

  • required - A list of properties that are required. Specified at the object level.
  • readOnly - A property that is only available in a response.
  • writeOnly - A property that is only available in a request.

Using Object for Dictionaries

The object type can also be used to describe dictionaries/maps/etc that use strings for keys and support any value type that can be described by the OpenAPI Spec.

You can also describe dictionaries that will contain certain keys

When using the additionalProperties attribute you can also specify additional attributes to validate the number of properties in the object:

  • minProperties - The minimum number of properties allowed in the object.
  • maxProperties - The maximum number of properties allowed in the object.

For example:

Free form objects

The object type can also be used to describe any arbitrary key/value pair (where the keys are still required to be strings).

Last updated on