Currently we have BeanOutputConverter to generate JSON schema based on the bean struct, but we can't define each field's meaning for the AI model.

Because https://json-schema.org/draft/2020-12/schema schema supports comments mechanism, maybe we can use schema comments to let the AI model more accurately generate response for each fields.

Expected Behavior

For example the following code will generate the prompt below:

BeanOutputConverter<Response> outputConvert = new BeanOutputConverter<>(Response.class);

record Response(List<Data> datas) {
        record Data(Integer type, String content, String description) {
        }
}

--- 

Your response should be in JSON format.
Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
Do not include markdown code blocks in your response.
Remove the ```json markdown from the output.
Here is the JSON Schema instance your output must adhere to:
```{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "type" : "object",
  "properties" : {
    "datas" : {
      "type" : "array",
      "items" : {
        "type" : "object",
        "properties" : {
          "content" : {
            "type" : "string"
          },
          "description" : {
            "type" : "string"
          },
          "type" : {
            "type" : "string"
          }
        }
      }
    }
  }
}```

Maybe we can add an annotation to the field such like this:

BeanOutputConverter<Response> outputConvert = new BeanOutputConverter<>(Response.class);

record Response(List<Data> datas) {
        record Data(@SchemaCommont("type should be following the rule: food=1, fruit=2") Integer type, String content, String description) {
        }
}

--- 

Your response should be in JSON format.
Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
Do not include markdown code blocks in your response.
Remove the ```json markdown from the output.
Here is the JSON Schema instance your output must adhere to:
```{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "type" : "object",
  "properties" : {
    "datas" : {
      "type" : "array",
      "items" : {
        "type" : "object",
        "properties" : {
          "content" : {
            "type" : "string"
          },
          "description" : {
            "type" : "string"
          },
          "type" : {
            "type" : "string",
            "$comment": "type should be following the rule: food=1, fruit=2"
          }
        }
      }
    }
  }
}```

Comment From: maxjiang153

It seems @JsonPropertyDescription already supported this feature.

BeanOutputConverter<Response> outputConvert = new BeanOutputConverter<>(Response.class);

record Response(List<Data> datas) {
        record Data(@JsonPropertyDescription("type should be following the rule: food=1, fruit=2") Integer type, String content, String description) {
        }
}

--- 

Your response should be in JSON format.
Do not include any explanations, only provide a RFC8259 compliant JSON response following this format without deviation.
Do not include markdown code blocks in your response.
Remove the ```json markdown from the output.
Here is the JSON Schema instance your output must adhere to:
```{
  "$schema" : "https://json-schema.org/draft/2020-12/schema",
  "type" : "object",
  "properties" : {
    "datas" : {
      "type" : "array",
      "items" : {
        "type" : "object",
        "properties" : {
          "content" : {
            "type" : "string"
          },
          "description" : {
            "type" : "string"
          },
          "type" : {
            "type" : "integer",
            "description": "type should be following the rule: food=1, fruit=2"
          }
        }
      }
    }
  }
}```