From a9ce47d8e1740bce22971960f02e914697d91616 Mon Sep 17 00:00:00 2001 From: Fabio Bonelli Date: Wed, 18 Feb 2026 09:28:26 +0100 Subject: [PATCH] feat: add normalized publiccode.yml to validation response Reply with a normalized canonical equivalent publiccode.yml when validation succeeds so clients don't need to deal with deprecated fields, aliases or renames on their side. Fix #42. --- internal/handlers/validate.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/handlers/validate.go b/internal/handlers/validate.go index 9b467b2..508ac70 100644 --- a/internal/handlers/validate.go +++ b/internal/handlers/validate.go @@ -29,6 +29,8 @@ func NewPubliccodeymlValidatorHandler() *PubliccodeymlValidatorHandler { } func (vh *PubliccodeymlValidatorHandler) Query(ctx *fiber.Ctx) error { + var normalized *string + valid := true parser := vh.parser @@ -51,7 +53,7 @@ func (vh *PubliccodeymlValidatorHandler) Query(ctx *fiber.Ctx) error { reader := bytes.NewReader(ctx.Body()) - _, err := parser.ParseStream(reader) + parsed, err := parser.ParseStream(reader) if err != nil { var validationResults publiccodeParser.ValidationResults if errors.As(err, &validationResults) { @@ -66,5 +68,13 @@ func (vh *PubliccodeymlValidatorHandler) Query(ctx *fiber.Ctx) error { } } - return ctx.JSON(fiber.Map{"valid": valid, "results": results}) + if valid && parsed != nil { + yaml, err := parsed.ToYAML() + if err == nil { + s := string(yaml) + normalized = &s + } + } + + return ctx.JSON(fiber.Map{"valid": valid, "results": results, "normalized": normalized}) }