Skip to content

Commit

Permalink
Define the create, list, and get APIs for Customer. Closes #113. (pro…
Browse files Browse the repository at this point in the history
  • Loading branch information
chambridge authored May 8, 2018
1 parent 5a93be9 commit 7591c44
Showing 1 changed file with 177 additions and 8 deletions.
185 changes: 177 additions & 8 deletions docs/source/specs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,160 @@ paths:
schema:
$ref: "#/components/schemas/Status"
'500':
description: unexpected error
description: Unexpected Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v1/customers/:
post:
summary: Create a customer
operationId: createCustomer
tags:
- Customer
requestBody:
description: Customer to add to the service
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CustomerIn'
responses:
'201':
description: An object describing the customer
content:
application/json:
schema:
$ref: "#/components/schemas/CustomerOut"
'500':
description: Unexpected Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
get:
summary: List the customers
operationId: listCustomers
tags:
- Customer
responses:
'200':
description: A paginated list of customer objects
content:
application/json:
schema:
$ref: "#/components/schemas/CustomerPagination"
'500':
description: Unexpected Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/api/v1/customers/{id}/:
get:
summary: Get a customer
operationId: getCustomer
tags:
- Customer
parameters:
- name: id
in: path
description: ID of customer to get
required: true
schema:
type: string
format: uuid
responses:
'200':
description: A customer objects
content:
application/json:
schema:
$ref: "#/components/schemas/CustomerOut"

'404':
description: Not Found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
'500':
description: Unexpected Error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Customer:
required:
- name
properties:
name:
type: string
example: "My Tech Company"
CustomerIn:
allOf:
- $ref: "#/components/schemas/Customer"
- required:
- owner
properties:
owner:
$ref: "#/components/schemas/UserIn"
CustomerPagination:
allOf:
- $ref: "#/components/schemas/ListPagination"
- required:
- results
properties:
results:
type: array
items:
$ref: "#/components/schemas/CustomerOut"
CustomerOut:
allOf:
- $ref: "#/components/schemas/Customer"
- required:
- id
- owner
- date_created
properties:
id:
type: string
format: uuid
example: "600562e7-d7d7-4516-8522-410e72792daf"
owner:
$ref: "#/components/schemas/UserOut"
date_created:
type: string
format: date-time
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
ListPagination:
required:
- previous
- next
properties:
count:
type: integer
format: int64
example: 30
previous:
type: string
format: uri
example: "/api/v1/(resources)/?page=2"
next:
type: string
format: uri
example: "/api/v1/(resources)/?page=4"
Status:
required:
- api_version
Expand Down Expand Up @@ -72,13 +219,35 @@ components:
server_id:
type: string
example: "ff4eb8e4-ddfb-4b66-8e0e-045a244990f3"
Error:
User:
required:
- code
- message
- username
- email
properties:
code:
type: integer
format: int32
message:
username:
type: string
example: "smithj"
email:
type: string
format: email
example: "[email protected]"
UserIn:
allOf:
- $ref: "#/components/schemas/User"
- required:
- password
properties:
password:
type: string
format: uuid
example: "str0ng!P@ss"
UserOut:
allOf:
- $ref: "#/components/schemas/User"
- required:
- id
properties:
id:
type: string
format: uuid
example: "57e60f90-8c0c-4bd1-87a0-2143759aae1c"

0 comments on commit 7591c44

Please sign in to comment.