2021-05-05 20:21:04 +00:00
|
|
|
"""OpenAPI v3 Specification"""
|
|
|
|
|
|
|
|
# apispec via OpenAPI
|
|
|
|
from apispec import APISpec
|
|
|
|
from apispec.ext.marshmallow import MarshmallowPlugin
|
|
|
|
from apispec_webframeworks.flask import FlaskPlugin
|
2021-05-06 15:35:44 +00:00
|
|
|
from .api_schemas import *
|
2021-05-06 01:03:00 +00:00
|
|
|
import pkg_resources
|
2021-05-05 20:21:04 +00:00
|
|
|
|
|
|
|
# Create an APISpec
|
|
|
|
spec = APISpec(
|
|
|
|
title="N.E.S.T.",
|
2021-05-13 17:24:44 +00:00
|
|
|
version=pkg_resources.get_distribution("nest").version,
|
2021-05-05 20:21:04 +00:00
|
|
|
openapi_version="3.0.2",
|
|
|
|
plugins=[FlaskPlugin(), MarshmallowPlugin()],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# register schemas with spec
|
|
|
|
spec.components.schema("Login", schema=LoginSchema)
|
|
|
|
spec.components.schema("Error", schema=ErrorSchema)
|
|
|
|
spec.components.schema("I_Login", schema=InputLoginSchema)
|
|
|
|
spec.components.schema("Success", schema=SuccesSchema)
|
|
|
|
spec.components.schema("EmailParameter", schema=EmailParameterSchema)
|
|
|
|
spec.components.schema("CreateUser", schema=CreateUser)
|
2021-05-05 20:45:36 +00:00
|
|
|
spec.components.schema("Repository", schema=RepositorySchema)
|
|
|
|
spec.components.schema("IntegerParameter", schema=IntegerParameterSchema)
|
|
|
|
spec.components.schema("RepositoryUpdate", schema=RepositoryUpdate)
|
2021-05-06 09:25:39 +00:00
|
|
|
spec.components.schema("CreateRepository", schema=CreateRepository)
|
|
|
|
spec.components.schema("CreateCondition", schema=CreateCondition)
|
2021-05-06 12:12:11 +00:00
|
|
|
spec.components.schema("ConditionParameter", schema=ConditionParameterSchema)
|
2021-05-07 17:31:57 +00:00
|
|
|
spec.components.schema("AlertParameter", schema=AlertParameterSchema)
|
2021-05-07 17:15:14 +00:00
|
|
|
spec.components.schema("Alert", schema=Alert)
|
2021-05-13 09:40:15 +00:00
|
|
|
spec.components.schema("Tweet", schema=TweetSchema)
|
2021-05-07 17:15:14 +00:00
|
|
|
spec.components.schema("CreateAlert", schema=CreateAlert)
|
2021-05-06 00:57:26 +00:00
|
|
|
spec.components.security_scheme("jwt", {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"})
|
2021-05-05 20:21:04 +00:00
|
|
|
|
|
|
|
# add swagger tags that are used for endpoint annotation
|
|
|
|
tags = [
|
|
|
|
{'name': 'user-related',
|
|
|
|
'description': 'User related calls of the API.'
|
|
|
|
},
|
|
|
|
{'name': 'repository-related',
|
|
|
|
'description': 'Repository related calls of the API.'
|
|
|
|
},
|
2021-05-06 12:12:11 +00:00
|
|
|
{'name': 'condition-related',
|
|
|
|
'description': 'Condition related calls of the API.'
|
|
|
|
},
|
2021-05-07 17:15:14 +00:00
|
|
|
{'name': 'alert-related',
|
|
|
|
'description': 'Alert related calls of the API.'
|
|
|
|
},
|
2021-05-05 20:21:04 +00:00
|
|
|
{'name': 'admin-only',
|
|
|
|
'description': 'Admin only calls of the API.'
|
|
|
|
},
|
|
|
|
{'name': 'debug',
|
|
|
|
'description': 'Debug only calls of the API.'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
for tag in tags:
|
|
|
|
spec.tag(tag)
|