From 25c55393eb2bd4adcc4a5aa88365ec2c39389672 Mon Sep 17 00:00:00 2001 From: HaruhiSuzumiyah <68439343+HaruhiSuzumiyah@users.noreply.github.com> Date: Wed, 24 May 2023 10:31:07 -0400 Subject: [PATCH 1/2] Change JsonIgnoreProperties Rather than ignoring all properties with @JsonIgnoreProperties, we only ignore if it doesn't have the "allowGetters" = true Since if it allowsGetters, you are going to receive it as part of the response --- .../io/swagger/v3/core/jackson/ModelResolver.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java index bb2905d941..93f9b90e5d 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java @@ -2146,20 +2146,23 @@ protected Set resolveIgnoredProperties(Annotations a, Annotation[] annot Set propertiesToIgnore = new HashSet<>(); JsonIgnoreProperties ignoreProperties = a.get(JsonIgnoreProperties.class); if (ignoreProperties != null) { - propertiesToIgnore.addAll(Arrays.asList(ignoreProperties.value())); + if(!ignoreProperties.allowGetters()) { + propertiesToIgnore.addAll(Arrays.asList(ignoreProperties.value())); + } } - propertiesToIgnore.addAll(resolveIgnoredProperties(annotations)); return propertiesToIgnore; } - + protected Set resolveIgnoredProperties(Annotation[] annotations) { Set propertiesToIgnore = new HashSet<>(); if (annotations != null) { for (Annotation annotation : annotations) { if (annotation instanceof JsonIgnoreProperties) { - propertiesToIgnore.addAll(Arrays.asList(((JsonIgnoreProperties) annotation).value())); - break; + if (!((JsonIgnoreProperties) annotation).allowGetters()) { + propertiesToIgnore.addAll(Arrays.asList(((JsonIgnoreProperties) annotation).value())); + break; + } } } } From 222613f862d9a15ccf08c3491ada736743ce8672 Mon Sep 17 00:00:00 2001 From: HaruhiSuzumiyah <68439343+HaruhiSuzumiyah@users.noreply.github.com> Date: Thu, 1 Jun 2023 13:26:13 -0400 Subject: [PATCH 2/2] Update ModelResolver.java --- .../src/main/java/io/swagger/v3/core/jackson/ModelResolver.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java index 93f9b90e5d..649080308c 100644 --- a/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java +++ b/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java @@ -2150,6 +2150,7 @@ protected Set resolveIgnoredProperties(Annotations a, Annotation[] annot propertiesToIgnore.addAll(Arrays.asList(ignoreProperties.value())); } } + propertiesToIgnore.addAll(resolveIgnoredProperties(annotations)); return propertiesToIgnore; }