File tree Expand file tree Collapse file tree 3 files changed +75
-2
lines changed
modules/openapi-generator/src
main/resources/Java/libraries/microprofile
java/org/openapitools/codegen/java/microprofile Expand file tree Collapse file tree 3 files changed +75
-2
lines changed Original file line number Diff line number Diff line change @@ -52,10 +52,10 @@ public class {{classname}} {{#parent}}extends {{{.}}}{{/parent}}{{#vendorExtensi
5252{ {{.} }}
5353{ {/vendorExtensions.x-field-extra-annotation} }
5454{ {#isContainer} }
55- private { {{datatypeWithEnum} }} { {name} }{ {#required} } = { {{defaultValue} }}{ {/required} }{ {^required} } = null{ {/required} };
55+ protected { {{datatypeWithEnum} }} { {name} }{ {#required} } = { {{defaultValue} }}{ {/required} }{ {^required} } = null{ {/required} };
5656{ {/isContainer} }
5757{ {^isContainer} }
58- private { {{datatypeWithEnum} }} { {name} }{ {#defaultValue} } = { {{.} }}{ {/defaultValue} };
58+ protected { {{datatypeWithEnum} }} { {name} }{ {#defaultValue} } = { {{.} }}{ {/defaultValue} };
5959{ {/isContainer} }
6060 { {/vars} }
6161{ {> additional_properties} }
Original file line number Diff line number Diff line change @@ -235,5 +235,31 @@ public void testGeneratedApiExceptionMapperDoesNotHaveProviderAnnotationWhenDisa
235235 .assertTypeAnnotations ()
236236 .doesNotContainWithName ("Provider" );
237237 }
238+
239+ @ Test
240+ public void testClientCanAccessFieldInParent () throws Exception {
241+ File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
242+ output .deleteOnExit ();
243+
244+ OpenAPI openAPI = new OpenAPIParser ()
245+ .readLocation ("src/test/resources/bugs/issue_23034.yaml" , null , new ParseOptions ()).getOpenAPI ();
246+
247+ codegen .setOutputDir (output .getAbsolutePath ());
248+ codegen .additionalProperties ().put (JavaClientCodegen .MICROPROFILE_GLOBAL_EXCEPTION_MAPPER , "false" );
249+
250+ ClientOptInput input = new ClientOptInput ()
251+ .openAPI (openAPI )
252+ .config (codegen );
253+
254+ List <File > files = new DefaultGenerator ().opts (input ).generate ();
255+
256+ Map <String , File > filesMap = files .stream ()
257+ .collect (Collectors .toMap (File ::getName , Function .identity ()));
258+
259+ validateJavaSourceFiles (files );
260+
261+ JavaFileAssert .assertThat (filesMap .get ("Parent.java" ))
262+ .fileContains ("protected String parentField;" );
263+ }
238264}
239265
Original file line number Diff line number Diff line change 1+ ---
2+ openapi : 3.0.4
3+ info :
4+ title : Reproduce
5+ version : ' v1'
6+ components :
7+ schemas :
8+ Child :
9+ required :
10+ - childField1
11+ type : object
12+ allOf :
13+ - $ref : " #/components/schemas/Parent"
14+ properties :
15+ childField1 :
16+ type : string
17+
18+ Parent :
19+ required :
20+ - classType
21+ - parentField
22+ type : object
23+ properties :
24+ parentField :
25+ type : string
26+ readOnly : true
27+ classType :
28+ description : Identifier of discriminator mapping class.
29+ enum :
30+ - Child
31+ type : string
32+ discriminator :
33+ propertyName : classType
34+ mapping :
35+ Child : " #/components/schemas/Child"
36+ paths :
37+ ' /v1/reproduce ' :
38+ get :
39+ responses :
40+ ' 200 ' :
41+ content :
42+ application/json :
43+ schema :
44+ type : array
45+ items :
46+ $ref : ' #/components/schemas/Child'
47+ description : ' reproduce'
You can’t perform that action at this time.
0 commit comments