Skip to content

Commit 102f57f

Browse files
committed
Upgrade swagger-core to version 2.2.36
Upgrade swagger-ui to version 5.27.1
1 parent a297959 commit 102f57f

File tree

5 files changed

+27
-59
lines changed

5 files changed

+27
-59
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
<central-publishing-maven-plugin.version>0.7.0
5656
</central-publishing-maven-plugin.version>
5757
<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
58-
<swagger-api.version>2.2.34</swagger-api.version>
59-
<swagger-ui.version>5.27.0</swagger-ui.version>
58+
<swagger-api.version>2.2.36</swagger-api.version>
59+
<swagger-ui.version>5.27.1</swagger-ui.version>
6060
<gmavenplus-plugin.version>1.13.1</gmavenplus-plugin.version>
6161
<jjwt.version>0.9.1</jjwt.version>
6262
<therapi-runtime-javadoc.version>0.15.0</therapi-runtime-javadoc.version>

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/ModelConverterRegistrar.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232
import io.swagger.v3.core.converter.ModelConverter;
3333
import io.swagger.v3.core.converter.ModelConverters;
34-
import io.swagger.v3.core.jackson.ModelResolver;
35-
import io.swagger.v3.core.util.Json31;
3634
import org.apache.commons.lang3.reflect.FieldUtils;
3735
import org.slf4j.Logger;
3836
import org.slf4j.LoggerFactory;
@@ -55,12 +53,6 @@ public class ModelConverterRegistrar {
5553
*/
5654
private final ModelConverters modelConvertersInstance;
5755

58-
59-
/**
60-
* The singleton fallback instance.
61-
*/
62-
private static volatile ModelConverters modelConvertersFallbackInstance;
63-
6456
/**
6557
* Instantiates a new Model converter registrar.
6658
*
@@ -74,30 +66,8 @@ public ModelConverterRegistrar(List<ModelConverter> modelConverters, SpringDocCo
7466
registeredConverterOptional.ifPresent(modelConvertersInstance::removeConverter);
7567
modelConvertersInstance.addConverter(modelConverter);
7668
}
77-
if (springDocConfigProperties.isOpenapi31()) {
78-
initializeFallbackInstance();
79-
}
8069
}
8170

82-
/**
83-
* Initialize fallback instance.
84-
*/
85-
private static synchronized void initializeFallbackInstance() {
86-
if (modelConvertersFallbackInstance == null) {
87-
modelConvertersFallbackInstance = new ModelConverters(true);
88-
modelConvertersFallbackInstance.addConverter(new ModelResolver(Json31.mapper()));
89-
}
90-
}
91-
92-
/**
93-
* Gets model converters fallback instance.
94-
*
95-
* @return the model converters fallback instance
96-
*/
97-
public static ModelConverters getModelConvertersFallbackInstance() {
98-
return modelConvertersFallbackInstance;
99-
}
100-
10171
/**
10272
* Gets registered converter same as.
10373
*

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocAnnotationsUtils.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import org.apache.commons.lang3.StringUtils;
6666
import org.slf4j.Logger;
6767
import org.slf4j.LoggerFactory;
68-
import org.springdoc.core.converters.ModelConverterRegistrar;
6968

7069
import org.springframework.core.MethodParameter;
7170
import org.springframework.core.annotation.AnnotationUtils;
@@ -140,31 +139,7 @@ public static Schema extractSchema(Components components, Type returnType, JsonV
140139
new AnnotatedType(returnType)
141140
.resolveAsRef(true).jsonViewAnnotation(jsonView).ctxAnnotations(annotations));
142141
}
143-
// Handle ClassCastException - related to https://github.com/swagger-api/swagger-core/issues/4904
144-
catch (ClassCastException e) {
145-
if (openapi31) {
146-
try {
147-
resolvedSchema = ModelConverterRegistrar.getModelConvertersFallbackInstance()
148-
.resolveAsResolvedSchema(
149-
new AnnotatedType(returnType)
150-
.resolveAsRef(true)
151-
.jsonViewAnnotation(jsonView)
152-
.ctxAnnotations(annotations));
153-
} catch (Exception fallbackEx) {
154-
LOGGER.warn(Constants.GRACEFUL_EXCEPTION_OCCURRED, fallbackEx);
155-
return null;
156-
}
157-
} else {
158-
LOGGER.warn(Constants.GRACEFUL_EXCEPTION_OCCURRED, e);
159-
return null;
160-
}
161-
}
162142
catch (Exception e) {
163-
if(e instanceof ClassCastException && openapi31) {
164-
resolvedSchema = ModelConverterRegistrar.getModelConvertersFallbackInstance()
165-
.resolveAsResolvedSchema(new AnnotatedType(returnType)
166-
.resolveAsRef(true).jsonViewAnnotation(jsonView).ctxAnnotations(annotations));
167-
}
168143
LOGGER.warn(Constants.GRACEFUL_EXCEPTION_OCCURRED, e);
169144
return null;
170145
}

springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app26.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,33 @@
4545
"components": {
4646
"schemas": {
4747
"Bar": {
48+
"type": "object",
4849
"properties": {
4950
"bar": {
5051
"type": "string"
5152
}
5253
}
5354
},
5455
"Foo": {
56+
"type": "object",
5557
"properties": {
5658
"foo": {
5759
"type": "string"
5860
}
5961
}
6062
},
6163
"MyModel": {
64+
"type": "object",
6265
"properties": {
6366
"thing": {
6467
"description": "Hello",
6568
"oneOf": [
69+
{
70+
"$ref": "#/components/schemas/Foo"
71+
},
72+
{
73+
"$ref": "#/components/schemas/Bar"
74+
},
6675
{
6776
"$ref": "#/components/schemas/Foo"
6877
},

springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app26.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,38 @@
5454
"components": {
5555
"schemas": {
5656
"Bar": {
57+
"type": "object",
58+
"description": "The type Bar.",
5759
"properties": {
5860
"bar": {
59-
"type": "string"
61+
"type": "string",
62+
"description": "The Bar."
6063
}
6164
}
6265
},
6366
"Foo": {
67+
"type": "object",
68+
"description": "The type Foo.",
6469
"properties": {
6570
"foo": {
66-
"type": "string"
71+
"type": "string",
72+
"description": "The Foo."
6773
}
6874
}
6975
},
7076
"MyModel": {
77+
"type": "object",
78+
"description": "The type My model.",
7179
"properties": {
7280
"thing": {
7381
"description": "Hello",
7482
"oneOf": [
83+
{
84+
"$ref": "#/components/schemas/Foo"
85+
},
86+
{
87+
"$ref": "#/components/schemas/Bar"
88+
},
7589
{
7690
"$ref": "#/components/schemas/Foo"
7791
},

0 commit comments

Comments
 (0)