liveBook · Manning

Atomic type

As explained in The Design of Web APIs, Second Edition

A data type is a classification that specifies the kind of value a data element can contain and how it may be represented or processed.

An atomic data type identifies the kind of single value a data element contains, such as a string, number, or boolean. Choosing the type affects how consumers interpret and process API data. section 7.4 section 8.5

Choose atomic types as part of a broader data-modeling workflow:

  • List the concept’s elements before debating final names or types. section 5.2.5
  • Group related elements into objects or arrays, then choose each element’s type and whether it is required. section 5.2.5
  • Prefer correctly named booleans, and review strings and numbers for human readability and interoperability. section 8.5

A type choice changes consumer effort

A washing machine value such as {"ec": 50400} may technically communicate an end-of-cycle time, but consumers must decode and calculate it. A human-readable value such as {"endOfCycle": "2:35 pm"} communicates the meaning directly. The same concern applies when modeling a Product resource: productReference can be an integer, while supplier can be an object. section 8.0 section 5.1.3

Figure 8.11 Contrasting non-user-friendly and user-friendly data types and formats
figure

Compare user-friendly and non-user-friendly atomic data types and formats. section 8.5

How The Design of Web APIs, Second Edition covers it

How deep it goes
Explains type selection, requiredness, and readability, while deferring performance, security, and implementation constraints.
Examples
Uses washing-machine time values, Product properties, JSON Schema, and YAML or JSON atomic values as examples.
What it assumes
Builds from basic resource modeling and introduces strings, numbers, booleans, objects, arrays, and required properties.
What you can do after
Apply it via JSON Schema and OpenAPI to select and describe consumer-oriented API property types.
How it connects
Connects atomic types with data modeling, JSON Schema, OpenAPI, usability, and interoperability.

Also explained in

Compare how 17 books explain atomic type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.