add support for swagger object and array type #2247

Closed
opened 2026-02-21 17:43:26 -05:00 by yindo · 0 comments
Owner

Originally created by @LeePui on GitHub (Apr 16, 2024).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing?

Objective: Convert the JSON generated by the LLM into the types defined in the Swagger documentation.

2. Describe the feature you'd like to see

Hi, @Yeuoly ,Dify currently supports simple object types, such as Map<String, String>, but it still lacks support for custom object types and arrays.

I want continue to refine the Swagger parsing to enable Dify to support the following formats:

  • support array type:
    • example:
    • swagger format:
"properties": {
    "arr": {
        "type": "array",
        "description": "array type",
        "items": {
            "type": "integer"
        }
    }
}
    • llm generate:{"arr" : "['1', '2', '3']"}
    • parse to : {"arr" : [1, 2, 3]}

  • support additional object type:
    • example:
    • swagger format:
"properties": {
      "objectXXX": {
          "type": "object",
          "description": "object type",
          "additionalProperties": {
              "type": "integer",
              "format": "int32"
          }
      }
}
    • llm generate:{"objectXXX" : "{'field1' : '11', 'field1' : '22'}"}
    • parse to: {"objectXXX" : {'field1' : 11, 'field1' : 22}}

3. How will this feature improve your workflow or experience?

Regarding nested sub-objects, I've found that the LLM's accuracy in generating nested structures is not very high.
I believe that the object structures provided to the LLM should not be too complex and must be easily interpretable.
One solution I've thought of is that the tool's input parameters should convert nested sub-objects into simple Object types, and then include a few-shot description.
For example:
change

"properties": {
    "objectNestedType": {
        "type": "object",
        "additionalProperties": {
            "originalRef": "TestReq",
            "$ref": "#/definitions/Person"
        }
    }
}

to

"properties": {
    "objectNestedType": {
        "type": "object",
        "description": "The following information extracted from the conversation: userName, age, sex. such as {'userName' : 'ben'}",
    }
}

4. Additional context or comments

No response

5. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @LeePui on GitHub (Apr 16, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? **Objective**: Convert the JSON generated by the LLM into the types defined in the Swagger documentation. ### 2. Describe the feature you'd like to see Hi, @Yeuoly ,Dify currently supports simple object types, such as Map<String, String>, but it still lacks support for custom object types and arrays. I want continue to refine the Swagger parsing to enable Dify to support the following formats: - support **array** type: - example: - swagger format: ``` "properties": { "arr": { "type": "array", "description": "array type", "items": { "type": "integer" } } } ``` - - llm generate:`{"arr" : "['1', '2', '3']"}` - parse to : `{"arr" : [1, 2, 3]}` --- - support **additional object** type: - example: - swagger format: ``` "properties": { "objectXXX": { "type": "object", "description": "object type", "additionalProperties": { "type": "integer", "format": "int32" } } } ``` - - llm generate:`{"objectXXX" : "{'field1' : '11', 'field1' : '22'}"}` - parse to: `{"objectXXX" : {'field1' : 11, 'field1' : 22}}` ### 3. How will this feature improve your workflow or experience? Regarding **nested sub-objects**, I've found that the LLM's accuracy in generating nested structures is not very high. I believe that the object structures provided to the LLM should not be too complex and must be easily interpretable. One solution I've thought of is that the tool's input parameters should convert nested sub-objects into simple Object types, and then include a few-shot description. For example: change ``` "properties": { "objectNestedType": { "type": "object", "additionalProperties": { "originalRef": "TestReq", "$ref": "#/definitions/Person" } } } ``` to ``` "properties": { "objectNestedType": { "type": "object", "description": "The following information extracted from the conversation: userName, age, sex. such as {'userName' : 'ben'}", } } ``` ### 4. Additional context or comments _No response_ ### 5. Can you help us with this feature? - [X] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 17:43:26 -05:00
yindo closed this issue 2026-02-21 17:43:26 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#2247