Swaggerhub 返回预定义的响应,但服务器存根不返回

问题描述

我有 API yaml 规范,它定义了每个端点的响应应该是什么,例如我希望 /version 按照定义返回 version1.0

openapi: "3.0.3"
info:
  title: "TITLE"
  description: "DESCRIPTION"
  version: "1.0.0"
paths:
  /version:
    get:      
      description: "description"      
      responses:
        "200": 
          description: "description"
          content: 
            application/json:
              schema:
                $ref: '#/components/schemas/version'
components:
  schemas:
    version:
      type: object
      properties:
        version:
          type: string
      example:
        "version": "version1.0"

在 Swaggerhub 上运行的 API 服务器按预期工作,但例如由 Swaggerhub 生成并在我的机器上本地运行的 python-flask 服务器存根为每个端点返回 do some magic!,而不是 yaml 中提供的 example。与使用 swagger-codegen 和 openapi-generator 生成的服务器存根相同。

我的主要兴趣在于让它适用于 openapi-generator 生成的服务器存根。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)