File tree Expand file tree Collapse 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-async/src/main/java/org/openapitools/client/model
native/src/main/java/org/openapitools/client/model Expand file tree Collapse file tree 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
267267
268268 {{/vars}}
269269{{>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}}
270287 /**
271288 * Return true if this {{name}} object is equal to o.
272289 */
Original file line number Diff line number Diff line change @@ -1954,4 +1954,32 @@ public void testForJavaApacheHttpClientOverrideSetter() throws IOException {
19541954 " public Pet petType(String petType) {\n " );
19551955
19561956 }
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) {
129129 }
130130
131131
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+
132144 /**
133145 * Return true if this DataQuery object is equal to o.
134146 */
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ public void setDeclawed(Boolean declawed) {
7878 }
7979
8080
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+
8193 /**
8294 * Return true if this Cat object is equal to o.
8395 */
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ public void setBreed(String breed) {
7878 }
7979
8080
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+
8193 /**
8294 * Return true if this Dog object is equal to o.
8395 */
Original file line number Diff line number Diff line change @@ -52,6 +52,12 @@ public class ParentPet extends GrandparentAnimal {
5252 public ParentPet () {
5353 }
5454
55+ @ Override
56+ public ParentPet petType (String petType ) {
57+ this .setPetType (petType );
58+ return this ;
59+ }
60+
5561 /**
5662 * Return true if this ParentPet object is equal to o.
5763 */
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ public void setDeclawed(Boolean declawed) {
7878 }
7979
8080
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+
8193 /**
8294 * Return true if this Cat object is equal to o.
8395 */
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ public void setBreed(String breed) {
7878 }
7979
8080
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+
8193 /**
8294 * Return true if this Dog object is equal to o.
8395 */
Original file line number Diff line number Diff line change @@ -52,6 +52,12 @@ public class ParentPet extends GrandparentAnimal {
5252 public ParentPet () {
5353 }
5454
55+ @ Override
56+ public ParentPet petType (String petType ) {
57+ this .setPetType (petType );
58+ return this ;
59+ }
60+
5561 /**
5662 * Return true if this ParentPet object is equal to o.
5763 */
You can’t perform that action at this time.
0 commit comments