Skip to content

Prevent duplicate import#71

Merged
cubahno merged 1 commit into
mainfrom
ig/fix-duplicate-import
Apr 15, 2026
Merged

Prevent duplicate import#71
cubahno merged 1 commit into
mainfrom
ig/fix-duplicate-import

Conversation

@cubahno
Copy link
Copy Markdown
Collaborator

@cubahno cubahno commented Apr 15, 2026

When a schema uses x-go-type-import with path: encoding/json (common with x-go-type: json.RawMessage), the generated code contains a duplicate "encoding/json" import.
This is because:

  1. header.tmpl hardcodes "encoding/json" in the import block
  2. .Imports (from x-go-type-import on schemas) can also contain "encoding/json"
  3. The template renders both, creating a duplicate
  4. imports.Process() (goimports) at parser.go should be the safety net but doesn't handle the resulting parse error gracefully

Fixes #70

@cubahno cubahno force-pushed the ig/fix-duplicate-import branch from 5ce37db to 6c1c45e Compare April 15, 2026 15:38
@cubahno cubahno marked this pull request as ready for review April 15, 2026 15:42
@cubahno cubahno merged commit d92daca into main Apr 15, 2026
3 checks passed
@cubahno cubahno deleted the ig/fix-duplicate-import branch April 15, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

duplicate encoding/json import

1 participant