INNER CODE UNIT · Go

TestAdditionalProperties_PreservesUnrelatedKeys

yannh/kubeconform · openapi2jsonschema-go/openapi2jsonschema_test.go:108

func TestAdditionalProperties_PreservesUnrelatedKeys(t *testing.T) {
	input := mapOf(
		"properties", mapOf("name", mapOf("type", "string")),
		"required", []any{"name"},
		"type", "object",
	)
	got := additionalProperties(input, false)
	parsed := roundTrip(t, got)
	// `additionalProperties: false` is only added at the level that has a
	// "properties" key — the nested {type: string} does not.
	want := map[string]any{
		"properties":           map[string]any{"name": map[string]any{"type": "string"}},
		"required":             []any{"name"},
		"type":                 "object",
		"additionalProperties": false,
	}
	if !reflect.DeepEqual(parsed, want) {
		t.Fatalf("got %v want %v", parsed, want)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…