json-schema-to-typescript
json-schema-to-typescript copied to clipboard
Allow specification of a custom interface name
This PR adds a new tsName
schema property that allows a developer to overwrite the default generated name. This is super helpful in cases where two interfaces/types are generated with the same name (and one has a numerical increment), or where the developer may wish to ensure backwards compatibility of their TypeScript definitions.
Before:
/**
* This interface was referenced by `Browsers`'s JSON-Schema
* via the `definition` "browsers".
*/
export type Browsers1 = Record<string, BrowserStatement>;
export interface Browsers {
browsers?: Browsers1;
}
After:
/**
* This interface was referenced by `Browsers`'s JSON-Schema
* via the `definition` "browsers".
*/
export type Browsers = Record<string, BrowserStatement>;
export interface BrowsersData {
browsers?: Browsers;
}
This is related to #181 (and potentially resolves it?). Unlike #215, however, this PR aims to grant the developer more finite control over the names.