Skip to content

Commit 2c20bf1

Browse files
committed
Tests update for #1957
1 parent b274a0e commit 2c20bf1

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/SpringDocUtils.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package org.springdoc.core;
2424

2525
import java.lang.annotation.Annotation;
26+
import java.math.BigDecimal;
2627
import java.util.function.Predicate;
2728

2829
import io.swagger.v3.oas.models.media.Schema;
@@ -33,6 +34,7 @@
3334

3435
/**
3536
* The type Spring doc utils.
37+
*
3638
* @author bnasslahsen
3739
*/
3840
public class SpringDocUtils {
@@ -323,5 +325,27 @@ public SpringDocUtils setModelAndViewClass(Class<?> clazz) {
323325
AbstractOpenApiResource.setModelAndViewClass(clazz);
324326
return this;
325327
}
328+
329+
/**
330+
* Remove from schema map spring doc utils.
331+
*
332+
* @param clazzs the clazzs
333+
* @return the spring doc utils
334+
*/
335+
public SpringDocUtils removeFromSchemaMap(Class<?> clazzs) {
336+
AdditionalModelsConverter.removeFromSchemaMap(clazzs);
337+
return this;
338+
}
339+
340+
/**
341+
* Remove from schema class spring doc utils.
342+
*
343+
* @param clazzs the clazzs
344+
* @return the spring doc utils
345+
*/
346+
public SpringDocUtils removeFromSchemaClass(Class<?> clazzs) {
347+
AdditionalModelsConverter.removeFromClassMap(clazzs);
348+
return this;
349+
}
326350
}
327351

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,20 @@
3939

4040
/**
4141
* The type Additional models converter.
42+
*
4243
* @author bnasslahsen
4344
*/
4445
public class AdditionalModelsConverter implements ModelConverter {
4546

4647
/**
4748
* The constant modelToClassMap.
4849
*/
49-
private static final Map<Class, Class> modelToClassMap = new HashMap<>();
50+
private static Map<Class, Class> modelToClassMap = new HashMap<>();
5051

5152
/**
5253
* The constant modelToSchemaMap.
5354
*/
54-
private static final Map<Class, Schema> modelToSchemaMap = new HashMap<>();
55+
private static Map<Class, Schema> modelToSchemaMap = new HashMap<>();
5556

5657
/**
5758
* The constant paramObjectReplacementMap.
@@ -154,4 +155,21 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato
154155
return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null;
155156
}
156157

158+
/**
159+
* Remove from schema map.
160+
*
161+
* @param clazz the clazz
162+
*/
163+
public static void removeFromSchemaMap(Class clazz) {
164+
modelToSchemaMap.remove(clazz);
165+
}
166+
167+
/**
168+
* Remove from class map.
169+
*
170+
* @param clazz the clazz
171+
*/
172+
public static void removeFromClassMap(Class clazz) {
173+
modelToClassMap.remove(clazz);
174+
}
157175
}

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v30/app114/SpringDocApp114Test.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222

2323
package test.org.springdoc.api.v30.app114;
2424

25+
import java.math.BigDecimal;
26+
2527
import javax.money.MonetaryAmount;
2628

2729
import org.springdoc.core.SpringDocUtils;
30+
import org.springdoc.core.converters.AdditionalModelsConverter;
2831
import test.org.springdoc.api.v30.AbstractSpringDocV30Test;
2932

3033
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -33,7 +36,9 @@
3336
public class SpringDocApp114Test extends AbstractSpringDocV30Test {
3437

3538
static {
36-
SpringDocUtils.getConfig().replaceWithClass(MonetaryAmount.class, org.springdoc.core.converters.models.MonetaryAmount.class);
39+
SpringDocUtils.getConfig()
40+
.removeFromSchemaMap(BigDecimal.class)
41+
.replaceWithClass(MonetaryAmount.class, org.springdoc.core.converters.models.MonetaryAmount.class);
3742
}
3843

3944
@SpringBootApplication

0 commit comments

Comments
 (0)