@Test
    public void testOptionalPropsWithCommonPrefix() {
        var schema = """
                {
                    "properties": {
                        "ab": {"type": "integer"},
                        "ac": {"type": "integer"}
                    },
                    "additionalProperties": {"type": "integer"}
                }
                """;
        var expectedGrammar = """
                ab-kv ::= "\\"ab\\"" space ":" space integer
                ab-rest ::= ( "," space ac-kv )? ac-rest
                ac-kv ::= "\\"ac\\"" space ":" space integer
                ac-rest ::= ( "," space additional-kv )*
                additional-k ::= ["] ( [a] ([b] char+ | [c] char+ | [^"bc] char*) | [^"a] char* )? ["] space
                additional-kv ::= additional-k ":" space integer
                char ::= [^"\\\\\\x7F\\x00-\\x1F] | [\\\\] (["\\\\bfnrt] | "u" [0-9a-fA-F]{4})
                integer ::= ("-"? integral-part) space
                integral-part ::= [0] | [1-9] [0-9]{0,15}
                root ::= "{" space  (ab-kv ab-rest | ac-kv ac-rest | additional-kv ( "," space additional-kv )* )? "}" space
                space ::= | " " | "\\n" [ \\t]{0,20}
                """;


        var actualGrammar = JsonSchemaToGrammar.convert(schema);
        assertEquals(expectedGrammar, actualGrammar);
    }
These tests are based on C++ unit tests from llama.cpp repository.
model-integration/src/test/java/ai/vespa/llm/clients/JsonSchemaToGrammarTest.java