mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +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:
@@ -622,3 +622,54 @@ func TestDocument_InputAsJSON(t *testing.T) {
|
||||
|
||||
assert.Equal(t, d, strings.TrimSpace(string(rend)))
|
||||
}
|
||||
|
||||
func TestDocument_InputAsJSON_LargeIndent(t *testing.T) {
|
||||
|
||||
var d = `{
|
||||
"openapi": "3.1",
|
||||
"paths": {
|
||||
"/an/operation": {
|
||||
"get": {
|
||||
"operationId": "thisIsAnOperationId"
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
doc, err := NewDocumentWithConfiguration([]byte(d), datamodel.NewOpenDocumentConfiguration())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, _ = doc.BuildV3Model()
|
||||
|
||||
// render the document.
|
||||
rend, _, _, _ := doc.RenderAndReload()
|
||||
|
||||
assert.Equal(t, d, strings.TrimSpace(string(rend)))
|
||||
}
|
||||
|
||||
func TestDocument_RenderWithIndention(t *testing.T) {
|
||||
|
||||
spec := `openapi: "3.1.0"
|
||||
info:
|
||||
title: Test
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/test:
|
||||
get:
|
||||
operationId: 'test'`
|
||||
|
||||
config := datamodel.NewOpenDocumentConfiguration()
|
||||
|
||||
doc, err := NewDocumentWithConfiguration([]byte(spec), config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, _ = doc.BuildV3Model()
|
||||
|
||||
rend, _, _, _ := doc.RenderAndReload()
|
||||
|
||||
assert.Equal(t, spec, strings.TrimSpace(string(rend)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user