@@ -64,16 +64,39 @@ export function generateFormComponentHtml(resource: Resource, parser: SwaggerPar
6464 const typeName = option . name ; // e.g., 'cat' or 'dog'
6565 const subSchema = option . schema ;
6666
67+ // ====================================================================
68+ // THE FIX: Create a helper function to recursively merge properties from `allOf`.
69+ // This ensures inherited properties (like `name` from `BasePet`) are included.
70+ // ====================================================================
71+ const getAllProperties = ( schema : SwaggerDefinition ) : Record < string , SwaggerDefinition > => {
72+ let allProperties : Record < string , SwaggerDefinition > = { ...schema . properties } ;
73+ if ( schema . allOf ) {
74+ for ( const sub of schema . allOf ) {
75+ const resolvedSub = parser . resolve < SwaggerDefinition > ( sub ) ;
76+ if ( resolvedSub ) {
77+ const subProps = getAllProperties ( resolvedSub ) ; // Recurse
78+ // Merge base properties first, so subtype properties take precedence
79+ allProperties = { ...subProps , ...allProperties } ;
80+ }
81+ }
82+ }
83+ return allProperties ;
84+ } ;
85+
86+
6787 // Create a container that will be controlled by an Angular `@if` block.
6888 // This relies on the `isPetType(type: string)` method existing in the component class.
6989 const ifContainer = _ . create ( 'div' ) ;
7090
7191 // Create the sub-form container with the `formGroupName` directive.
7292 const formGroupContainer = _ . create ( 'div' ) . setAttribute ( 'formGroupName' , typeName ) ;
7393
94+ // Use the helper to get all properties, including inherited ones.
95+ const allSubSchemaProperties = getAllProperties ( subSchema ) ;
96+
7497 // Generate controls for all properties of this specific subtype.
7598 // It is crucial to filter out the discriminator property itself to avoid rendering it twice.
76- Object . entries ( subSchema . properties ! )
99+ Object . entries ( allSubSchemaProperties )
77100 . filter ( ( [ key , schema ] ) => key !== dPropName && ! schema . readOnly )
78101 . forEach ( ( [ key , schema ] ) => {
79102 const control = buildFormControl ( { name : key , schema : schema as SwaggerDefinition } ) ;
@@ -106,9 +129,9 @@ export function generateFormComponentHtml(resource: Resource, parser: SwaggerPar
106129 . setAttribute ( '[disabled]' , 'form.invalid || form.pristine' ) ;
107130
108131 // Dynamically change the save button's text based on whether we are creating or editing.
109- const saveButtonContent = `\n@if (isEditMode()) {
132+ const saveButtonContent = `\n@if (isEditMode()) {
110133 <span>Save Changes</span>
111- } @else {
134+ } @else {
112135 <span>Create ${ resource . modelName } </span>
113136}\n` ;
114137 saveButton . setInnerHtml ( saveButtonContent ) ;
0 commit comments