代码之家  ›  专栏  ›  技术社区  ›  daveskylark

虚张声势抛出“不是有效的参数定义”

  •  0
  • daveskylark  · 技术社区  · 8 年前

    我正在使用Swagger UI创建API文档。我有很多错误,说“不是有效的参数定义”,我不知道为什么。谁能告诉我发生了什么或为什么?我包括一段代码和一张带有行号和错误描述的图片。

    招摇过市的例子

    #sys_application
    
    /api/application/add:
      post:
        description: Adds specified application(s).
        parameters:
    
        - name: name
          in: body
          description: name of the application
          required: true
          type: string
    
        - name: appId
          in: body
          description: application id
          required: true
          type: string
    
        - name: icon
          in: body
          description: application icon
          required: true
          type: string
    
        - name: state
          in: body
          description: current state of the application
          required: true
          type: string
    
        - name: profileRoute
          in: body
          description: embedded profile route that is displayed within the map app
          required: true
          type: string
    
        - name: type
          in: body
          description: type of the application
          required: true
          type: string
    
        - name: permissions
          in: body
          description: user permissions for application
          required: false
          type: string
    
        - name: subscriptions
          in: body
          description: application subscriptions
          required: false
          type: string
    

    虚张声势错误

    enter image description here

    1 回复  |  直到 8 年前
        1
  •  2
  •   fehguy    8 年前

    当你使用 in: body ,规范要求 schema 元素,例如:

    name: user
    in: body
    schema:
      type: object
      properties:
        userId:
          type: string
    

    使用主体参数时,需要使用基本值,例如 type: string .