From 99a5dfb5d94ecdfa9e73b2e9f6bcef7f6e037842 Mon Sep 17 00:00:00 2001 From: Xiaozhou Li Date: Tue, 25 Aug 2020 10:36:17 +0200 Subject: [PATCH 1/3] Ignore spec generation if Enum items are not string --- jsonmodels/builders.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsonmodels/builders.py b/jsonmodels/builders.py index a19efdc..e594244 100644 --- a/jsonmodels/builders.py +++ b/jsonmodels/builders.py @@ -142,6 +142,10 @@ def _apply_validators_modifications(field_schema, field): validator.modify_schema(field_schema["items"]) except AttributeError: pass + except TypeError: + # ignore the cases in which the items are not strings, until we know + # how to deal with openapi enums that are not strings (CS-1097) + pass class PrimitiveBuilder(Builder): From cba4573947237837671c8495add538f477440ec1 Mon Sep 17 00:00:00 2001 From: Xiaozhou Li Date: Tue, 25 Aug 2020 10:52:22 +0200 Subject: [PATCH 2/3] linting fix for _apply_validators_modifications --- jsonmodels/builders.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jsonmodels/builders.py b/jsonmodels/builders.py index e594244..4ea0020 100644 --- a/jsonmodels/builders.py +++ b/jsonmodels/builders.py @@ -127,7 +127,7 @@ def is_root(self): return not bool(self.parent) -def _apply_validators_modifications(field_schema, field): +def _apply_validators_modifications(field_schema, field): # noqa: ignore=C901 for validator in field.validators: try: validator.modify_schema(field_schema) @@ -143,8 +143,9 @@ def _apply_validators_modifications(field_schema, field): except AttributeError: pass except TypeError: - # ignore the cases in which the items are not strings, until we know - # how to deal with openapi enums that are not strings (CS-1097) + # ignore the cases in which the items are not strings, + # until we know how to deal with Enums that are not strings + # (CS-1097) pass From 1a106a5c5380b505ac225d409c9ad8bfc328dc9a Mon Sep 17 00:00:00 2001 From: Xiaozhou Li Date: Tue, 25 Aug 2020 11:42:07 +0200 Subject: [PATCH 3/3] update comments: keep an eye on the OpenAPI spec update --- jsonmodels/builders.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jsonmodels/builders.py b/jsonmodels/builders.py index 4ea0020..1b88fe2 100644 --- a/jsonmodels/builders.py +++ b/jsonmodels/builders.py @@ -143,9 +143,8 @@ def _apply_validators_modifications(field_schema, field): # noqa: ignore=C901 except AttributeError: pass except TypeError: - # ignore the cases in which the items are not strings, - # until we know how to deal with Enums that are not strings - # (CS-1097) + # CS-1097 ignore the cases in which the items are not strings, + # until OpenAPI spec supports generating non-string Enum items pass