musement / types-generator

3 stars 1 forks source link

fix: convert any string to pascal case #25

Closed GabriMcNab closed 2 years ago

GabriMcNab commented 2 years ago

Description

If I try to generate types for this king of swagger: https://gist.github.com/GabriMcNab/22b190988b050122fda1cad5d46fdca2

I get this output:

"use strict";
export type Error = { code?: string; message?: string };
export type Title = string;
export type Description = string;
export type Highlights = Array<string>;
export type Included = Array<string>;
export type Non_included = Array<string>;
export type Important_information = Array<string>;
export type Info_voucher = string;
export type Id = string;
export type Go_commercial = boolean;
export type Asterix_id = string;
export type Core_id = string;
export type Creation_date = string;
export type Updated_date = string;
export type Functional_raw = {
  asterix_id?: Asterix_id;
  core_id?: Core_id;
  highlights?: Highlights;
  included?: Included;
  non_included?: Non_included;
  important_information?: Important_information;
};
export type Commercial_raw = {
  title: Title;
  description?: Description;
  info_voucher?: Info_voucher;
};
export type Raw_element = {
  id?: Id;
  go_commercial?: Go_commercial;
  creation_date?: Creation_date;
  updated_date?: Updated_date;
  functional?: Functional_raw;
  commercial: Commercial_raw;
};

Which is not compliant with the PascalCase standard for Typescript.

What

Why

The toPascalCase function should be able to convert any kind of case (snake_case, kebab-case, camelCase) to PascalCase.