Document API authentication (#2021)

* Document API authentication and Content-Type header requirement
This commit is contained in:
Nikita Stupin
2021-11-22 13:38:19 +03:00
committed by GitHub
parent 7fc05bd4e3
commit a0783c334c

View File

@@ -26,7 +26,26 @@ from CTFd.api.v1.unlocks import unlocks_namespace
from CTFd.api.v1.users import users_namespace
api = Blueprint("api", __name__, url_prefix="/api/v1")
CTFd_API_v1 = Api(api, version="v1", doc=current_app.config.get("SWAGGER_UI_ENDPOINT"))
CTFd_API_v1 = Api(
api,
version="v1",
doc=current_app.config.get("SWAGGER_UI_ENDPOINT"),
authorizations={
"AccessToken": {
"type": "apiKey",
"in": "header",
"name": "Authorization",
"description": "Generate access token in the settings page of your user account.",
},
"ContentType": {
"type": "apiKey",
"in": "header",
"name": "Content-Type",
"description": "Must be set to `application/json`",
},
},
security=["AccessToken", "ContentType"],
)
CTFd_API_v1.schema_model("APISimpleErrorResponse", APISimpleErrorResponse.schema())
CTFd_API_v1.schema_model(