File tree Expand file tree Collapse file tree 7 files changed +171
-1
lines changed
springdoc-openapi-webmvc-core/src/test
java/test/org/springdoc/api/app114 Expand file tree Collapse file tree 7 files changed +171
-1
lines changed Original file line number Diff line number Diff line change 43
43
<groupId >org.apache.commons</groupId >
44
44
<artifactId >commons-lang3</artifactId >
45
45
</dependency >
46
+ <dependency >
47
+ <groupId >javax.money</groupId >
48
+ <artifactId >money-api</artifactId >
49
+ <optional >true</optional >
50
+ </dependency >
46
51
</dependencies >
47
52
</project >
Original file line number Diff line number Diff line change
1
+ package org .springdoc .core ;
2
+
3
+
4
+ import javax .money .MonetaryAmount ;
5
+
6
+ import org .springframework .boot .autoconfigure .condition .ConditionalOnClass ;
7
+ import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
8
+ import org .springframework .context .annotation .Configuration ;
9
+
10
+ import static org .springdoc .core .Constants .SPRINGDOC_ENABLED ;
11
+
12
+ @ ConditionalOnClass (MonetaryAmount .class )
13
+ @ Configuration
14
+ @ ConditionalOnProperty (name = SPRINGDOC_ENABLED , matchIfMissing = true )
15
+ public class SpringDocMonetaryAmountConfiguration {
16
+
17
+ static {
18
+ SpringDocUtils .getConfig ().replaceWithClass (MonetaryAmount .class , org .springdoc .core .converters .MonetaryAmount .class );
19
+ }
20
+
21
+ }
Original file line number Diff line number Diff line change
1
+ package org .springdoc .core .converters ;
2
+
3
+ import java .math .BigDecimal ;
4
+
5
+ import com .fasterxml .jackson .annotation .JsonProperty ;
6
+ import io .swagger .v3 .oas .annotations .media .Schema ;
7
+
8
+ @ Schema
9
+ public class MonetaryAmount {
10
+
11
+ @ JsonProperty ("amount" )
12
+ @ Schema (example = "99.96" )
13
+ private BigDecimal amount ;
14
+
15
+ @ JsonProperty ("currency" )
16
+ @ Schema (example = "USD" )
17
+ private String currency ;
18
+
19
+ }
Original file line number Diff line number Diff line change 1
1
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2
2
org.springdoc.core.SpringDocConfiguration,\
3
- org.springdoc.core.SpringDocConfigProperties
3
+ org.springdoc.core.SpringDocConfigProperties,\
4
+ org.springdoc.core.SpringDocMonetaryAmountConfiguration
Original file line number Diff line number Diff line change
1
+ /*
2
+ *
3
+ * * Copyright 2019-2020 the original author or authors.
4
+ * *
5
+ * * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * * you may not use this file except in compliance with the License.
7
+ * * You may obtain a copy of the License at
8
+ * *
9
+ * * https://www.apache.org/licenses/LICENSE-2.0
10
+ * *
11
+ * * Unless required by applicable law or agreed to in writing, software
12
+ * * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * * See the License for the specific language governing permissions and
15
+ * * limitations under the License.
16
+ *
17
+ */
18
+
19
+ package test .org .springdoc .api .app114 ;
20
+
21
+ import com .fasterxml .jackson .annotation .JsonProperty ;
22
+ import org .springdoc .core .converters .MonetaryAmount ;
23
+
24
+ import org .springframework .http .MediaType ;
25
+ import org .springframework .web .bind .annotation .PostMapping ;
26
+ import org .springframework .web .bind .annotation .RequestBody ;
27
+ import org .springframework .web .bind .annotation .RestController ;
28
+
29
+ @ RestController
30
+ public class HelloController {
31
+
32
+ @ PostMapping (value = "/foos1" , consumes = MediaType .APPLICATION_JSON_VALUE )
33
+ MonetaryAmount getCurrency (@ RequestBody CarDTO carDTO ) {
34
+ return carDTO .price ;
35
+ }
36
+
37
+ class CarDTO {
38
+ @ JsonProperty ("price" )
39
+ MonetaryAmount price ;
40
+ }
41
+
42
+ }
Original file line number Diff line number Diff line change
1
+ package test .org .springdoc .api .app114 ;
2
+
3
+ import test .org .springdoc .api .AbstractSpringDocTest ;
4
+
5
+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
6
+
7
+
8
+ public class SpringDocApp114Test extends AbstractSpringDocTest {
9
+
10
+ @ SpringBootApplication
11
+ static class SpringDocTestApp {}
12
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "openapi" : " 3.0.1" ,
3
+ "info" : {
4
+ "title" : " OpenAPI definition" ,
5
+ "version" : " v0"
6
+ },
7
+ "servers" : [
8
+ {
9
+ "url" : " http://localhost" ,
10
+ "description" : " Generated server url"
11
+ }
12
+ ],
13
+ "paths" : {
14
+ "/foos1" : {
15
+ "post" : {
16
+ "tags" : [
17
+ " hello-controller"
18
+ ],
19
+ "operationId" : " getCurrency" ,
20
+ "requestBody" : {
21
+ "content" : {
22
+ "application/json" : {
23
+ "schema" : {
24
+ "$ref" : " #/components/schemas/CarDTO"
25
+ }
26
+ }
27
+ },
28
+ "required" : true
29
+ },
30
+ "responses" : {
31
+ "200" : {
32
+ "description" : " OK" ,
33
+ "content" : {
34
+ "*/*" : {
35
+ "schema" : {
36
+ "$ref" : " #/components/schemas/MonetaryAmount"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ },
45
+ "components" : {
46
+ "schemas" : {
47
+ "CarDTO" : {
48
+ "type" : " object" ,
49
+ "properties" : {
50
+ "price" : {
51
+ "$ref" : " #/components/schemas/MonetaryAmount"
52
+ }
53
+ }
54
+ },
55
+ "MonetaryAmount" : {
56
+ "type" : " object" ,
57
+ "properties" : {
58
+ "amount" : {
59
+ "type" : " number" ,
60
+ "example" : 99.96
61
+ },
62
+ "currency" : {
63
+ "type" : " string" ,
64
+ "example" : " USD"
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
You can’t perform that action at this time.
0 commit comments