Skip to content

[问题] [BUG] array对象数组会变成字符串 #275

@caochenlei

Description

@caochenlei

⚠️ 验证

  • 我已经搜索过 issues,确信这不是一个重复的问题。

❓ 您的问题

对象数组不能正确接收数据,应该是对象json结构,而不是一个字符串,不知道是配置问题还是,代码bug,另外我的address地址是一个对象,在yaml中也没有体现出来,我是通过openapi文件导入的

📚 上下文

yaml定义如下:

  - name: saveStudent
    description: 保存学生信息、学生地址以及学生的兴趣爱好
    method: PUT
    endpoint: '{{.Config.url}}/api/users/student/save'
    headers:
      Authorization: '{{.Request.Headers.Authorization}}'
      Content-Type: application/json
    args:
      - name: stuNo
        position: body
        required: true
        type: string
        description: 学生学号,唯一标识
        default: ''
        items:
          type: ''
      - name: address
        position: body
        required: true
        type: object
        description: 学生地址信息
        default: ''
        items:
          type: ''
      - name: hobbies
        position: body
        required: true
        type: array
        description: 学生爱好列表,包含学生的各项兴趣爱好
        default: ''
        items:
          type: object
          properties:
            desc:
              description: 爱好的描述或详情
              type: string
            name:
              description: 爱好的名称
              type: string
      - name: stuName
        position: body
        required: true
        type: string
        description: 学生姓名
        default: ''
        items:
          type: ''
    requestBody: |-
      {
          "stuNo": {{ toJSON .Args.stuNo}},
          "address": {{  toJSON .Args.address}},
          "hobbies": {{ toJSON .Args.hobbies}},
          "stuName": {{ toJSON .Args.stuName}}
      }
    responseBody: '{{.Response.Body}}'

接收到的请求:

Image

发送的请求:

Image

我这个爱好是一个 对象数组,但是不知道为什么一直解析为 字符串

🔗 相关资源

暂无

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions