@@ -190,43 +190,48 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
190190 allModels .put (modelName , cm );
191191 }
192192 }
193- // Fix up all parent and interface CodegenModel references.
194- for (CodegenModel cm : allModels .values ()) {
195- if (cm .parent != null ) {
196- cm .parentModel = allModels .get (cm .parent );
197- }
198- if (cm .interfaces != null && !cm .interfaces .isEmpty ()) {
199- cm .interfaceModels = new ArrayList <CodegenModel >(cm .interfaces .size ());
200- for (String intf : cm .interfaces ) {
201- CodegenModel intfModel = allModels .get (intf );
202- if (intfModel != null ) {
203- cm .interfaceModels .add (intfModel );
204- }
205- }
206- }
207- }
208- // Let parent know about all its children
193+
209194 for (String name : allModels .keySet ()) {
210- CodegenModel cm = allModels .get (name );
211- CodegenModel parent = allModels .get (cm .parent );
212- // if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
213- // TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
214- while (parent != null ) {
215- if (parent .children == null ) {
216- parent .children = new ArrayList <CodegenModel >();
217- }
218- parent .children .add (cm );
219- if (parent .discriminator == null ) {
220- parent = allModels .get (parent .parent );
221- } else {
222- parent = null ;
223- }
224- }
195+ CodegenModel codegenModel = allModels .get (name );
196+ fixUpParentAndInterfaces (codegenModel , allModels );
225197 }
226198 }
227199 return objs ;
228200 }
229201
202+ /**
203+ * Fix up all parent and interface CodegenModel references.
204+ * @param allModels
205+ */
206+ protected void fixUpParentAndInterfaces (CodegenModel codegenModel , Map <String , CodegenModel > allModels ) {
207+ if (codegenModel .parent != null ) {
208+ codegenModel .parentModel = allModels .get (codegenModel .parent );
209+ }
210+ if (codegenModel .interfaces != null && !codegenModel .interfaces .isEmpty ()) {
211+ codegenModel .interfaceModels = new ArrayList <CodegenModel >(codegenModel .interfaces .size ());
212+ for (String intf : codegenModel .interfaces ) {
213+ CodegenModel intfModel = allModels .get (intf );
214+ if (intfModel != null ) {
215+ codegenModel .interfaceModels .add (intfModel );
216+ }
217+ }
218+ }
219+ CodegenModel parent = codegenModel .parentModel ;
220+ // if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
221+ // TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
222+ while (parent != null ) {
223+ if (parent .children == null ) {
224+ parent .children = new ArrayList <CodegenModel >();
225+ }
226+ parent .children .add (codegenModel );
227+ if (parent .discriminator == null ) {
228+ parent = allModels .get (parent .parent );
229+ } else {
230+ parent = null ;
231+ }
232+ }
233+ }
234+
230235 // override with any special post-processing
231236 @ SuppressWarnings ("static-method" )
232237 public Map <String , Object > postProcessModels (Map <String , Object > objs ) {
@@ -3445,6 +3450,11 @@ public String apiFilename(String templateName, String tag) {
34453450 return apiFileFolder () + File .separator + toApiFilename (tag ) + suffix ;
34463451 }
34473452
3453+ public String modelFilename (String templateName , String modelName ) {
3454+ String suffix = modelTemplateFiles ().get (templateName );
3455+ return modelFileFolder () + File .separator + toModelFilename (modelName ) + suffix ;
3456+ }
3457+
34483458 /**
34493459 * Return the full path and API documentation file
34503460 *
0 commit comments