Skip to content

Commit 499d73b

Browse files
committed
code review
1 parent d40ace4 commit 499d73b

File tree

5 files changed

+44
-38
lines changed

5 files changed

+44
-38
lines changed

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
@Lazy(false)
106106
@Configuration(proxyBeanMethods = false)
107107
@ConditionalOnProperty(name = SPRINGDOC_ENABLED, matchIfMissing = true)
108+
@ConditionalOnWebApplication
108109
public class SpringDocConfiguration {
109110

110111
/**
@@ -243,7 +244,6 @@ ModelConverterRegistrar modelConverterRegistrar(Optional<List<ModelConverter>> m
243244
* @return the operation service
244245
*/
245246
@Bean
246-
@ConditionalOnWebApplication
247247
@ConditionalOnMissingBean
248248
OperationService operationBuilder(GenericParameterService parameterBuilder, RequestBodyService requestBodyService,
249249
SecurityService securityParser, PropertyResolverUtils propertyResolverUtils, Optional<JavadocProvider> javadocProvider) {
@@ -271,7 +271,6 @@ PropertyResolverUtils propertyResolverUtils(ConfigurableBeanFactory factory, Mes
271271
* @return the request body builder
272272
*/
273273
@Bean
274-
@ConditionalOnWebApplication
275274
@ConditionalOnMissingBean
276275
RequestBodyService requestBodyBuilder(GenericParameterService parameterBuilder) {
277276
return new RequestBodyService(parameterBuilder);
@@ -509,7 +508,6 @@ static class SpringDocFunctionCatalogConfiguration {
509508
*/
510509
@Bean
511510
@ConditionalOnMissingBean
512-
@ConditionalOnWebApplication
513511
@Lazy(false)
514512
CloudFunctionProvider springCloudFunctionProvider(Optional<FunctionCatalog> functionCatalog, GenericResponseService genericResponseService, SpringDocConfigProperties springDocConfigProperties, ApplicationContext applicationContext) {
515513
return new SpringCloudFunctionProvider(functionCatalog, genericResponseService, springDocConfigProperties, applicationContext);

springdoc-openapi-webflux-core/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ public Function<String, String> reverseString() {
4949

5050
@Bean
5151
public Function<String, String> uppercase() {
52-
return value -> value.toUpperCase();
52+
return String::toUpperCase;
5353
}
5454

5555
@Bean
5656
public Function<Flux<String>, Flux<String>> lowercase() {
57-
return flux -> flux.map(value -> value.toLowerCase());
57+
return flux -> flux.map(String::toLowerCase);
5858
}
5959

6060
@Bean(name = "titi")
6161
public Supplier<PersonDTO> hello() {
62-
return () -> new PersonDTO();
62+
return PersonDTO::new;
6363
}
6464

6565
@Bean

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818

1919
package test.org.springdoc.api.app174;
2020

21+
import java.util.Arrays;
22+
import java.util.List;
2123
import java.util.function.Consumer;
2224
import java.util.function.Function;
2325
import java.util.function.Supplier;
26+
import java.util.stream.Collectors;
2427

2528
import io.swagger.v3.oas.annotations.Operation;
2629
import io.swagger.v3.oas.annotations.media.ArraySchema;
@@ -29,8 +32,8 @@
2932
import io.swagger.v3.oas.annotations.responses.ApiResponse;
3033
import org.springdoc.core.annotations.RouterOperation;
3134
import org.springdoc.core.annotations.RouterOperations;
32-
import reactor.core.publisher.Flux;
3335
import test.org.springdoc.api.AbstractSpringDocTest;
36+
import test.org.springdoc.api.app175.PersonDTO;
3437

3538
import org.springframework.boot.autoconfigure.SpringBootApplication;
3639
import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration;
@@ -52,7 +55,7 @@ public Function<String, String> reverseString() {
5255

5356
@Bean
5457
public Function<String, String> uppercase() {
55-
return value -> value.toUpperCase();
58+
return String::toUpperCase;
5659
}
5760

5861
@Bean
@@ -62,25 +65,25 @@ public Function<String, String> uppercase() {
6265
@RouterOperation(method = RequestMethod.POST, operation = @Operation(description = "Say hello POST", operationId = "lowercasePOST", tags = "positions",
6366
responses = @ApiResponse(responseCode = "200", description = "new desc", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class))))))
6467
})
65-
public Function<Flux<String>, Flux<String>> lowercase() {
66-
return flux -> flux.map(value -> value.toLowerCase());
68+
public Function<List<String>, List<String>> lowercase() {
69+
return list -> list.stream().map(String::toLowerCase).collect(Collectors.toList());
6770
}
6871

6972
@Bean(name = "titi")
7073
@RouterOperation(operation = @Operation(description = "Say hello By Id", operationId = "hellome", tags = "persons",
71-
responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PersonDTO.class)))))
72-
public Supplier<PersonDTO> helloSupplier() {
73-
return () -> new PersonDTO();
74+
responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = test.org.springdoc.api.app175.PersonDTO.class)))))
75+
public Supplier<test.org.springdoc.api.app175.PersonDTO> helloSupplier() {
76+
return test.org.springdoc.api.app175.PersonDTO::new;
7477
}
7578

7679
@Bean
77-
public Consumer<PersonDTO> helloConsumer() {
78-
return personDTO -> personDTO.getFirstName();
80+
public Consumer<test.org.springdoc.api.app175.PersonDTO> helloConsumer() {
81+
return PersonDTO::getFirstName;
7982
}
8083

8184
@Bean
82-
public Supplier<Flux<String>> words() {
83-
return () -> Flux.fromArray(new String[] { "foo", "bar" });
85+
public Supplier<List<String>> words() {
86+
return () -> Arrays.asList("foo", "bar");
8487
}
8588

8689
}

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app175/SpringDocApp175Test.java

+10-8
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818

1919
package test.org.springdoc.api.app175;
2020

21+
import java.util.Arrays;
22+
import java.util.List;
2123
import java.util.function.Consumer;
2224
import java.util.function.Function;
2325
import java.util.function.Supplier;
26+
import java.util.stream.Collectors;
2427

2528
import io.swagger.v3.oas.annotations.Operation;
2629
import io.swagger.v3.oas.annotations.media.ArraySchema;
@@ -29,7 +32,6 @@
2932
import io.swagger.v3.oas.annotations.responses.ApiResponse;
3033
import org.springdoc.core.annotations.RouterOperation;
3134
import org.springdoc.core.annotations.RouterOperations;
32-
import reactor.core.publisher.Flux;
3335
import test.org.springdoc.api.AbstractSpringDocTest;
3436

3537
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -54,7 +56,7 @@ public Function<String, String> reverseString() {
5456

5557
@Bean
5658
public Function<String, String> uppercase() {
57-
return value -> value.toUpperCase();
59+
return String::toUpperCase;
5860
}
5961

6062
@Bean
@@ -64,25 +66,25 @@ public Function<String, String> uppercase() {
6466
@RouterOperation(method = RequestMethod.POST, operation = @Operation(description = "Say hello POST", operationId = "lowercasePOST", tags = "positions",
6567
responses = @ApiResponse(responseCode = "200", description = "new desc", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class))))))
6668
})
67-
public Function<Flux<String>, Flux<String>> lowercase() {
68-
return flux -> flux.map(value -> value.toLowerCase());
69+
public Function<List<String>, List<String>> lowercase() {
70+
return list -> list.stream().map(String::toLowerCase).collect(Collectors.toList());
6971
}
7072

7173
@Bean(name = "titi")
7274
@RouterOperation(operation = @Operation(description = "Say hello By Id", operationId = "hellome", tags = "persons",
7375
responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PersonDTO.class)))))
7476
public Supplier<PersonDTO> helloSupplier() {
75-
return () -> new PersonDTO();
77+
return PersonDTO::new;
7678
}
7779

7880
@Bean
7981
public Consumer<PersonDTO> helloConsumer() {
80-
return personDTO -> personDTO.getFirstName();
82+
return PersonDTO::getFirstName;
8183
}
8284

8385
@Bean
84-
public Supplier<Flux<String>> words() {
85-
return () -> Flux.fromArray(new String[] { "foo", "bar" });
86+
public Supplier<List<String>> words() {
87+
return () -> Arrays.asList("foo", "bar");
8688
}
8789

8890
}

springdoc-openapi-webmvc-core/src/test/resources/results/app174.json

+16-13
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@
4848
"content": {
4949
"application/json": {
5050
"schema": {
51-
"$ref": "#/components/schemas/FluxString"
51+
"type": "array",
52+
"items": {
53+
"type": "string"
54+
}
5255
}
5356
},
5457
"text/plain": {
5558
"schema": {
56-
"$ref": "#/components/schemas/FluxString"
59+
"type": "array",
60+
"items": {
61+
"type": "string"
62+
}
5763
}
5864
}
5965
}
@@ -96,7 +102,10 @@
96102
"in": "path",
97103
"required": true,
98104
"schema": {
99-
"$ref": "#/components/schemas/FluxString"
105+
"type": "array",
106+
"items": {
107+
"type": "string"
108+
}
100109
}
101110
}
102111
],
@@ -301,7 +310,10 @@
301310
"content": {
302311
"*/*": {
303312
"schema": {
304-
"$ref": "#/components/schemas/FluxString"
313+
"type": "array",
314+
"items": {
315+
"type": "string"
316+
}
305317
}
306318
}
307319
}
@@ -312,15 +324,6 @@
312324
},
313325
"components": {
314326
"schemas": {
315-
"FluxString": {
316-
"type": "object",
317-
"properties": {
318-
"prefetch": {
319-
"type": "integer",
320-
"format": "int32"
321-
}
322-
}
323-
},
324327
"PersonDTO": {
325328
"type": "object",
326329
"properties": {

0 commit comments

Comments
 (0)