Skip to content

Commit 32ee710

Browse files
committed
fix: add default title handling in specTitle function
This commit updates the specTitle function to provide a default title of 'openAPi' when no title is found in the OpenAPI spec. A warning is logged to the console to inform users of the missing title, enhancing the robustness of the title generation process.
1 parent cdc3eea commit 32ee710

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ export function sanitizeTypeName(name: string): string {
5050
}
5151

5252
export function specTitle(spec: OpenAPIV3.Document): string {
53-
return camelCase(spec.info.title.toLowerCase().replace(/\s+/g, "-"));
53+
const title = spec.info.title ?? "openAPi";
54+
if (!spec.info.title) {
55+
console.warn("No title found in OpenAPI spec, using 'openAPi' as default");
56+
}
57+
return camelCase(title.toLowerCase().replace(/\s+/g, "-"));
5458
}
5559

5660
/**

0 commit comments

Comments
 (0)