File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """A Python wrapper for the OpenAPI Generator CLI."""
2+
13from __future__ import annotations
24
35import importlib .resources
68import sys
79
810
9- def run (args : list [str ] | None = None ) -> None :
11+ def run (args : list [str ] | None = None ) -> subprocess .CompletedProcess [bytes ]:
12+ """Run the OpenAPI Generator CLI with the given arguments.
13+
14+ Args:
15+ args (list[str], optional):
16+ The list of arguments to pass to the Open
17+ API Generator CLI. If not provided, the CLI will
18+ be run without any arguments.
19+
20+ Returns:
21+ subprocess.CompletedProcess[bytes]: The result of running the OpenAPI Generator CLI.
22+
23+ """
1024 arguments = ["java" ]
1125
1226 java_opts = os .getenv ("JAVA_OPTS" )
@@ -18,13 +32,14 @@ def run(args: list[str] | None = None) -> None:
1832 jar_path = importlib .resources .files ("openapi_generator_cli" ) / "openapi-generator.jar"
1933 arguments .append (str (jar_path ))
2034
21- if args and type (args ) == list :
35+ if args and isinstance (args , list ) :
2236 arguments .extend (args )
2337
24- subprocess .call (arguments ) # noqa: S603
38+ return subprocess .run (arguments , check = False ) # noqa: S603
2539
2640
2741def cli () -> None :
42+ """Run the OpenAPI Generator CLI with the arguments provided on the command line."""
2843 args = []
2944 if len (sys .argv ) > 1 :
3045 args = sys .argv [1 :]
You can’t perform that action at this time.
0 commit comments