-
Notifications
You must be signed in to change notification settings - Fork 19
Api
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.
/* if in src/ */
import Api from './models/Api'
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()
})
-
Api.resources
expects an OrderedMap of Resource, which should contain all the Resources of the API. This field is required.
-
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 theApi.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
expects a Store containing all the shared objects that are used in the Api. This field is required.
-
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.
The Api
record does not expose any methods.