quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

Use exact given name for generated TypeScript interface (don't remove underscores or change capitalization)

Open hi2u opened this issue 5 years ago • 1 comments

I'm using quicktype-core as a library in a Node.js project to generate TypeScript interfaces from a collection of JSON files.

I give the exact interface name that I want, such as This_is_the_exact_interface_name_i_want below:

const jsonInput = jsonInputForTargetLanguage('typescript');
await jsonInput.addSource({
	name: "This_is_the_exact_interface_name_i_want", // <-- THIS PART
	samples: myArrayOfSamples,
});

const inputData = new InputData();
inputData.addInput(jsonInput);
const result = await quicktype({
	inputData,
	lang: 'typescript',
	alphabetizeProperties: true,
	inferEnums: false,
	rendererOptions: {},
});

...but the name of the top-level interface it generates removes the underscores and converts to WordCase.

  • So instead of getting what I wanted: This_is_the_exact_interface_name_i_want
  • I get: ThisIsTheExactInterfaceNameIWant

How can I stop it from doing that? I need the generated top-level interface (and obviously all the references to it) to have the exact name that I've specified.

hi2u avatar Aug 26 '20 09:08 hi2u

@schani .. is there any way to do this?

hi2u avatar Nov 16 '23 13:11 hi2u