@@ -191,14 +191,28 @@ async function createFernProject(data: OnboardingDocsRequest, tempDir: string):
191191 } ;
192192 }
193193
194+ // Remove API Reference tab if no OpenAPI specs provided
195+ if ( data . openApiSpecUrls . length === 0 ) {
196+ // Remove the API Reference tab from tabs
197+ if ( docsConfig . tabs && docsConfig . tabs [ "API Reference" ] ) {
198+ delete docsConfig . tabs [ "API Reference" ] ;
199+ }
200+
201+ // Remove the API Reference navigation
202+ if ( docsConfig . navigation ) {
203+ docsConfig . navigation = docsConfig . navigation . filter ( ( nav : any ) => nav . tab !== "API Reference" ) ;
204+ }
205+ }
206+
194207 // Write updated docs.yml
195208 await fs . writeFile (
196209 docsYmlPath ,
197210 `# yaml-language-server: $schema=https://schema.buildwithfern.dev/docs-yml.json\n\n${ yaml . dump ( docsConfig ) } `
198211 ) ;
199212
200- // Download OpenAPI specs if provided and update generators.yml
213+ // Handle OpenAPI specs and generators.yml
201214 if ( data . openApiSpecUrls . length > 0 ) {
215+ // Download OpenAPI specs if provided
202216 for ( const spec of data . openApiSpecUrls ) {
203217 try {
204218 const { content } = await fetchOpenApiSpec ( spec . assetUrl ) ;
@@ -208,11 +222,19 @@ async function createFernProject(data: OnboardingDocsRequest, tempDir: string):
208222 }
209223 }
210224
211- // Create or update generators.yml with OpenAPI specs
225+ // Update generators.yml with OpenAPI specs
212226 const generatorsYmlContent = createGeneratorsYml ( data . openApiSpecUrls ) ;
213227 if ( generatorsYmlContent ) {
214228 await fs . writeFile ( path . join ( fernDir , "generators.yml" ) , generatorsYmlContent ) ;
215229 }
230+ } else {
231+ // Remove generators.yml from template if no OpenAPI specs provided
232+ try {
233+ await fs . unlink ( path . join ( fernDir , "generators.yml" ) ) ;
234+ } catch ( error ) {
235+ // File might not exist, ignore error
236+ console . log ( "generators.yml not found in template, skipping removal" ) ;
237+ }
216238 }
217239}
218240
0 commit comments