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 SelfPrivacy API token
''; '';
}; };
enableSwagger = mkOption {
default = false;
type = types.bool;
description = ''
Enable Swagger UI
'';
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -35,6 +42,7 @@ in
HOME = "/root"; HOME = "/root";
PYTHONUNBUFFERED = "1"; PYTHONUNBUFFERED = "1";
AUTH_TOKEN = cfg.token; AUTH_TOKEN = cfg.token;
ENABLE_SWAGGER = (if cfg.enableSwagger then "1" else "0");
} // config.networking.proxy.envVars; } // 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 ]; 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" ]; after = [ "network-online.target" ];

View file

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

View file

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

View file

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

View file

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