Skip to content

Commit

Permalink
fix(gen): keep fragment prefix for jschemagen
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Nov 22, 2022
1 parent 4fba9bf commit 1ab8195
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gen/gen_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ func GenerateSchema(schema *jsonschema.Schema, fs FileSystem, opts GenerateSchem
{
prev := gen.nameRef
gen.nameRef = func(ref jsonschema.Ref) (string, error) {
nref := ref
for _, trim := range opts.TrimPrefix {
ref.Ptr = strings.TrimPrefix(ref.Ptr, trim)
nref.Ptr = strings.TrimPrefix(nref.Ptr, trim)
}
if !strings.HasPrefix(nref.Ptr, "#") {
nref.Ptr = "#" + nref.Ptr
}

result, err := prev(ref)
result, err := prev(nref)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 1ab8195

Please sign in to comment.