From cff6cf03405f9b338714e1ab1545db0aa73d0732 Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Fri, 22 Dec 2023 23:54:14 +0100 Subject: [PATCH] fix(spec): rendering a Pristine document should ensure raw is up to date This PR makes sure that whenever rendering a Pristine document (e.g. to create a clean document from a fresh clone), the raw root doc is up-to-date. In go-swagger, we modify the spec (e.g. with flatten, expand, ...) and the internal state of the spec document may sometimes need a clean Document to be reconstructed. * contributes go-swagger/go-swagger#2346 Signed-off-by: Frederic BIDON --- spec.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec.go b/spec.go index 30ce449..c9039cd 100644 --- a/spec.go +++ b/spec.go @@ -248,7 +248,8 @@ func (d *Document) ResetDefinitions() *Document { // Pristine creates a new pristine document instance based on the input data func (d *Document) Pristine() *Document { - dd, _ := Analyzed(d.Raw(), d.Version()) + raw, _ := json.Marshal(d.Spec()) + dd, _ := Analyzed(raw, d.Version()) dd.pathLoader = d.pathLoader dd.specFilePath = d.specFilePath