An attribute, or property, is a named piece of data belonging to an object. In JSON, its quoted name is followed by a colon and a value. In an API, properties describe a resource without necessarily being resources themselves: a product has a name, but that name cannot exist independently. A price might instead warrant its own resource if consumers need to track its history. section 5.1.2 section 3.3.1
Describing a product
A product can have an integer productReference, a string name, a numeric price, a Boolean isProductAvailable, an array of keywords, and a supplier object. The supplier can in turn have supplierCode and name properties. Include related data when consumers need it: a supplier name may be useful alongside its code, while the code can identify the related supplier resource. section 5.2.3 section 5.2.2
To model properties without getting stuck on naming debates:
- List the data consumers need, including an identifier. Check ideas with subject matter experts; treat an existing UI or database as input, not an unquestioned specification. section 5.2.2
- Group related elements into objects or arrays. Then choose portable types, consistent names, and which properties are required; remove elements that do not make sense. section 5.2.5 section 5.2.3
- Add a description when name and type are insufficient—for example, to state that a price uses US dollars or a date string uses YYYY-MM-DD. section 5.2.3
Listing 7.6 An inner object
...
Product:
type: object #1
properties:
...
supplier:
type: object #1
properties: #2
supplierCode:
type: string
description: Unique identifier
name:
type: string
In an OpenAPI JSON Schema, properties maps names to schemas. The supplier property has type object and its own properties map for supplierCode and name. This example does not yet mark either nested property as required. section 7.4.4
Keep essential subject matter in the resource data even if metadata also conveys it: a transfer’s cancellable flag tells consumers something important about the transfer. As a check on a schema, try specifying a rule that every 201 response defines a required string or integer id property. section 11.4.5 section 18.15



























