api_v1.4/hub_api/docs/openapi-specs.yml
guille 1adfe6519f Merge remote-tracking branch 'origin/city_commands' into api_guille
# Conflicts:
#	bootstrap.py
#	hub_api/city_commands.py
#	hub_api/config.py
#	hub_api/construction_catalog.py
#	hub_api/energy_demand.py
#	hub_api/greenery_catalog.py
#	hub_api/uptime.py
#	hub_api/user.py
#	requirements.txt
2023-02-13 07:15:10 -05:00

577 lines
15 KiB
YAML

info:
title: CERC API Swagger - OpenAPI 3.0
description: NextGen Cities Institute API
termsOfService: http://swagger.io/terms/
contact:
email: nextgen-cities@gmail.com
version: 1.4
externalDocs:
description: Find out more about Swagger
url: http://swagger.io
paths:
/v1.4/uptime:
get:
tags:
- Uptime
summary: API uptime
operationId: uptime
description: Retrieve current API uptime
parameters:
- in: header
name: appId
schema:
type: string
required: true
description: the Id of the application access this API
responses:
'200':
description: Request sucessful
content:
application/json:
schema:
$ref: '#/components/schemas/Uptime'
/v1.4/city:
post:
tags:
- city
summary: Create a city
operationId: createCity
description: Create a new city with a file upload
parameters:
- in: header
name: appId
schema:
type: string
required: true
description: the Id of the application access this API
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
city_file:
type: string
format: binary
required: true
responses:
'201':
description: City created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/City'
'200':
description: City not created
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'404':
description: City not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
security:
- BearerAuth: []
/v1.4/city/{city_id}:
get:
tags:
- city
summary: Get a city
operationId: getCity
description: Retrieve a city with a given city ID
parameters:
- in: header
name: appId
schema:
type: string
required: true
description: the ID of the application access this API
- in: path
name: city_id
schema:
type: integer
required: true
description: Numeric ID of the city to get
responses:
'200':
description: City retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/City'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'404':
description: City not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
put:
tags:
- city
summary: Update a city
operationId: updateCity
description: Create a new city with a file upload
parameters:
- in: header
name: appId
schema:
type: string
required: true
description: the Id of the application access this API
- in: path
name: city_id
schema:
type: integer
required: true
description: Numeric ID of the city to update
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
city_file:
type: string
format: binary
required: true
responses:
'201':
description: City updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/City'
'200':
description: City not updated
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'404':
description: City not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
security:
- BearerAuth: [ ]
delete:
tags:
- city
summary: Delete a city
operationId: deleteCity
description: Delete city with specified city_id
parameters:
- in: header
name: appId
schema:
type: string
required: true
description: the ID of the application access this API
- in: path
name: city_id
schema:
type: integer
required: true
description: Numeric ID of the city to delete
responses:
'201':
description: City deleted successfully
content:
application/json:
schema:
$ref: '#/components/schemas/City'
'200':
description: City not deleted
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'404':
description: City not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
security:
- BearerAuth: [ ]
/v1.4/user:
post:
tags:
- user
summary: Create user
description: This can only be done by the logged in admin.
operationId: createUser
parameters:
- in: header
name: appId
schema:
type: string
required: true
description: the Id of the application access this API
requestBody:
description: Created user object
content:
application/json:
schema:
$ref: '#/components/schemas/User'
application/xml:
schema:
$ref: '#/components/schemas/User'
responses:
'201':
description: User created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
security:
- BearerAuth: [ ]
put:
tags:
- user
summary: Update user
description: This can only be done by the logged in admin.
operationId: updateUser
requestBody:
description: Update user object
content:
application/json:
schema:
$ref: '#/components/schemas/User'
application/xml:
schema:
$ref: '#/components/schemas/User'
responses:
'201':
description: User updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/User'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'403':
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
security:
- BearerAuth: [ ]
/v1.4/user/login:
post:
tags:
- user
summary: Logs user into the system
description: ''
operationId: loginUser
parameters:
- in: header
name: appId
schema:
type: string
required: true
description: the Id of the application access this API
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Login'
required: true
responses:
'200':
description: Login successful
content:
application/json:
schema:
$ref: '#/components/schemas/LoginRes'
'400':
description: Invalid username/password supplied
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
components:
schemas:
Uptime:
type: object
properties:
uptime:
type: string
format: hh:mm:ss.ms
example: "00:09:53.600281"
City:
type: object
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: Montreal
srs_name:
type: string
example: EPSG:26918
country:
type: string
example: ca
lon:
type: float
example: 0.38292983
lat:
type: float
example: 0.92898883
time_zone:
type: string
example: utc
city_version:
type: integer
format: int64
example: 1
lower_corner:
type: array
items:
type: float
example: [610610.7547462888,5035770.347264212,566.5784301757819]
upper_corner:
type: array
items:
type: float
example: [610610.7547462888,5035770.347264212,566.5784301757819]
user:
type: object
$ref: '#/components/schemas/User'
created:
type: string
example: 2023-01-15 18:40:54.64877
updated:
type: string
example: 2023-01-15 18:40:54.64877
User:
type: object
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: Peter Yefi
email:
type: string
format: email
example: peteryefi@gmail.com
password:
type: string
example: 'Hub@183838'
role:
type: string
enum:
- Admin
- Hub_Reader
required:
- name
- email
- password
- role
Login:
type: object
properties:
email:
type: string
example: peteryefi@gmail.com
password:
type: string
example: 'Hub@183838'
required:
- email
- password
LoginRes:
type: object
properties:
token:
type: string
example: eylskdkdjfkdj67uhbnmkhbn908uyhndh
user:
type: object
$ref: '#/components/schemas/User'
ApiResponse:
type: object
properties:
code:
type: integer
format: int32
message:
type: string
Uptime:
type: object
properties:
uptime:
type: string
requestBodies:
User:
description: User object that is to be created
content:
application/json:
schema:
$ref: '#/components/schemas/User'
application/xml:
schema:
$ref: '#/components/schemas/User'
CityArray:
description: List of city object
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/City'
securitySchemes:
BearerAuth:
type: http
scheme: bearer
bearerFormat: JWT