aka documenting your work
Really think about your API before building
Really think about your API before building
Make an API someone else might like to use
Really think about your API before building
Make an API someone else might like to use
Easier to collaborate- defined inputs and outputs
Really think about your API before building
Make an API someone else might like to use
Easier to collaborate- defined inputs and outputs
Work with an API before it's finished
(It's harder to document after the fact)
Kill two birds with one stone
It grows unpredictably and starts to smell
APIs are predictable
name - string, required
category - string, required
photoUrls - array, optional
PhotoURL
url - string, required
status - string, required
description - string, optional
{
"id": 7431699383703929000,
"name" : "Scruffy",
"photoUrls": [],
"tags": []
}
{
"err": "TypeError,
"description" : "Could not insert pet, missing field: name",
}
Yet Another Markup Language
Yet Another Markup Language
it's really called that
swagger: "2.0"
info:
title: Uber API
description: Move your app forward with the Uber API
version: "1.0.0"
# the domain of the service
host: api.uber.com
# this is an example of the Uber API
# as a demonstration of an API spec in YAML
swagger: "2.0"
info:
title: Uber API
description: Move your app forward with the Uber API
version: "1.0.0"
# the domain of the service
host: api.uber.com
# array of all schemes that your API supports
schemes:
- https
# will be prefixed to all paths
basePath: /v1
securityDefinitions:
apikey:
type: apiKey
name: server_token
in: query
produces:
- application/json
paths:
/products:
get:
summary: Product Types
description: The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order.
parameters:
- name: latitude
in: query
description: Latitude component of location.
required: true
type: number
format: double
- name: longitude
in: query
description: Longitude component of location.
required: true
type: number
format: double
security:
- apikey: []
tags:
- Products
responses:
200:
description: An array of products
schema:
type: array
items:
$ref: '#/definitions/Product'
default:
description: Unexpected error
schema:
$ref: '#/definitions/Error'
definitions:
Product:
properties:
product_id:
type: string
description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles.
description:
type: string
description: Description of product.
display_name:
type: string
description: Display name of product.
capacity:
type: integer
description: Capacity of product. For example, 4 people.
image:
type: string
description: Image URL representing the product.