File tree 9 files changed +118
-1
lines changed
modules/openapi-generator/src
main/resources/Java/libraries/native
test/java/org/openapitools/codegen/java
echo_api/java/native/src/main/java/org/openapitools/client/model
native/src/main/java/org/openapitools/client/model
native-async/src/main/java/org/openapitools/client/model
9 files changed +118
-1
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,23 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
267
267
268
268
{{/vars}}
269
269
{{>libraries/native/additional_properties}}
270
+ {{#parent}}
271
+ {{#allVars}}
272
+ {{#isOverridden}}
273
+ @Override
274
+ public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
275
+ {{#vendorExtensions.x-is-jackson-optional-nullable}}
276
+ this.{{setter}}(JsonNullable.<{{{datatypeWithEnum}}}>of({{name}}));
277
+ {{/vendorExtensions.x-is-jackson-optional-nullable}}
278
+ {{^vendorExtensions.x-is-jackson-optional-nullable}}
279
+ this.{{setter}}({{name}});
280
+ {{/vendorExtensions.x-is-jackson-optional-nullable}}
281
+ return this;
282
+ }
283
+
284
+ {{/isOverridden}}
285
+ {{/allVars}}
286
+ {{/parent}}
270
287
/**
271
288
* Return true if this {{name}} object is equal to o.
272
289
*/
Original file line number Diff line number Diff line change @@ -1954,4 +1954,32 @@ public void testForJavaApacheHttpClientOverrideSetter() throws IOException {
1954
1954
" public Pet petType(String petType) {\n " );
1955
1955
1956
1956
}
1957
- }
1957
+
1958
+ @ Test
1959
+ public void testForJavaNativeClientOverrideSetter () throws IOException {
1960
+ File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
1961
+ output .deleteOnExit ();
1962
+ String outputPath = output .getAbsolutePath ().replace ('\\' , '/' );
1963
+ OpenAPI openAPI = new OpenAPIParser ()
1964
+ .readLocation ("src/test/resources/3_0/allOf_composition_discriminator.yaml" , null , new ParseOptions ()).getOpenAPI ();
1965
+
1966
+ JavaClientCodegen codegen = new JavaClientCodegen ();
1967
+ codegen .setOutputDir (output .getAbsolutePath ());
1968
+
1969
+ ClientOptInput input = new ClientOptInput ();
1970
+ input .openAPI (openAPI );
1971
+ input .config (codegen );
1972
+
1973
+ DefaultGenerator generator = new DefaultGenerator ();
1974
+ codegen .setLibrary (JavaClientCodegen .NATIVE );
1975
+
1976
+ generator .opts (input ).generate ();
1977
+
1978
+ assertFileContains (Paths .get (outputPath + "/src/main/java/org/openapitools/client/model/Cat.java" ), " @Override\n " +
1979
+ " public Cat petType(String petType) {" );
1980
+ assertFileContains (Paths .get (outputPath + "/src/main/java/org/openapitools/client/model/Pet.java" ), " }\n " +
1981
+ "\n " +
1982
+ " public Pet petType(String petType) {\n " );
1983
+
1984
+ }
1985
+ }
Original file line number Diff line number Diff line change @@ -129,6 +129,18 @@ public void setDate(OffsetDateTime date) {
129
129
}
130
130
131
131
132
+ @ Override
133
+ public DataQuery id (Long id ) {
134
+ this .setId (id );
135
+ return this ;
136
+ }
137
+
138
+ @ Override
139
+ public DataQuery outcomes (List <OutcomesEnum > outcomes ) {
140
+ this .setOutcomes (outcomes );
141
+ return this ;
142
+ }
143
+
132
144
/**
133
145
* Return true if this DataQuery object is equal to o.
134
146
*/
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ public void setDeclawed(Boolean declawed) {
78
78
}
79
79
80
80
81
+ @ Override
82
+ public Cat className (String className ) {
83
+ this .setClassName (className );
84
+ return this ;
85
+ }
86
+
87
+ @ Override
88
+ public Cat color (String color ) {
89
+ this .setColor (color );
90
+ return this ;
91
+ }
92
+
81
93
/**
82
94
* Return true if this Cat object is equal to o.
83
95
*/
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ public void setBreed(String breed) {
78
78
}
79
79
80
80
81
+ @ Override
82
+ public Dog className (String className ) {
83
+ this .setClassName (className );
84
+ return this ;
85
+ }
86
+
87
+ @ Override
88
+ public Dog color (String color ) {
89
+ this .setColor (color );
90
+ return this ;
91
+ }
92
+
81
93
/**
82
94
* Return true if this Dog object is equal to o.
83
95
*/
Original file line number Diff line number Diff line change @@ -52,6 +52,12 @@ public class ParentPet extends GrandparentAnimal {
52
52
public ParentPet () {
53
53
}
54
54
55
+ @ Override
56
+ public ParentPet petType (String petType ) {
57
+ this .setPetType (petType );
58
+ return this ;
59
+ }
60
+
55
61
/**
56
62
* Return true if this ParentPet object is equal to o.
57
63
*/
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ public void setDeclawed(Boolean declawed) {
78
78
}
79
79
80
80
81
+ @ Override
82
+ public Cat className (String className ) {
83
+ this .setClassName (className );
84
+ return this ;
85
+ }
86
+
87
+ @ Override
88
+ public Cat color (String color ) {
89
+ this .setColor (color );
90
+ return this ;
91
+ }
92
+
81
93
/**
82
94
* Return true if this Cat object is equal to o.
83
95
*/
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ public void setBreed(String breed) {
78
78
}
79
79
80
80
81
+ @ Override
82
+ public Dog className (String className ) {
83
+ this .setClassName (className );
84
+ return this ;
85
+ }
86
+
87
+ @ Override
88
+ public Dog color (String color ) {
89
+ this .setColor (color );
90
+ return this ;
91
+ }
92
+
81
93
/**
82
94
* Return true if this Dog object is equal to o.
83
95
*/
Original file line number Diff line number Diff line change @@ -52,6 +52,12 @@ public class ParentPet extends GrandparentAnimal {
52
52
public ParentPet () {
53
53
}
54
54
55
+ @ Override
56
+ public ParentPet petType (String petType ) {
57
+ this .setPetType (petType );
58
+ return this ;
59
+ }
60
+
55
61
/**
56
62
* Return true if this ParentPet object is equal to o.
57
63
*/
You can’t perform that action at this time.
0 commit comments