From 801f51a070ab50210477f18e39ddc9a4103c6ad4 Mon Sep 17 00:00:00 2001 From: Vladimir Neverov Date: Tue, 19 Oct 2021 18:35:10 +0300 Subject: [PATCH 1/2] Add 'null' type to type list for fields marked as nullable in OpenAPI spec --- openapi2jsonschema/util.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openapi2jsonschema/util.py b/openapi2jsonschema/util.py index 34270d2..929a385 100644 --- a/openapi2jsonschema/util.py +++ b/openapi2jsonschema/util.py @@ -77,7 +77,10 @@ def allow_null_optional_fields(data, parent=None, grand_parent=None, key=None): def change_dict_values(d, prefix, version): new = {} try: + is_nullable = False for k, v in iteritems(d): + if k == 'nullable': + is_nullable = True new_v = v if isinstance(v, dict): new_v = change_dict_values(v, prefix, version) @@ -94,6 +97,10 @@ def change_dict_values(d, prefix, version): else: new_v = v new[k] = new_v + if is_nullable and 'type' in new: + if not isinstance(new['type'], list): + new['type'] = [new['type']] + new['type'].append('null') return new except AttributeError: return d From b9ea5c9db35c3aaddc6db7f53296e5450f363a35 Mon Sep 17 00:00:00 2001 From: Vladimir Neverov Date: Wed, 8 Nov 2023 12:48:35 +0400 Subject: [PATCH 2/2] Upgrade click dependency from ^7 to ^8 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0831c09..2e1164f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ keywords = ["openapi", "jsonschema"] python = "^3.7" jsonref = "^0.2.0" pyyaml = "^5.1" -click = "^7.0" +click = "^8.0" colorama = "^0.4.1" [tool.poetry.scripts]