Add Swagger to API package

This commit is contained in:
Inex Code 2021-11-16 17:08:58 +03:00
parent b4bc3a4ffc
commit 8b5865c332
5 changed files with 22 additions and 3 deletions

View file

@ -25,6 +25,13 @@ in
SelfPrivacy API token
'';
};
enableSwagger = mkOption {
default = false;
type = types.bool;
description = ''
Enable Swagger UI
'';
};
};
config = lib.mkIf cfg.enable {
@ -35,6 +42,7 @@ in
HOME = "/root";
PYTHONUNBUFFERED = "1";
AUTH_TOKEN = cfg.token;
ENABLE_SWAGGER = (if cfg.enableSwagger then "1" else "0");
} // config.networking.proxy.envVars;
path = [ "/var/" "/var/dkim/" pkgs.coreutils pkgs.gnutar pkgs.xz.bin pkgs.gzip pkgs.gitMinimal config.nix.package.out pkgs.nixos-rebuild pkgs.restic pkgs.mkpasswd ];
after = [ "network-online.target" ];

View file

@ -4,7 +4,7 @@ let
inherit (nixpkgs) pkgs;
inherit pythonPkgs;
selfprivacy-api = { buildPythonPackage, flask, flask-restful, setuptools, portalocker }:
selfprivacy-api = { buildPythonPackage, flask, flask-restful, setuptools, portalocker, flask-swagger, flask-swagger-ui }:
buildPythonPackage rec {
pname = "selfprivacy-api";
version = "1.1";
@ -12,7 +12,7 @@ let
url = "https://git.selfprivacy.org/ilchub/selfprivacy-rest-api.git";
rev = "dbb4c1095654bba88d4f0c91b7b195d5262976b6";
};
propagatedBuildInputs = [ flask flask-restful setuptools portalocker ];
propagatedBuildInputs = [ flask flask-restful setuptools portalocker flask-swagger flask-swagger-ui ];
meta = {
description = ''
SelfPrivacy Server Management API

View file

@ -3,6 +3,7 @@
services.selfprivacy-api = {
enable = true;
token = config.services.userdata.api.token;
enableSwagger = config.services.userdata.api.enableSwagger;
};
users.users."selfprivacy-api" = {

View file

@ -23,6 +23,9 @@
"properties": {
"token": {
"type": "string"
},
"enableSwagger": {
"type": "boolean"
}
}
},

View file

@ -44,6 +44,13 @@ in
'';
type = types.nullOr types.str;
};
enableSwagger = mkOption {
default = true;
description = ''
Enable Swagger UI
'';
type = types.bool;
};
};
backblaze = {
bucket = mkOption {
@ -132,7 +139,7 @@ in
};
rootKeys = mkOption {
description = ''
Root SSH Keys
Root SSH Keys
'';
type = types.nullOr (types.listOf types.str);
};