mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 20:47:44 +00:00
Original indention and text delimiter style retained when rendering #106
Now the original indention is captured and string delimiters are retained when rendering out documents. Signed-off-by: Dave Shanley <dave@quobix.com> # fixes 106
This commit is contained in:
@@ -22,18 +22,19 @@ const (
|
||||
// SpecInfo represents a 'ready-to-process' OpenAPI Document. The RootNode is the most important property
|
||||
// used by the library, this contains the top of the document tree that every single low model is based off.
|
||||
type SpecInfo struct {
|
||||
SpecType string `json:"type"`
|
||||
Version string `json:"version"`
|
||||
SpecFormat string `json:"format"`
|
||||
SpecFileType string `json:"fileType"`
|
||||
SpecBytes *[]byte `json:"bytes"` // the original byte array
|
||||
RootNode *yaml.Node `json:"-"` // reference to the root node of the spec.
|
||||
SpecJSONBytes *[]byte `json:"-"` // original bytes converted to JSON
|
||||
SpecJSON *map[string]interface{} `json:"-"` // standard JSON map of original bytes
|
||||
Error error `json:"-"` // something go wrong?
|
||||
APISchema string `json:"-"` // API Schema for supplied spec type (2 or 3)
|
||||
Generated time.Time `json:"-"`
|
||||
JsonParsingChannel chan bool `json:"-"`
|
||||
SpecType string `json:"type"`
|
||||
Version string `json:"version"`
|
||||
SpecFormat string `json:"format"`
|
||||
SpecFileType string `json:"fileType"`
|
||||
SpecBytes *[]byte `json:"bytes"` // the original byte array
|
||||
RootNode *yaml.Node `json:"-"` // reference to the root node of the spec.
|
||||
SpecJSONBytes *[]byte `json:"-"` // original bytes converted to JSON
|
||||
SpecJSON *map[string]interface{} `json:"-"` // standard JSON map of original bytes
|
||||
Error error `json:"-"` // something go wrong?
|
||||
APISchema string `json:"-"` // API Schema for supplied spec type (2 or 3)
|
||||
Generated time.Time `json:"-"`
|
||||
JsonParsingChannel chan bool `json:"-"`
|
||||
OriginalIndentation int `json:"-"` // the original whitespace
|
||||
}
|
||||
|
||||
// GetJSONParsingChannel returns a channel that will close once async JSON parsing is completed.
|
||||
@@ -177,6 +178,9 @@ func ExtractSpecInfo(spec []byte) (*SpecInfo, error) {
|
||||
return specVersion, specVersion.Error
|
||||
}
|
||||
|
||||
// detect the original whitespace indentation
|
||||
specVersion.OriginalIndentation = utils.DetermineWhitespaceLength(string(spec))
|
||||
|
||||
return specVersion, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user