Skip to content

Commit

Permalink
fix(spec): rendering a Pristine document should ensure raw is up to date
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
fredbi committed Dec 22, 2023
1 parent 61ff370 commit cff6cf0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cff6cf0

Please sign in to comment.