Skip to content

Instantly share code, notes, and snippets.

@alexisvisco
Created June 16, 2019 18:57
Show Gist options
  • Save alexisvisco/fbca6ec75ba7870bb8a1c0548d315f46 to your computer and use it in GitHub Desktop.
Save alexisvisco/fbca6ec75ba7870bb8a1c0548d315f46 to your computer and use it in GitHub Desktop.
openapi: "3.0.0"
info:
version: 1.0.0
title: Expected API spec
servers:
- url: http://localhost:{port}/{basePath}
description: "Development server"
variables:
basePath:
default: "api/v1"
port:
default: "8080"
- url: https://expected.sh/{basePath}
description: "Official server"
variables:
basePath:
default: "api/v1"
tags:
- name: "Authentication"
description: "Routes about authentication"
- name: "Accounts"
description: "Routes about accounts"
- name: "Teams"
description: "Routes about teams"
paths:
/auth/register:
post:
description: Create a new account
tags:
- Authentication
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PostAuthRegisterRequest'
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PostAuthRegisterResponse'
400:
$ref: '#/components/responses/400'
500:
$ref: '#/components/responses/500'
/auth/login:
post:
description: Login an user, get the apikey
tags:
- Authentication
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PostAuthLoginRequest'
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PostAuthLoginResponse'
400:
$ref: '#/components/responses/400'
500:
$ref: '#/components/responses/500'
/teams:
post:
description: Create a new team
security:
- apiKey: [APIKeyAuth]
tags:
- Teams
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PostTeamRequest'
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PostTeamsResponse'
400:
$ref: '#/components/responses/400'
500:
$ref: '#/components/responses/500'
403:
$ref: '#/components/responses/403'
get:
description: Get all teams for the authenticated account
security:
- apiKey: [APIKeyAuth]
tags:
- Teams
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/PostTeamResponse'
400:
$ref: '#/components/responses/400'
500:
$ref: '#/components/responses/500'
403:
$ref: '#/components/responses/403'
components:
securitySchemes:
APIKeyAuth:
type: apiKey
in: header
name: Authorization
responses:
400:
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
500:
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
403:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
schemas:
Model:
type: object
properties:
id:
type: string
created_at:
type: string
deleted_at:
type: string
Account:
type: object
allOf:
- $ref: '#/components/schemas/Model'
properties:
name:
type: string
email:
type: string
Permission:
type: object
allOf:
- $ref: '#/components/schemas/Model'
properties:
acceptance_regexp:
type: string
exclusion_regexp:
type: string
push:
type: boolean
pull:
type: boolean
delete:
type: boolean
Group:
type: object
allOf:
- $ref: '#/components/schemas/Model'
properties:
name:
type: string
members:
type: array
items:
$ref: '#/components/schemas/Account'
permissions:
type: array
items:
$ref: '#/components/schemas/Permission'
Team:
type: object
allOf:
- $ref: '#/components/schemas/Model'
properties:
name:
type: string
members:
type: array
items:
$ref: '#/components/schemas/Account'
groups:
type: array
items:
$ref: '#/components/schemas/Group'
owners:
type: array
items:
type: string
Error:
type: object
properties:
details:
type: object
additionalProperties:
type: string
code:
type: integer
PostAuthRegisterRequest:
type: object
properties:
name:
type: string
email:
type: string
password:
type: string
PostAuthRegisterResponse:
type: object
properties:
account:
$ref: '#/components/schemas/Account'
PostAuthLoginRequest:
type: object
properties:
email:
type: string
password:
type: string
PostAuthLoginResponse:
type: object
properties:
account:
$ref: '#/components/schemas/Account'
api_key:
type: string
PostTeamRequest:
type: object
properties:
name:
type: string
members:
type: array
items:
type: string
PostTeamResponse:
type: object
properties:
team:
$ref: '#/components/schemas/Team'
PostTeamsResponse:
type: object
properties:
team:
type: array
items:
$ref: '#/components/schemas/Team'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment