json-schema-to-typescript icon indicating copy to clipboard operation
json-schema-to-typescript copied to clipboard

Parsed ts dosen't have description when string array with description

Open GrangbelrLurain opened this issue 7 months ago • 2 comments

I write string array schema with description, but it isn't in parsed typescript. please update typescript with description. if you not have time to update, please comment to me for push request this issue.

this is example for this issue, yaml json schema

$schema: http://json-schema.org/draft-07/schema#

title: peoples
type: array
description: |
  @group Shared/QueryString
  @description <adult>,<child age>|<child age>
items:
  type: string
  description: |
    @group Shared/QueryString/REGEXP
    @description travel peoples QueryString(<adult>,<child age>|<child age>|...)
  pattern: "^\\d+,(?:\\d+)(?:-\\d+)*$"
  examples:
    - "2,5-7"
    - "1,3-4-5"

this is parsed schema to typescript


/**
 * @group Shared/QueryString
 * @description <adult>,<child age>|<child age>
 */
export type Peoples = string[];

GrangbelrLurain avatar May 20 '25 02:05 GrangbelrLurain

@claude implement this

bcherny avatar Jun 04 '25 01:06 bcherny

Claude finished @bcherny's task in 3m 22s —— View jobclaude/issue-660-20250604_012018Create PR ➔


✅ Successfully implemented string array item descriptions

I've implemented the fix for issue #660 where string array item descriptions were missing from generated TypeScript.

Todo List:

  • [x] Read repository setup instructions (CLAUDE.md) - No CLAUDE.md found, checked README and package.json
  • [x] Understand the codebase structure and current description handling
  • [x] Find array processing logic and identify where item descriptions should be added
  • [x] Implement the fix to include array item descriptions in src/generator.ts
  • [x] Create test case for the fix
  • [x] Commit changes and provide PR link

✨ Changes Made:

  1. Fixed src/generator.ts: Modified the generateStandaloneType() function to include array item descriptions in the generated TypeScript comment. When an array has items with descriptions, they're now included as "Array items: [description]".

  2. Added test case: Created test/e2e/arrayWithItemDescription.js to verify the fix works correctly with the exact scenario from the issue.

🎯 Result:

The provided YAML schema example will now generate:

/**
 * @group Shared/QueryString
 * @description <adult>,<child age>|<child age>
 *
 * Array items:
 * @group Shared/QueryString/REGEXP
 * @description travel peoples QueryString(<adult>,<child age>|<child age>|...)
 */
export type Peoples = string[];

Instead of the previous output that omitted the array item descriptions.


claude[bot] avatar Jun 04 '25 01:06 claude[bot]