【问题标题】:Flasgger: Parameters not showing and SchemaFlasgger:参数未显示和架构
【发布时间】:2021-06-06 03:35:52
【问题描述】:

我最近开始学习 Swagger for APi 文档。但是,当我转到 localhost:5000/apidocs 时,我看到了我添加的 API,但即使我在 yml 文件中描述了参数,所有 API 都没有参数。我在互联网上找不到任何相关内容。

这是我的 YML 代码:

paths:
  /api/ppp:
    get:
      tags:
      - "user"
      summary: "Find User by uID"
      description: "Returns a single user info"
      operationId: "getuserById"
      produces:
        - "application/xml"
        - "application/json"
      parameters:
        - name: "userId"
          in: "path"
          description: "ID of user to return"
          required: true
          type: "uuid"

这就是我如何向 api 添加 swagger @swag_from('pathto/swagger.yml')

同样,我还有一个疑问。我们在 yml 规范文件中定义模式。我想知道这些架构到底代表什么,是否有必要使用它们?

附上APIdocs页面的截图

【问题讨论】:

    标签: flask swagger swagger-ui flask-restful flasgger


    【解决方案1】:

    试试这个:

    tags:
    - user
    summary: "Find User by uID"
    description: "Returns a single user info"
    operationId: "getuserById"
    produces:
      - "application/xml"
      - "application/json"
    parameters:
      - name: "userId"
        in: "path"
        description: "ID of user to return"
        required: true
        type: "uuid"
    

    【讨论】:

    • 请不要只发布代码作为答案,还要解释您的代码的作用以及它如何解决问题的问题。带有解释的答案通常更有帮助、质量更好,并且更有可能吸引投票。
    猜你喜欢
    • 2021-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多