77 getMetaDescription ,
88 isFieldOmitted ,
99 isFilterKindIncluded ,
10+ isModelIncluded ,
1011 isOperationIncluded ,
1112 isProcedureIncluded ,
1213} from '../common/spec-utils' ;
@@ -60,7 +61,7 @@ export class RestApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {
6061 paths : this . generatePaths ( ) ,
6162 components : {
6263 schemas : this . generateSchemas ( ) ,
63- parameters : this . generateSharedParams ( ) as any ,
64+ parameters : this . generateSharedParams ( ) ,
6465 } ,
6566 } as OpenAPIV3_1 . Document ;
6667 }
@@ -103,6 +104,7 @@ export class RestApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {
103104 // Relation paths
104105 for ( const [ fieldName , fieldDef ] of Object . entries ( modelDef . fields ) ) {
105106 if ( ! fieldDef . relation ) continue ;
107+ if ( ! isModelIncluded ( fieldDef . type , this . queryOptions ) ) continue ;
106108 const relModelDef = this . schema . models [ fieldDef . type ] ;
107109 if ( ! relModelDef ) continue ;
108110 const relIdFields = this . getIdFields ( relModelDef ) ;
@@ -114,15 +116,15 @@ export class RestApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {
114116 fieldName ,
115117 fieldDef ,
116118 tag ,
117- ) as any ;
119+ ) ;
118120
119121 // Relationship management path
120122 paths [ `/${ modelPath } /{id}/relationships/${ fieldName } ` ] = this . buildRelationshipPath (
121123 modelName ,
122124 fieldName ,
123125 fieldDef ,
124126 tag ,
125- ) as any ;
127+ ) ;
126128 }
127129 }
128130
@@ -131,15 +133,15 @@ export class RestApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {
131133 for ( const [ procName , procDef ] of Object . entries ( this . schema . procedures ) ) {
132134 if ( ! isProcedureIncluded ( procName , this . queryOptions ) ) continue ;
133135 const isMutation = ! ! procDef . mutation ;
134- const pathItem : Record < string , any > = { } ;
135-
136136 if ( isMutation ) {
137- pathItem [ 'post' ] = this . buildProcedureOperation ( procName , 'post' ) ;
137+ paths [ `/${ PROCEDURE_ROUTE_PREFIXES } /${ procName } ` ] = {
138+ post : this . buildProcedureOperation ( procName , 'post' ) ,
139+ } as OpenAPIV3_1 . PathItemObject ;
138140 } else {
139- pathItem [ 'get' ] = this . buildProcedureOperation ( procName , 'get' ) ;
141+ paths [ `/${ PROCEDURE_ROUTE_PREFIXES } /${ procName } ` ] = {
142+ get : this . buildProcedureOperation ( procName , 'get' ) ,
143+ } as OpenAPIV3_1 . PathItemObject ;
140144 }
141-
142- paths [ `/${ PROCEDURE_ROUTE_PREFIXES } /${ procName } ` ] = pathItem as any ;
143145 }
144146 }
145147
@@ -702,6 +704,7 @@ export class RestApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {
702704 for ( const [ fieldName , fieldDef ] of Object . entries ( modelDef . fields ) ) {
703705 if ( fieldDef . omit ) continue ;
704706 if ( isFieldOmitted ( modelName , fieldName , this . queryOptions ) ) continue ;
707+ if ( fieldDef . relation && ! isModelIncluded ( fieldDef . type , this . queryOptions ) ) continue ;
705708
706709 const schema = this . fieldToSchema ( fieldDef ) ;
707710 const fieldDescription = getMetaDescription ( fieldDef . attributes ) ;
@@ -738,6 +741,7 @@ export class RestApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {
738741 if ( fieldDef . foreignKeyFor ) continue ;
739742 // Skip auto-generated id fields
740743 if ( idFieldNames . has ( fieldName ) && fieldDef . default !== undefined ) continue ;
744+ if ( fieldDef . relation && ! isModelIncluded ( fieldDef . type , this . queryOptions ) ) continue ;
741745
742746 if ( fieldDef . relation ) {
743747 relationships [ fieldName ] = fieldDef . array
@@ -799,6 +803,7 @@ export class RestApiSpecGenerator<Schema extends SchemaDef = SchemaDef> {
799803 if ( fieldDef . omit ) continue ;
800804 if ( fieldDef . updatedAt ) continue ;
801805 if ( fieldDef . foreignKeyFor ) continue ;
806+ if ( fieldDef . relation && ! isModelIncluded ( fieldDef . type , this . queryOptions ) ) continue ;
802807
803808 if ( fieldDef . relation ) {
804809 relationships [ fieldName ] = fieldDef . array
0 commit comments