Skip to content
Jonathan Montane edited this page Jan 31, 2017 · 1 revision

Api components act as containers for all the other components of API-Flow's modeling suite. They contain four critical subcomponents named resources, group, store and info. By design, Parsers are expected to return an Api record that can then be used by the Serializers.

Import

/* if in src/ */
import Api from './models/Api'

Interface

Api extends Record using the following pattern:

import { Record, OrderedMap } from 'immutable'
import Store from './Store'
import Info from './Info'

const Api = Record({
   resources: OrderedMap()
   group: null,
   store: new Store(),
   info: new Info()
})

Fields

Api.resources
  • Api.resources expects an OrderedMap of Resource, which should contain all the Resources of the API. This field is required.
Api.group
  • Api.group expects a Group, which should contain Groups and Resource ids. The Resource ids must be the unique identifiers of the Resources stored in the Api.resources field. This allows the parser to pass the original structure to serializers that do not have a fixed structure for the requests (like Paw, Insomnia or Postman).
Api.store
  • Api.store expects a Store containing all the shared objects that are used in the Api. This field is required.
Api.info
  • Api.info expects an Info record that contains meta data pertaining to the Api itself, such as the name of the Api, its version, description, etc. This field is required.

Methods

The Api record does not expose any methods.

Clone this wiki locally