From 94e33b9ba4f3ebe602858c7123329aedeacabf1a Mon Sep 17 00:00:00 2001 From: frantuma Date: Wed, 22 May 2024 13:08:29 +0200 Subject: [PATCH] fix #4676 - fix schema serialization with sort=true --- .../integration/GenericOpenApiContext.java | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/modules/swagger-integration/src/main/java/io/swagger/v3/oas/integration/GenericOpenApiContext.java b/modules/swagger-integration/src/main/java/io/swagger/v3/oas/integration/GenericOpenApiContext.java index 2ec0e829f1..ff14aa1c5e 100644 --- a/modules/swagger-integration/src/main/java/io/swagger/v3/oas/integration/GenericOpenApiContext.java +++ b/modules/swagger-integration/src/main/java/io/swagger/v3/oas/integration/GenericOpenApiContext.java @@ -16,6 +16,7 @@ import io.swagger.v3.core.filter.SpecFilter; import io.swagger.v3.core.jackson.ModelResolver; import io.swagger.v3.core.jackson.PathsSerializer; +import io.swagger.v3.core.jackson.mixin.Schema31Mixin; import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.Json31; import io.swagger.v3.core.util.Yaml; @@ -739,7 +740,62 @@ static abstract class SortedSchemaMixin { @JsonIgnore public abstract Object getJsonSchemaImpl(); + @JsonIgnore + public abstract List getPrefixItems(); + + @JsonIgnore + public abstract String getContentEncoding(); + + @JsonIgnore + public abstract String getContentMediaType(); + + @JsonIgnore + public abstract Schema getContentSchema(); + + @JsonIgnore + public abstract Schema getPropertyNames(); + + @JsonIgnore + public abstract Object getUnevaluatedProperties(); + + @JsonIgnore + public abstract Integer getMaxContains(); + + @JsonIgnore + public abstract Integer getMinContains(); + @JsonIgnore + public abstract Schema getAdditionalItems(); + + @JsonIgnore + public abstract Schema getUnevaluatedItems(); + + @JsonIgnore + public abstract Schema getIf(); + + @JsonIgnore + public abstract Schema getElse(); + + @JsonIgnore + public abstract Schema getThen(); + + @JsonIgnore + public abstract Map getDependentSchemas(); + + @JsonIgnore + public abstract Map> getDependentRequired(); + + @JsonIgnore + public abstract String get$comment(); + + @JsonIgnore + public abstract List getExamples(); + + @JsonIgnore + public abstract Object getConst(); + + @JsonIgnore + public abstract Boolean getBooleanSchemaValue(); } @JsonPropertyOrder(value = {"openapi", "info", "externalDocs", "servers", "security", "tags", "paths", "components", "webhooks"}, alphabetic = true) @@ -756,7 +812,7 @@ static abstract class SortedOpenAPIMixin31 { public abstract Paths getPaths(); } - @JsonPropertyOrder(value = {"type", "format"}, alphabetic = true) + @JsonPropertyOrder(value = {"type", "format", "if", "then", "else"}, alphabetic = true) static abstract class SortedSchemaMixin31 { @JsonAnyGetter @@ -785,6 +841,7 @@ static abstract class SortedSchemaMixin31 { public abstract String getType(); @JsonProperty("type") + @JsonSerialize(using = Schema31Mixin.TypeSerializer.class) public abstract Set getTypes(); @JsonAnySetter @@ -799,6 +856,9 @@ static abstract class SortedSchemaMixin31 { @JsonIgnore public abstract Object getJsonSchemaImpl(); + @JsonIgnore + public abstract Boolean getBooleanSchemaValue(); + } }