File tree Expand file tree Collapse file tree
modules/openapi-generator/src
main/java/org/openapitools/codegen/languages
java/org/openapitools/codegen/java/spring Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2301,7 +2301,7 @@ private boolean shouldBeImplicitHeader(CodegenParameter parameter) {
23012301 @ Override
23022302 public void addImportsToOneOfInterface (List <Map <String , String >> imports ) {
23032303 if (jackson ) {
2304- for (String i : Arrays .asList ("JsonSubTypes" , "JsonTypeInfo" )) {
2304+ for (String i : Arrays .asList ("JsonSubTypes" , "JsonTypeInfo" , "JsonIgnoreProperties" )) {
23052305 Map <String , String > oneImport = new HashMap <>();
23062306 oneImport .put ("import" , importMapping .get (i ));
23072307 if (!imports .contains (oneImport )) {
Original file line number Diff line number Diff line change @@ -5002,4 +5002,14 @@ public void testEnumUnknownDefaultCaseDeserializationNotSet_issue13241() throws
50025002 .assertMethod ("build" )
50035003 .doesNotHaveAnnotation ("Deprecated" );
50045004 }
5005+
5006+ @ Test
5007+ public void shouldAddJsonIgnorePropertiesImportWhenUsingOneOfWithinOneOf_issue18929 () throws IOException {
5008+ final SpringCodegen codegen = new SpringCodegen ();
5009+
5010+ final Map <String , File > files = generateFiles (codegen , "src/test/resources/3_0/spring/issue_18929.yaml" );
5011+
5012+ JavaFileAssert .assertThat (files .get ("RequestTwoSchemaNestedOneOf.java" ))
5013+ .hasImports ("com.fasterxml.jackson.annotation.JsonIgnoreProperties" );
5014+ }
50055015}
Original file line number Diff line number Diff line change 1+ openapi : 3.0.3
2+ info :
3+ title : oneOf within oneOf
4+ version : 7.7.0-SNAPSHOT
5+ paths :
6+ /oneOf-within-oneOf-test :
7+ post :
8+ operationId : ' oneOfWithinOneOfTest'
9+ requestBody :
10+ content :
11+ application/json :
12+ schema :
13+ oneOf :
14+ - $ref : ' #/components/schemas/RequestTwoSchema'
15+ - $ref : ' #/components/schemas/RequestOneSchema'
16+ responses :
17+ ' 201 ' :
18+ description : The request was successful and the resource has been created.
19+ content :
20+ application/json :
21+ schema :
22+ type : string
23+ components :
24+ schemas :
25+ AbstractNestedSchema :
26+ type : object
27+ discriminator :
28+ propertyName : type
29+ mapping :
30+ NESTED_ONE : ' #/components/schemas/NestedOneSchema'
31+ NESTED_TWO : ' #/components/schemas/NestedTwoSchema'
32+ required :
33+ - type
34+ properties :
35+ type :
36+ type : string
37+ NestedOneSchema :
38+ type : object
39+ allOf :
40+ - $ref : ' #/components/schemas/AbstractNestedSchema'
41+ AbstractRequestSchema :
42+ type : object
43+ discriminator :
44+ propertyName : type
45+ mapping :
46+ REQUEST_ONE : ' #/components/schemas/RequestOneSchema'
47+ REQUEST_TWO : ' #/components/schemas/RequestTwoSchema'
48+ required :
49+ - type
50+ properties :
51+ type :
52+ type : string
53+ RequestTwoSchema :
54+ type : object
55+ allOf :
56+ - $ref : ' #/components/schemas/AbstractRequestSchema'
57+ required :
58+ - nested
59+ properties :
60+ nested :
61+ oneOf :
62+ - $ref : ' #/components/schemas/NestedTwoSchema'
63+ - $ref : ' #/components/schemas/NestedOneSchema'
64+ RequestOneSchema :
65+ type : object
66+ allOf :
67+ - $ref : ' #/components/schemas/AbstractRequestSchema'
68+ NestedTwoSchema :
69+ type : object
70+ allOf :
71+ - $ref : ' #/components/schemas/AbstractNestedSchema'
You can’t perform that action at this time.
0 commit comments