1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 buildPythonPackage,
6 pythonOlder,
7
8 # build-system
9 poetry-core,
10
11 # dependencies
12 asgiref,
13 httpx,
14 inflection,
15 jsonschema,
16 jinja2,
17 python-multipart,
18 pyyaml,
19 requests,
20 starlette,
21 typing-extensions,
22 werkzeug,
23
24 # optional-dependencies
25 a2wsgi,
26 flask,
27 swagger-ui-bundle,
28 uvicorn,
29
30 # tests
31 pytest-aiohttp,
32 pytestCheckHook,
33 testfixtures,
34}:
35
36buildPythonPackage rec {
37 pname = "connexion";
38 version = "3.2.0";
39 pyproject = true;
40
41 disabled = pythonOlder "3.8";
42
43 src = fetchFromGitHub {
44 owner = "spec-first";
45 repo = "connexion";
46 tag = version;
47 hash = "sha256-ruwpA2yd7FRME1FvYrZh0EOnhmQ26YVouXzpVD9ph6g=";
48 };
49
50 build-system = [ poetry-core ];
51
52 dependencies = [
53 asgiref
54 httpx
55 inflection
56 jsonschema
57 jinja2
58 python-multipart
59 pyyaml
60 requests
61 starlette
62 typing-extensions
63 werkzeug
64 ];
65
66 optional-dependencies = {
67 flask = [
68 a2wsgi
69 flask
70 ];
71 swagger-ui = [ swagger-ui-bundle ];
72 uvicorn = [ uvicorn ];
73 };
74
75 nativeCheckInputs = [
76 pytest-aiohttp
77 pytestCheckHook
78 testfixtures
79 ]
80 ++ lib.flatten (builtins.attrValues optional-dependencies);
81
82 pythonImportsCheck = [ "connexion" ];
83
84 disabledTests = [
85 "test_build_example"
86 "test_mock_resolver_no_example"
87 "test_sort_apis_by_basepath"
88 "test_sort_routes"
89 # Tests require network access
90 "test_remote_api"
91 ]
92 ++ lib.optionals stdenv.hostPlatform.isDarwin [
93 # ImportError: Error while finding loader for '/private/tmp/nix-build-python3.12-connexion-3.1.0.drv-0/source' (<class 'ModuleNotFoundError'>: No module named '/private/tmp/nix-build-python3')
94 "test_lifespan"
95 ];
96
97 meta = {
98 description = "Swagger/OpenAPI First framework on top of Flask";
99 homepage = "https://github.com/spec-first/connexion";
100 changelog = "https://github.com/spec-first/connexion/releases/tag/${version}";
101 license = lib.licenses.asl20;
102 maintainers = with lib.maintainers; [ bot-wxt1221 ];
103 mainProgram = "connexion";
104 };
105}