use title case for "Object" type

for backwards compatibility
This commit is contained in:
Alexander Zielenski 2023-03-13 17:34:09 -07:00
parent ce3385ab1f
commit 61d408832a
2 changed files with 17 additions and 1 deletions

View File

@ -242,7 +242,9 @@ Takes dictionary as argument with keys:
{{- $name := split $ref "/" | last -}}
{{- or (split $name "." | last) "Object" -}}
{{- else -}}
{{- or .type "Object" -}}
{{/* Old explain used capitalized "Object". Just follow suit */}}
{{- if eq .type "object" -}}Object
{{- else -}}{{- or .type "Object" -}}{{- end -}}
{{- end -}}
{{- else -}}
{{- fail "expected schema argument to subtemplate 'typeguess'" -}}

View File

@ -310,6 +310,20 @@ func TestPlaintext(t *testing.T) {
checkEquals("array"),
},
},
{
// Shows that the typeguess puts Object tpye in title case
Name: "ArrayUnknown",
Subtemplate: "typeGuess",
Context: map[string]any{
"schema": map[string]any{
"description": "a cool field",
"type": "object",
},
},
Checks: []check{
checkEquals("Object"),
},
},
{
// Shows that the typeguess template works with scalars
Name: "ArrayOfScalar",