From c70e8e27fcf0a17e96cdb673d4f284b29a0af06f Mon Sep 17 00:00:00 2001 From: puc9 <51006296+puc9@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:47:15 -0700 Subject: [PATCH 1/2] Fix number/boolean and nullable object generation --- mitmproxy2swagger/swagger_util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mitmproxy2swagger/swagger_util.py b/mitmproxy2swagger/swagger_util.py index 32a4ae4..fd0664d 100644 --- a/mitmproxy2swagger/swagger_util.py +++ b/mitmproxy2swagger/swagger_util.py @@ -112,7 +112,7 @@ def response_to_headers(headers): def value_to_schema(value): # check if value is a number - if isinstance(value, (int, float)): + if type(value) is int or type(value) is float: return {"type": "number"} # check if value is a boolean elif isinstance(value, bool): @@ -143,7 +143,11 @@ def value_to_schema(value): } # if it is none, return null elif value is None: - return {"type": "object"} + return { + "type": "object", + "nullable": True + } + def is_uuid(key): From 9c29226973b9e5eab90dd5d27f1747900eafa873 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 22:00:52 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mitmproxy2swagger/swagger_util.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mitmproxy2swagger/swagger_util.py b/mitmproxy2swagger/swagger_util.py index fd0664d..27adf84 100644 --- a/mitmproxy2swagger/swagger_util.py +++ b/mitmproxy2swagger/swagger_util.py @@ -143,11 +143,7 @@ def value_to_schema(value): } # if it is none, return null elif value is None: - return { - "type": "object", - "nullable": True - } - + return {"type": "object", "nullable": True} def is_uuid(key):