Skip to content

Commit a8bb5cf

Browse files
committed
move swagger modifications to a dedicated annotation and rename the customizers
1 parent cb40ddf commit a8bb5cf

6 files changed

Lines changed: 24 additions & 15 deletions

File tree

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package it.aboutbits.springboot.toolbox.boot.type;
22

3-
import it.aboutbits.springboot.toolbox.boot.type.swagger.GenericSingleValueWrapperModelConverter;
4-
import it.aboutbits.springboot.toolbox.boot.type.swagger.GenericSingleValueWrapperPropertyCustomizer;
5-
import it.aboutbits.springboot.toolbox.boot.type.swagger.IdentityModelConverter;
6-
import it.aboutbits.springboot.toolbox.boot.type.swagger.IdentityPropertyCustomizer;
73
import org.springframework.context.annotation.Import;
84

95
import java.lang.annotation.ElementType;
@@ -13,13 +9,7 @@
139

1410
@Target({ElementType.TYPE})
1511
@Retention(RetentionPolicy.RUNTIME)
16-
@Import({
17-
GenericSingleValueWrapperModelConverter.class,
18-
GenericSingleValueWrapperPropertyCustomizer.class,
19-
IdentityModelConverter.class,
20-
IdentityPropertyCustomizer.class,
21-
CustomTypeConfigurationRegistrar.class
22-
})
12+
@Import(CustomTypeConfigurationRegistrar.class)
2313
public @interface RegisterCustomTypes {
2414
String[] additionalTypePackages() default "";
2515
}

src/main/java/it/aboutbits/springboot/toolbox/boot/type/swagger/GenericSingleValueWrapperModelConverter.java renamed to src/main/java/it/aboutbits/springboot/toolbox/boot/type/swagger/CustomTypeModelConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import java.util.Iterator;
1414

1515
@Component
16-
public class GenericSingleValueWrapperModelConverter implements ModelConverter {
16+
public class CustomTypeModelConverter implements ModelConverter {
1717

1818
@Override
1919
public Schema<?> resolve(

src/main/java/it/aboutbits/springboot/toolbox/boot/type/swagger/GenericSingleValueWrapperPropertyCustomizer.java renamed to src/main/java/it/aboutbits/springboot/toolbox/boot/type/swagger/CustomTypePropertyCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@Slf4j
1616
@Component
17-
public class GenericSingleValueWrapperPropertyCustomizer implements PropertyCustomizer {
17+
public class CustomTypePropertyCustomizer implements PropertyCustomizer {
1818
@Override
1919
public Schema<?> customize(Schema property, AnnotatedType annotatedType) {
2020
var type = annotatedType.getType();

src/main/java/it/aboutbits/springboot/toolbox/boot/type/swagger/IdentityModelConverter.java renamed to src/main/java/it/aboutbits/springboot/toolbox/boot/type/swagger/EntityIdModelConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.Iterator;
1313

1414
@Component
15-
public class IdentityModelConverter implements ModelConverter {
15+
public class EntityIdModelConverter implements ModelConverter {
1616

1717
@Override
1818
public Schema<?> resolve(

src/main/java/it/aboutbits/springboot/toolbox/boot/type/swagger/IdentityPropertyCustomizer.java renamed to src/main/java/it/aboutbits/springboot/toolbox/boot/type/swagger/EntityIdPropertyCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@Slf4j
1616
@Component
17-
public class IdentityPropertyCustomizer implements PropertyCustomizer {
17+
public class EntityIdPropertyCustomizer implements PropertyCustomizer {
1818
@Override
1919
public Schema<?> customize(Schema property, AnnotatedType annotatedType) {
2020
var type = annotatedType.getType();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package it.aboutbits.springboot.toolbox.boot.type.swagger;
2+
3+
import org.springframework.context.annotation.Import;
4+
5+
import java.lang.annotation.ElementType;
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.RetentionPolicy;
8+
import java.lang.annotation.Target;
9+
10+
@Target({ElementType.TYPE})
11+
@Retention(RetentionPolicy.RUNTIME)
12+
@Import({
13+
CustomTypeModelConverter.class,
14+
CustomTypePropertyCustomizer.class,
15+
EntityIdModelConverter.class,
16+
EntityIdPropertyCustomizer.class
17+
})
18+
public @interface RegisterCustomSwaggerTypes {
19+
}

0 commit comments

Comments
 (0)