-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use api generated docs instead of comments
- Loading branch information
Showing
97 changed files
with
2,247 additions
and
631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>ahriman API</title> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<!-- Embed elements Elements via Web Component --> | ||
<script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script> | ||
<link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css" type="text/css"> | ||
|
||
<link rel="shortcut icon" href="/static/favicon.ico"> | ||
</head> | ||
<body> | ||
|
||
<elements-api | ||
apiDescriptionUrl="/api-docs/swagger.json" | ||
router="hash" | ||
layout="sidebar" | ||
/> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# | ||
# Copyright (c) 2021-2023 ahriman team. | ||
# | ||
# This file is part of ahriman | ||
# (see https://github.com/arcan1s/ahriman). | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
import aiohttp_apispec # type: ignore | ||
|
||
from aiohttp import web | ||
from typing import Any, Dict, List | ||
|
||
from ahriman import version | ||
from ahriman.core.configuration import Configuration | ||
|
||
|
||
__all__ = ["setup_apispec"] | ||
|
||
|
||
def _info() -> Dict[str, Any]: | ||
""" | ||
create info object for swagger docs | ||
Returns: | ||
Dict[str, Any]: info object as per openapi specification | ||
""" | ||
return { | ||
"title": "ahriman", | ||
"description": """Wrapper for managing custom repository inspired by [repo-scripts](https://github.com/arcan1s/repo-scripts). | ||
## Features | ||
* Install-configure-forget manager for the very own repository. | ||
* Multi-architecture support. | ||
* Dependency manager. | ||
* VCS packages support. | ||
* Official repository support. | ||
* Ability to patch AUR packages and even create package from local PKGBUILDs. | ||
* Sign support with gpg (repository, package, per package settings). | ||
* Triggers for repository updates, e.g. synchronization to remote services (rsync, s3 and github) and report generation (email, html, telegram). | ||
* Repository status interface with optional authorization and control options | ||
<security-definitions /> | ||
""", | ||
"license": { | ||
"name": "GPL3", | ||
"url": "https://raw.githubusercontent.com/arcan1s/ahriman/master/LICENSE", | ||
}, | ||
"version": version.__version__, | ||
} | ||
|
||
|
||
def _security() -> List[Dict[str, Any]]: | ||
""" | ||
get security definitions | ||
Returns: | ||
List[Dict[str, Any]]: generated security definition | ||
""" | ||
return [{ | ||
"token": { | ||
"type": "apiKey", # as per specification we are using api key | ||
"name": "API_SESSION", | ||
"in": "cookie", | ||
} | ||
}] | ||
|
||
|
||
def _servers(application: web.Application) -> List[Dict[str, Any]]: | ||
""" | ||
get list of defined addresses for server | ||
Args: | ||
application(web.Application): web application instance | ||
Returns: | ||
List[Dict[str, Any]]: list (actually only one) of defined web urls | ||
""" | ||
configuration: Configuration = application["configuration"] | ||
address = configuration.get("web", "address", fallback=None) | ||
if not address: | ||
host = configuration.get("web", "host") | ||
port = configuration.getint("web", "port") | ||
address = f"http://{host}:{port}" | ||
|
||
return [{ | ||
"url": address, | ||
}] | ||
|
||
|
||
def setup_apispec(application: web.Application) -> aiohttp_apispec.AiohttpApiSpec: | ||
""" | ||
setup swagger api specification | ||
Args: | ||
application(web.Application): web application instance | ||
Returns: | ||
aiohttp_apispec.AiohttpApiSpec: created specification instance | ||
""" | ||
return aiohttp_apispec.setup_aiohttp_apispec( | ||
application, | ||
url="/api-docs/swagger.json", | ||
openapi_version="3.0.2", | ||
info=_info(), | ||
servers=_servers(application), | ||
security=_security(), | ||
) |
Oops, something went wrong.