fun testGenerateStandardSchemaWithDescriptions()

in prompt/prompt-structure/src/commonTest/kotlin/ai/koog/prompt/structure/json/generator/JsonSchemaGeneratorTest.kt [344:404]


    fun testGenerateStandardSchemaWithDescriptions() {
        val descriptions = mapOf(
            "TestClass" to "A test class (override)",
            "TestClass.intProperty" to "An integer property"
        )

        val result = standardGenerator.generate(json, "TestClass", serializer<TestClass>(), descriptions)
        val schema = json.encodeToString(result.schema)

        val expectedSchema = """
            {
              "${"$"}id": "TestClass",
              "${"$"}defs": {
                "TestClass": {
                  "type": "object",
                  "properties": {
                    "stringProperty": {
                      "type": "string",
                      "description": "A string property"
                    },
                    "intProperty": {
                      "type": "integer",
                      "description": "An integer property"
                    },
                    "booleanProperty": {
                      "type": "boolean"
                    },
                    "nullableProperty": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "listProperty": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "mapProperty": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "integer"
                      }
                    }
                  },
                  "required": [
                    "stringProperty",
                    "intProperty",
                    "booleanProperty"
                  ],
                  "additionalProperties": false,
                  "description": "A test class (override)"
                }
              },
              "${"$"}ref": "#/${"$"}defs/TestClass"
            }
        """.trimIndent()

        assertEquals(expectedSchema, schema)
    }