我通过swagger编辑器手动创建了YAML文件(和JSON文件).
现在我想将来自swagger-editor工具的酷炫自动生成页面嵌入到我的网站中,这样用户就可以通过我的API实时阅读和测试它(通过"尝试此操作"按钮).
我不想让swagger为我生成任何代码,我也不需要它自动更新文档(YAML或其他).每当我需要时,我都会手动更新我的静态YAML/JSON文件.招摇是否支持这种功能?它是否与swagger编辑器工具栏中的"生成客户端"相关?我正在寻找一些可以加载静态YAML文件的html/js/css文件,并生成类似于swagger-editor右侧页面的内容.顺便说一下,我正在使用Apache Web服务器(并不重要).
谢谢!
编辑:我只是寻找客户端 - 一些可以添加上述要求的js/css/html,我不介意不时再次生成它(每当我改变我的YAML文件/我的REST API时)
Swagger 2.0是否支持JAX-RS规范的矩阵参数?
我的应用程序中存在一些矩阵参数,例如/map/color;lat=50;long=20;scale=32000. 我想为矩阵参数导出 Swagger。我使用http://editor.swagger.io;但我无法在编辑器中得到任何帮助。谁能帮我?
Swagger 2.0支持矩阵参数吗?
与矩阵参数相关的其他链接:
我想记录和测试一个API,它在http://editor.swagger.io/中使用基于Cookie的认证.举一个简单的例子:如何在下面的YAML中编写,/ login操作创建一个Cookie并且Cookie必须传递给/ showMySecretStuff?
swagger: '2.0'
info:
title: Test API
version: '1'
host: my.test.com
schemes:
- https
basePath: /
consumes:
- multipart/form-data
produces:
- application/json
paths:
/login:
post:
parameters:
- name: username
in: formData
required: true
type: string
- name: password
in: formData
required: true
type: string
default: secret
responses:
200:
description: OK
/showMySecretStuff:
get:
responses:
200:
description: OK
Run Code Online (Sandbox Code Playgroud) 我是Swagger的新手,并使用在本地桌面上运行的Swagger编辑器来测试API。我不负责服务器配置,也无权进行更改。我已经设置了安全性定义,并且可以进行授权。现在,我正在尝试设置我的第一个路径架构,但是当我执行它时,我收到一条错误消息,提示“ TypeError:无法获取”,并且“响应标头”字段为空。
但是,当我复制Swagger Editor提供的Curl请求并在GitBash中运行它时,它将返回我期望的值。因此,我知道Swagger编辑器已经创建了一个工作请求。
我知道我的安全授权正在起作用,因为我可以在Curl请求中看到它返回的令牌。
身份验证架构和路径架构都命中不同的子域。身份验证由betaauthorize.myDomain.com处理,而路径由betaapi.myDoamin.com处理。
同样,我从桌面硬盘驱动器运行Swagger Editor。我缺少某种Swagger Editor配置设置吗?我需要让服务器管理员意识到服务器配置问题吗?我已经尝试了两天,但我全都没主意。任何建议,将不胜感激。
我想在我的API描述中放一个Markdown代码块,但是Swagger UI似乎正在读取,好像它是一个单行代码片段一样。我目前有:
description: |
This API was created to allow interaction with the Image Status Database (ISD)
## Requests
## Responses
In the case of a successful response, you will always receive a `data` key
that contains your data.
```
{
"meta": {
"code": 200
},
"data": {
...
},
"pagination": {
"next_url": "...",
"next_max_id": "13872296"
}
}
```
Run Code Online (Sandbox Code Playgroud)
显示为:
但是,Swagger编辑器显示正确的代码块:
Swagger UI不支持此功能吗?
是否有适用于Vert.x的基于注释的Swagger文档创建器?其余的端点都是使用路由器管理的,因此如果有任何方法可以生成Swagger文档,那就太棒了.我使用各种注释完成了基于Java Jersey的文档创建器,但找不到Vert.x文档的任何内容.Git Hub上的官方招摇wiki也没有任何与Vert.x文档相关的文档.
这是我在 Swagger 编辑器在线查看的 OpenAPI 3.0 定义的简化版本。我试图获得错误代码 401 和 403 的两个响应,它们共享相同的架构,显示不同的示例 - 这似乎不起作用,我仍然看到引用的类型作为示例。
您能帮我找出这些定义有什么问题吗?
openapi: 3.0.0
info:
version: '1.0'
title: A service
paths:
/doSomething:
post:
requestBody:
content:
application/json:
schema:
type: string
example: A string
responses:
401:
$ref: '#/components/responses/Unauthorized'
403:
$ref: '#/components/responses/Denied'
components:
responses:
Unauthorized:
description: The endpoint cannot be reached because the request is not authorized
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: unauthorized
Denied:
description: The request's authorizations don't match the required ones needed to access the resource
content:
application/json: …Run Code Online (Sandbox Code Playgroud) 我正在为需要非常详细和干净的文档的未来公共 API 编写 Swagger 规范。有没有办法在swagger.yml文件中的其他位置引用/链接/指向另一个端点?
例如,这是我想要实现的目标:
paths:
/my/endpoint:
post:
tags:
- Some tag
summary: Do things
description: >
This endpoint does things.
See /my/otherEndpoint for stuff # Here I would like to have some kind of hyperlink
operationId: doThings
consumes:
- application/json
produces:
- application/json
parameters:
...
responses:
...
/my/otherEndpoint: # This is the endpoint to be referenced to
get:
...
Run Code Online (Sandbox Code Playgroud)
我发现这$ref无济于事,因为它只是用引用的内容替换了自己。
Swagger 可以做这样的事情吗?
我想将Swagger UI和Swagger编辑器插入我的Angular项目中。这样它将看起来像这样:http : //editor.swagger.io/?docExpansion=none
由于以下说明,我已经能够将Swagger UI添加到我的Angular项目中:https : //github.com/agoncal/swagger-ui-angular6
仍然缺少Swagger编辑器,用户可以在其中编辑OpenAPI规范(请参阅第一个链接的左侧)。
我的应用程序的目标状态应该是:已加载OpenAPI规范,然后用户对API有了直观的了解,并且还应该能够通过Swagger编辑器(缺少部分)来编辑此API。因此,第一个链接的功能差不多。
所以我的问题是,如何在Angular项目中实现Swagger编辑器?我没有在互联网上找到任何有关它的信息。
我在 openapi 中呈现示例请求正文时遇到问题。我已经把它提炼成这个简单的例子:
openapi: 3.0.2
info:
title: Test
version: "1"
paths:
/Users:
post:
requestBody:
content:
application/json:
example:
name: "John"
responses:
"200":
description: Fetches them
content:
application/json:
example:
- name: John Doe
Run Code Online (Sandbox Code Playgroud)
https://editor.swagger.io/#和其他一些工具似乎无法呈现请求正文。我得到的是:
Could not render n, see the console.
虽然,响应正文按预期呈现得很好。
我在这里做错了什么
swagger-editor ×10
swagger ×8
swagger-2.0 ×4
swagger-ui ×4
openapi ×3
yaml ×2
angular ×1
cookies ×1
vert.x ×1