mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Add support for enum names with spaces inside them.
This commit is contained in:
parent
5559a15d2a
commit
42ac5e5fa8
9470
package-lock.json
generated
Normal file
9470
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -34,6 +34,7 @@ const handlebarsPlugin = () => ({
|
||||
knownHelpers: {
|
||||
equals: true,
|
||||
notEquals: true,
|
||||
containsSpaces: true,
|
||||
},
|
||||
});
|
||||
return `export default ${templateSpec};`;
|
||||
|
||||
@ -10,6 +10,10 @@ export enum {{{name}}} {
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
{{#if (containsSpaces name)}}
|
||||
"{{{name}}}" = {{{value}}},
|
||||
{{else}}
|
||||
{{{name}}} = {{{value}}},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
|
||||
@ -8,5 +8,6 @@ describe('registerHandlebarHelpers', () => {
|
||||
const helpers = Object.keys(Handlebars.helpers);
|
||||
expect(helpers).toContain('equals');
|
||||
expect(helpers).toContain('notEquals');
|
||||
expect(helpers).toContain('containsSpaces');
|
||||
});
|
||||
});
|
||||
|
||||
@ -9,4 +9,7 @@ export function registerHandlebarHelpers(): void {
|
||||
Handlebars.registerHelper('notEquals', function (a: string, b: string, options: Handlebars.HelperOptions): string {
|
||||
return a !== b ? options.fn(this) : options.inverse(this);
|
||||
});
|
||||
Handlebars.registerHelper('containsSpaces', function (value: string): boolean {
|
||||
return /\s+/.test(value);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user