@rvoh/dream
    Preparing search index...

    Function ObjectSerializer

    • Builds a serializer for a plain object or view model. A serializer is a function that takes the data to render and declares the keys to render it with:

      export const AddressSerializer = (address: Address) =>
      ObjectSerializer(address).attribute('city', { openapi: 'string' })

      A serializer must not read its data while being built: what it declares may not depend on its data. Dream and Psychic build it without data to read its shape (the OpenAPI schema, and the null and other-variant keys of a flattened association or customAttribute that uses it), so a serializer that reads its data while being built throws when a flattened association or customAttribute that uses it is rendered. Read the data inside a customAttribute callback, which runs only when the serializer renders, not while it is built.

      Type Parameters

      • DataType extends object | null
      • PassthroughDataType extends object | undefined = undefined

      Parameters

      • data: DataType

        The object to render

      • OptionalpassthroughData: PassthroughDataType

        Data available to this serializer and passed down to the serializers it renders

      Returns ObjectSerializerBuilder<DataType, PassthroughDataType, Exclude<DataType, null>>

      The serializer builder for method chaining