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

不是有效的参数定义,Swagger 2.0

  •  0
  • SharpCoder  · 技术社区  · 9 年前

    我是新来的,下面是我试图在在线编辑器中编辑的代码。但它在参数字段显示一个错误,显示“不是有效的参数定义”。

    # Example YAML to get you started quickly.
    # Be aware that YAML has indentation based scoping.
    # Code completion support is available so start typing for available options.
    swagger: '2.0'
    
    # This is your document metadata
    info:
      version: "0.0.0"
      title: <test>
    
    # Describe your paths here
    paths:
      # This is a path endpoint. Change it.
      /test:
        # This is a HTTP operation
        post:
          # Describe this verb here. Note: you can use markdown
    
          description: Pass list of input parameter.
          # This is array of GET operation parameters:
          operationId: test
          produces:
            - application/json
            - application/xml
            - text/xml
            - text/html
          parameters:
            - 
              name: value
              in: body
              description: Input parameter list
              required: true
              schema:
              type: array
              items:
                type: object
                properties:
                  Name:
                    type: string
                  Age:
                    type: integer
                    format: int32
                  Address:
                    type: string
                  Company:
                    type: string
                  WorkExperience:
                    type: integer
                    format: int32
    
          # Expected responses for this operation:
          responses:
            # Response code
            200:
              description: Successful response
              # A schema describing your response object.
              # Use JSON Schema format
              schema:
                title: ArrayOfPersons
                type: array
                items:
                  title: Person
                  type: object
                  properties:
                    name:
                      type: string
                    single:
                      type: boolean
    

    Swagger Error
    Not a valid parameter definition
    Jump to line 28
    Details
     Object
    code:  "ONE_OF_MISSING"
     params: Array [0]
    message:  "Not a valid parameter definition"
     path: Array [5]
    schemaId:  "http://swagger.io/v2/schema.json#"
     inner: Array [2]
    level: 900
    type:  "Swagger Error"
    description:  "Not a valid parameter definition"
    lineNumber: 28
    
    2 回复  |  直到 9 年前
        1
  •  1
  •   Ujjwal    9 年前

    这是一个有意出错的代码。

    schema:
        type: array
        items:
            type: object
            properties:
    
        2
  •  0
  •   Marlon van der Linde    9 年前

    模式字段中的“type:array”定义没有正确缩进。

          parameters:
            - 
              name: value
              in: body
              description: Input parameter list
              required: true
              schema:
                type: array
                items:
                  type: object
                  properties:
                    Name:
                      type: string
                    Age:
                      type: integer
                      format: int32
                    Address:
                      type: string
                    Company:
                      type: string
                    WorkExperience:
                      type: integer
                      format: int32