Swift: use file-private JSON helpers for standalone output

Open Beginner friendly
#3,093 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
swift
Domain
tooling

Research direction

Start with the Swift output path that handles the multiFileOutput option and the JSONSchemaSupport.swift helpers. Compare standalone output with --multi-file-output, then add regression coverage for both modes and verify that standalone generated files compile together while multi-file model files still access the helpers.

Written by the indexing model from the issue text.

Description

Problem

Swift output generated with --initializers contains module-level newJSONDecoder() and newJSONEncoder() helpers. When multiple schemas are generated separately and added to the same Swift target, each file defines the same functions and compilation fails with Invalid redeclaration.

The original fix in #1168 made these helpers fileprivate. They were later moved to JSONSchemaSupport.swift in commit ff61903b8, where they were changed back to internal visibility so model files could call the shared support file.

Expected behavior

  • Standalone/single-file output: helpers should be fileprivate, allowing multiple generated files in one module.
  • --multi-file-output: helpers in JSONSchemaSupport.swift must remain module-visible because model files call them.

Proposed fix

Emit fileprivate when multiFileOutput is disabled, and keep the current internal visibility when it is enabled. Add regression coverage for both modes.

Related: #1166, #1168.

Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 14m
Merged PRs (30d)
368

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from glideapps/quicktype

All issues in glideapps/quicktype

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.