问题标签 [swagger-2.0]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
api - 向 Swagger 定义添加实现细节、注释
是否有一种标准方法可以将 API 实现细节和/或注释添加到 Swagger 定义中?
我们使用 Swagger 来定义 API。然而,虽然我们发现它是为 API 使用者定义接口细节的非常好的工具,但我们几乎没有能力为 API 开发人员定义任何实现细节。
想听听其他人如何应对这一挑战。
node.js - 使用严格模式进行 Swagger 验证
我正在使用 swagger-tools 和 Swagger Spec 2.0 来验证我的 Node JS 服务中的请求正文。问题是带有附加属性的 JSON 通过验证,它会影响服务的内部逻辑。有效 JSON 示例:
我要阻止的仍然有效的 JSON 示例:
是否可以使用严格模式来使包含其他属性的请求失败?
swagger - A deterministic version of a JSON schema object
I am trying to use the Swagger Editor to create a custom JSON/YAML for my API. Basically I want to describe a POST request to an endpoint with Accept
and Content-Type
headers and POST-data in the form of JSON as in the following template {"document": "Some text paragraph", "documentType": "text/plain"}
.
This is my swagger.yml file
Swagger editor's error:
Line 59 is where the definitions start, more specifically, json
What am I doing wrong?
spring-mvc - springfox 不返回 api 文档
我正在尝试将 springfox 集成到我现有的 sprint Web 应用程序中我配置了 springfox,Web 应用程序正在正确启动,但没有生成 api 文档
这是springfox配置类
这是bean的创建
以下是控制器
当我尝试获取 api 文档时,它只返回 404。有人可以帮我解决这个问题吗
javascript - 如何在 swagger UI 中添加自定义授权?
在我的一个 Rest API 调用中,我需要添加标题“授权:partner_id:时间戳签名”
其中公司名称是静态字符串,它可以被硬编码,因为 partner_id 是查询参数的一部分,用户输入它并且签名计算为 sha256(secret,password).digest.encode('base64')
我现在如何以及在哪里可以实现此授权,因为我看到只有 api_key,并且在 swagger-ui 中允许基本授权。
java - Swagger 2 接受 xml 而不是 json
我有一个带有 spring boot 的项目,我想使用 swagger2 来记录我的 json web 服务。
我有这个配置:
要阅读文档,我使用此链接:http://localhost:9081/v2/api-docs
在招摇的用户界面中,它工作正常。但是当我直接在浏览器中尝试这个链接时,我有这个错误:
使用 Firebug,我看到它接受 XML 内容而不是 JSON 内容。
如何修改招摇配置以接受 JSON 内容?
api - How can I specify that an object's type is one of several possible object types?
I have an API where I post a set of object to the server, differentiated by type, where each type has some different parameters. The commands are structured like so:
For example, these may be two possible commands:
How can I specify this in Swagger? I can specify an enum
for "type"
, but how do I say ""args"
is one of these possible objects"?
I've checked out the docs but nothing stands out. The most promising one was allOf
because it displayed nicely in the editor (pastebin, paste into the online editor):
Which looks like this:
However, this isn't semantically what I need, and, not surprisingly, in the online viewer (that one's not set up for my test case, not sure how to link up a local file easily), they are presented as if all the fields appear at the same time, which is of course what allOf
means:
What's the proper way to represent this with Swagger?