我有API规范,它定义了来自每个端点的响应,例如,我希望/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-烧瓶服务器存根并在我的机器上本地运行,它返回每个端点的do some magic!,而不是yaml中提供的example。使用swagger-codegen和openapi生成器生成的服务器存根也是如此。
我主要感兴趣的是让它为openapi生成器生成的服务器存根工作。
发布于 2021-12-28 15:00:41
这正如期而至。
example标记是一个OpenAPI标记,用于向用户提供示例对象或模式,以演示API的使用。SwaggerHub (virtserver)提供的虚拟服务能够在对SwaggerHub提供的虚拟化服务进行API调用时解释example值并返回这些值。
另一方面,codegen可能也可能不会以相同的方式处理example标记(这取决于codegen模板)。关于如何解决这一问题,我有两个建议:
https://stackoverflow.com/questions/68346138
复制相似问题