quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

[BUG]: combineClasses option does not work

Open TPNils opened this issue 5 months ago • 0 comments

Issue Type

issue with quicktype output

Context (Environment, Version, Language)

Input Format: json Output Language: typescript

Version: [email protected]

Description

I want to convert a bulk amount of json data into typescript interfaces. Apparently some of them appear identical to each other and get merged together, even with the combineClasses: false or omission of the option.

Input Data

see Steps to Reproduce

Expected Behaviour / Output

With the combineClasses: false or combineClasses ommited, i expect to find 2 interfaces

export interface Obj1 {
    definition: string;
}
export interface Obj2 {
    definition: string;
}

Current Behaviour / Output

export interface Obj2 {
    definition: string;
}

Steps to Reproduce

With NodeJS 18.19.1 on windows 10

const { quicktype, InputData, jsonInputForTargetLanguage } = require("quicktype-core");

async function main() {
  const inputData = new InputData();
  await inputData.addSource('json', {name: 'Obj1', samples: [JSON.stringify({definition: 'Obj1'})]}, () => jsonInputForTargetLanguage('typescript'));
  await inputData.addSource('json', {name: 'Obj2', samples: [JSON.stringify({definition: 'Obj2'})]}, () => jsonInputForTargetLanguage('typescript'));

  // same result without combineClasses
  const tsResult = await quicktype({inputData: inputData, combineClasses: false, lang: 'typescript', rendererOptions: {'just-types': 'true'}});
  console.log('typescript\n' + tsResult.lines.join('\n'))
}

main()

With your website

(i dont know how to share setup to your site so i will fall back to a screenshot) Image

Possible Solution

TPNils avatar May 02 '25 02:05 TPNils