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

查看:174
本文介绍了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天全站免登陆