-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): docs generation now preserves original model schema names.
- Loading branch information
Showing
18 changed files
with
87 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 18 additions & 6 deletions
24
packages/cli/api-importers/openapi/openapi-ir-parser/src/schema/utils/getSchemaName.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import { camelCase, upperFirst } from "lodash-es"; | ||
import { camelCase, upperFirst, lowerFirst } from "lodash-es"; | ||
import { replaceStartingNumber } from "./replaceStartingNumber"; | ||
|
||
export function getGeneratedTypeName(breadcrumbs: string[]): string { | ||
const underscoreDelimeted = breadcrumbs.join("_"); | ||
const name = upperFirst(camelCase(underscoreDelimeted)); | ||
function customCamelCase(input: string): string { | ||
const tokens = input.split("_"); | ||
const processedTokens = tokens.map((token, index) => { | ||
if (/^[a-zA-Z0-9]+$/.test(token)) { | ||
return index === 0 ? lowerFirst(token) : upperFirst(token); | ||
} | ||
return token; | ||
}); | ||
return processedTokens.join(""); | ||
} | ||
|
||
export function getGeneratedTypeName(breadcrumbs: string[], useOriginalSchemaIds: boolean): string { | ||
const camelCaseFn = useOriginalSchemaIds ? customCamelCase : camelCase; | ||
const underscoreDelimited = breadcrumbs.join("_"); | ||
const name = upperFirst(camelCaseFn(underscoreDelimited)); | ||
if (/^\d/.test(name)) { | ||
return replaceStartingNumber(name) ?? name; | ||
} | ||
return name; | ||
} | ||
|
||
export function getGeneratedPropertyName(breadcrumbs: string[]): string { | ||
const underscoreDelimeted = breadcrumbs.join("_"); | ||
return camelCase(underscoreDelimeted); | ||
const underscoreDelimited = breadcrumbs.join("_"); | ||
return camelCase(underscoreDelimited); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters