mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
Added support for original format rendering #105
Original input document types are now rendered automatically as JSON or YAML (vs always being YAML). This only operates at the `Document` level for rendering out entire documents. Requested in #105 Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -573,6 +573,7 @@ summary: a test thing
|
||||
description: this is a test, that does a test.`
|
||||
|
||||
_ = os.WriteFile("test-operation.yaml", []byte(ae), 0644)
|
||||
defer os.Remove("test-operation.yaml")
|
||||
|
||||
var d = `openapi: "3.1"
|
||||
paths:
|
||||
@@ -595,3 +596,29 @@ paths:
|
||||
|
||||
assert.Equal(t, d, strings.TrimSpace(string(rend)))
|
||||
}
|
||||
|
||||
func TestDocument_InputAsJSON(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)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user