liveBook · Manning

Content field

As explained in API Design Patterns

A content field is a resource field whose meaning and value structure represent the content associated with a resource subtype.

A content field stores the value associated with a resource subtype. Its meaning may remain consistent across types, or its structure may change according to a type field. section 16.3.2

Choose the simplest structure that remains practical:

  • Use one string when text, a URI, or another shared representation is sufficient. section 16.3.2

Polymorphic message content

A Message may declare type as text, photo, audio, or video. Text can use a string content value, while media can use an object containing its URI and encoding format. Interpret and validate content according to type. section 16.3.2

How API Design Patterns covers it

How deep it goes
Compares shared fields, separate fields, and structured unions, then addresses type-dependent validation.
Examples
Uses Message variants, media metadata, separate URI fields, and Shape dimension unions to compare designs.
What you can do after
Evaluate and design content fields by balancing abstraction, subtype clarity, and type-specific validation.
How it connects
Connects polymorphic resources with type fields, media content, field structure, and data validation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.