【问题标题】:Swagger Editor Parameter ErrorsSwagger 编辑器参数错误
【发布时间】:2017-06-08 04:09:28
【问题描述】:

我正在尝试在 Swagger 中起草一个 API,以便通过 SwaggerUI 轻松查看,但遇到了我不太理解的错误。据我所知,我遵守规范。

/history/tags/{tag_id}:
  get:
    summary: "Gets the history of this tag."
    description: "Warning: not using both the start and end date fields may result in excessively long responses."
    operationId: "get_tag_history"
    produces:
    - "application/json"
    parameters:
    - name: "tag_id"
      in: "path"
      description: "UUID for this tag."
      type: "string"
      required: true
    - name: "start_date"
      in: "query"
      description: "Start date for history"
      type: "String"
      foramt: "date"
      required: false
    - name: "end_date"
      in: "query"
      description: "End date for history"
      type: "String"
      foramt: "date"
      required: false
    responses:
      200:
        description: "Operation success"
        schema: 
          $ref: "#/definitions/Tag_history"
      400:
        description: "Invalid request"

第二个和第三个参数抛出Schema error at paths./history/tags/{tag_id}.get.parameters[1] is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>(或parameters[2],取决于哪个参数)。

我见过的大多数其他问题只是人们忘记使用schema:,但这不是查询参数的结构方式。有什么想法吗?

【问题讨论】:

    标签: swagger-ui swagger-2.0 swagger-editor


    【解决方案1】:

    改变

    type: "String"
    foramt: "date"
    

    type: "string"
    format: "date"
    

    type 区分大小写,format 拼写错误。

    【讨论】:

    • 嗯,这只是尴尬...谢谢。
    猜你喜欢
    • 2017-06-11
    • 1970-01-01
    • 1970-01-01
    • 2018-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-18
    相关资源
    最近更新 更多