Repository navigation
Commit 5bbd33a
feat(spec): name-identity deconfliction for colliding definition names
Replace the short-name definition-key proxy with a real model-identity
mechanism so distinct Go types that share a name no longer merge silently
(and non-deterministically) onto one definition.
The build keys every definition by a fully-qualified, compiler-unique
identity ("<pkgpath>/<name>", EntityDecl.DefKey); a final reduce stage
projects each back to the shortest acceptable user-facing name:
- a globally-unique leaf is lifted to its bare name (byte-identical to
the previous output — zero churn in the common case);
- a colliding leaf is qualified with the minimal-depth PascalCase concat
of its nearest package segments (b.Test / c.Test -> BTest / CTest),
deepening until the group is globally unique, with a diagnostic;
- same-package duplicates (necessarily via swagger:model overrides)
revert the later declaration to its Go name, with a diagnostic;
- a colliding group whose best flat concat exceeds a readability budget
can, opt-in, be emitted as nested container definitions instead.
The whole pass is a pure function of the reachable identity set, so the
output is deterministic regardless of discovery / map-iteration order.
Author short-name $refs resolve to a colliding identity by leaf
(unique -> promote, none -> dangling, ambiguous -> diagnose + drop).
New options (scanner.Options):
- NameConcatBudget (default 0.65): readability-score threshold above
which a concat is a candidate for the hierarchical fail-safe.
- EmitHierarchicalNames (default false): opt into the nested fallback.
Includes the witness corpus (recursion / no-collision controls; the
3-way / mixed / same-package-dup / deep / recursion-collision /
examples-no-mix / hierarchical scenarios) with golden locks, plus the
readability-score exploration harness (disabled).
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
contributes to go-swagger#2783
contributes to go-swagger#2637
contributes to go-swagger#2662
contributes to go-swagger#1734
contributes to go-swagger#2126
contributes to go-swagger#2398
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 64cbe48 commit 5bbd33a
89 files changed
Lines changed: 2842 additions & 246 deletions
File tree
- fixtures
- bugs
- 2637
- mongo
- 2783
- b
- c
- enhancements
- name-identity-3way
- a
- b
- c
- name-identity-deep
- a/mongo
- b/mongo
- name-identity-examples-no-mix
- a
- b
- name-identity-hierarchical
- notificationservice
- recommendationengine
- name-identity-mixed
- x
- y
- name-identity-no-collision
- sub
- name-identity-recursion-collision
- p
- q
- name-identity-recursion
- name-identity-same-pkg-dup
- integration/golden
- internal
- builders
- common
- parameters
- responses
- routes
- schema
- spec
- integration
- parsers/grammar
- scanner
- scantest
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments