Conjure offers the following abstractions to use when defining your APIs. To see the JSON representation of these types, see the Wire specification.
GET
,PUT
,POST
,DELETE
- HTTP methods.- Query parameters - e.g.
https://example.com/api/something?foo=bar&baz=2
- Path parameters - Parsed sections of URLs e.g.
https://example.com/repo/{owner}/{repo}/pulls/{id}
- Headers - A non-case sensitive string name associated with a Conjure value (see docs).
- Cookie auth - A HTTP Cookie, often used for authentication.
Users may define the following kinds of named types. These can be referenced by their name elsewhere in a Conjure definition.
- Object - a collection of named fields, each of which has their own Conjure type.
- Enum - a type consisting of named string variants, e.g. "RED", "GREEN", "BLUE".
- Alias - a named shorthand for another Conjure type, purely for readability.
- Union - a type representing different named variants, each of which can contain different types. (Also known as 'algebraic data types' or 'tagged unions')
list<T>
- an ordered sequence of items of typeT
.map<K, V>
- values of typeV
each indexed by a unique key of typeK
(keys are unordered).optional<T>
- represents a value of typeT
which is either present or not present.set<T>
- a collection of distinct values of typeT
.
any
- a catch-all type which can represent arbitrary JSON including lists, maps, strings, numbers or booleans.bearertoken
- a string Json Web Token (JWT)binary
- a sequence of binary.boolean
-true
orfalse
datetime
- an ISO 8601 value e.g.2018-07-25T10:20:32+01:00
double
- a floating point number specified by IEEE 754, which includes NaN, +/-Infinity and signed zero.integer
- a signed 32-bit integer value ranging from -231 to 231 - 1.rid
- a Resource Identifier, e.g.ri.recipes.main.ingredient.1234
safelong
- a signed 53-bit integer that can be safely represented by browsers without loss of precision, value ranges from -253 + 1 to 253 - 1string
- a sequence of UTF-8 charactersuuid
- Universally Unique Identifier (aka guid) represented as a string
When migrating an existing API, it may be useful to use the following 'escape hatch' type. These are not recommended for normal APIs because Conjure can't introspect these external types to figure out what their JSON structure will be, so they're effectively opaque.
- External Reference - a reference to a non-Conjure type, with an associated fallback Conjure type
Conjure allows defining named, structured errors so that clients can expect specific pieces of information on failure or handle entire categories of problems in one fell swoop.
- Structured errors - have the following properties:
- Name - a user chosen description of the error e.g.
RecipeLocked
- Namespace - a user chosen category of the error e.g.
RecipeErrors
- Code - one of the pre-defined categories.
- Args - a map from string keys to Conjure types
- Name - a user chosen description of the error e.g.