什么是 Swagger,它与 OData 有关系吗? [英] What is Swagger and does it relate to OData?

查看:59
本文介绍了什么是 Swagger,它与 OData 有关系吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉 Microsoft 堆栈.我正在将 OData 用于我的一些宁静服务.最近我遇到了 Swagger 的 API 文档,我试图了解它与 OData 的关系.它们似乎都是 RESTful 规范.哪一种被广泛使用?

I am familiar with the Microsoft stack. I am using OData for some of my restful services. Recently I came across Swagger for API documentation and I am trying to understand how it relates to OData. Both of them seem to be RESTful specifications. Which one is widely used?

推荐答案

Swagger 是用于记录 API 的规范.通过为 API 创建 swagger 文档,您可以将其传递给 Swagger UI 的实例,该实例以整洁、可读的格式呈现文档并提供调用 API 的工具.有关详细信息,请参阅 swagger.io 网站.

Swagger is a specification for documenting APIs. By creating a swagger document for your API, you can pass it to an instance of Swagger UI, which renders the document in a neat, readable format and provides tooling to invoke your APIs. See the swagger.io website for further information.

OData 是用于创建http 上的数据服务 的规范,它定义了服务应该如何构建以及它应该遵循什么模式.例如,使用 $top 指令提供数据集的前 n 个结果.OData 目前是第 4 版,但 v2 文档有一个 非常很好的概述.

OData is a specification for creating data services over http, it defines how a service should be constructed and what patterns it should follow. For example, the use of the $top directive to provide the first n results of a data set. OData is currently at version 4, but the v2 documentation has a very good overview.

Swashbuckle 是 Microsoft 堆栈的 nuget 包根据检查您提供的用于塑造输出文档的代码和其他元数据,自动为您的 API 生成 swagger 文档.

Swashbuckle is a nuget package for the Microsoft stack that produces swagger documents for your API's automatically, based on inspecting the code and additional metadata you provide to shape the output document.

如果您希望 Swashbuckle 为您正在构建的 OData API 自动生成 swagger 文档,那么您可以使用 Swashbuckle.OData 为您提供此信息.

If you want Swashbuckle to automatically generate swagger documents for an OData API you are building, then you can use Swashbuckle.OData to provide this for you.

如果您使用 .NET Core,那么它会变得稍微复杂一些,但是可以在 .NET Core Swagger OData 示例.

If you are using .NET Core, then it gets a little more complex, but a full example can be found at the .NET Core Swagger OData sample.

OpenAPI 是描述 API 的规范;Swagger 是 OpenAPI 标准的实现.您可以在此处找到更多详细信息.

OpenAPI is a specification for describing API's; Swagger is an implementation of the OpenAPI standard. You can find more details here.

我希望这有助于消除任何混淆.

I hope this helps clear up any confusion.

这篇关于什么是 Swagger,它与 OData 有关系吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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