Swagger/OpenAPI 模拟服务器 [英] Swagger/OpenAPI mock server

查看:27
本文介绍了Swagger/OpenAPI 模拟服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Swagger 文件中有一个 API 参考.我想创建一个非常简单的模拟服务器,这样当我调用例如:

I have an API reference in a Swagger file. I want to create a very simple mock server, so that when I call e.g.:

mymockurl.com/users 它将返回一个预定义的 JSON(无需连接到数据库).

mymockurl.com/users it will return a predefined JSON (no need to connect to a database).

最简单的方法是什么?我不是后端人员.

What's the easiest way to do this? I'm not a backend guy.

推荐答案

SwaggerHub 为 OpenAPI 2.0 和3.0 规格.免费和付费计划均支持模拟.

SwaggerHub provides a mock server for OpenAPI 2.0 and 3.0 specs. Mocking is supported on both free and paid plans.

要使用模拟服务器,请将您的规范导入 SwaggerHub 并启用API 自动模拟".模拟响应可以是 JSON、YAML 和 XML,并根据您的响应模式和定义的 exampledefaultenum 值生成架构.

To use the mock server, import your spec into SwaggerHub and enable "API Auto Mocking". Mock responses can be JSON, YAML and XML, and are generated based on your response schemas and the example, default and enum values defined in the schemas.

披露:我在制作 SwaggerHub 的公司工作.

Disclosure: I work for the company that makes SwaggerHub.

这篇关于Swagger/OpenAPI 模拟服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆