假设我有一个类似的参数limit
.这个地方到处都是用的,如果我需要更新它,就必须在任何地方进行更改:
parameters:
- name: limit
in: query
description: Limits the number of returned results
required: false
type: number
format: int32
Run Code Online (Sandbox Code Playgroud)
我可以使用$ ref在别处定义它并使其可重用吗?我遇到了这张票,暗示有人想改变或改进功能,但我不知道它是否已经存在于今天?
我使用Swagger来记录我的REST服务.我的一项服务需要上传CSV文件.在JSON文件中为参数部分指定以下属性后,我可以在我的招摇页面上获取文件上载选项.
{
"name": "File",
"description": "The file in zip format.",
"paramType": "body",
"required": true,
"allowMultiple": false,
"dataType": "file"
}
Run Code Online (Sandbox Code Playgroud)
但是当我选择一个文件然后点击我收到错误NS_ERROR_XPC_BAD_OP_ON_WN_PROTO:在jquery-1.8.0.min.js(第2行)中对WrappedNative原型对象进行非法操作时,它会不断处理,我没有得到任何响应.
是否有将 OpenAPI 3.0 转换为 Swagger 2.0 的生成器?
Mashery 是一个 API 网关,在打开端点的输入上需要 Swagger 2.0 格式。
我有一个POST请求,它使用以下JSON请求体.如何使用OpenAPI(Swagger)描述此请求体?
{
"testapi": {
"testapiContext": {
"messageId": "kkkk8",
"messageDateTime": "2014-08-17T14:07:30+0530"
},
"testapiBody": {
"cameraServiceRq": {
"osType": "android",
"deviceType": "samsung555"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我尝试了以下内容,但我仍然坚持定义身体schema
.
swagger: "2.0"
info:
version: 1.0.0
title: get camera
license:
name: MIT
host: localhost
basePath: /test/service
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/getCameraParameters:
post:
summary: Create new parameters
operationId: createnew
consumes:
- application/json
- application/xml
produces:
- application/json
- application/xml
parameters:
- name: pet
in: body
description: The pet JSON you …
Run Code Online (Sandbox Code Playgroud) 我熟悉Microsoft堆栈.我正在使用OData来完成我的一些宁静服务.最近我遇到了Swagger的API文档,我试图了解它与OData的关系.它们似乎都是RESTful规范.哪一个被广泛使用?
我在Swagger中有一系列参数
"parameters": [
{
"name": "username",
"description": "Fetch username by username/email",
"required": false,
"type": "string",
"paramType": "query"
},
{
"name": "site",
"description": "Fetch username by site",
"required": false,
"type": "string",
"paramType": "query"
},
{
"name": "survey",
"description": "Fetch username by survey",
"required": false,
"type": "string",
"paramType": "query"
}
],
Run Code Online (Sandbox Code Playgroud)
必须填写一个参数但是哪个参数无关紧要,其他参数可以留空.有没有办法在Swagger中表现出来?
我正在设计一个 API,我想定义一个枚举严重性,其值可以为低、中或高。在内部,严重性存储为整数,因此我想将它们分别映射到 2,1 和 0。有没有办法在 OpenAPI 定义中做到这一点?这就是我目前的严重性:
severity:
type: string
enum:
- HIGH
- MEDIUM
- LOW
Run Code Online (Sandbox Code Playgroud) 我有JSON模式文件,其中一个属性被定义为string
或null
:
"type":["string", "null"]
Run Code Online (Sandbox Code Playgroud)
转换为YAML(与OpenAPI/Swagger一起使用)时,它变为:
type:
- 'null'
- string
Run Code Online (Sandbox Code Playgroud)
但Swagger编辑器显示错误:
架构"类型"键必须是字符串
在OpenAPI中定义可空属性的正确方法是什么?
我目前在 NestJS 项目中使用 Swagger,并且启用了资源管理器:
在 main.js
const options = new DocumentBuilder()
.setTitle('My App')
.setSchemes('https')
.setDescription('My App API documentation')
.setVersion('1.0')
.build()
const document = SwaggerModule.createDocument(app, options)
SwaggerModule.setup('docs', app, document, {
customSiteTitle: 'My App documentation',
})
Run Code Online (Sandbox Code Playgroud)
有了这个,资源管理器可以访问,/docs
这是我所期望的。但我想知道是否可以向资源管理器添加任何身份验证层,因此只接受某些请求。
我想让这个资源管理器在生产中可以访问,但仅限于经过身份验证的用户。
提前致谢 :)
https://www.dariawan.com/tutorials/spring/documenting-spring-boot-rest-api-springdoc-openapi-3/
试图遵循这些
我如何处理像这样的注释
@ApiModel(value = "Response container")
@ApiModelProperty(value = "Iventory response", required = true)
Run Code Online (Sandbox Code Playgroud) openapi ×10
swagger ×7
swagger-2.0 ×3
swagger-ui ×3
enums ×1
mashery ×1
nestjs ×1
odata ×1
springdoc ×1
swashbuckle ×1
typescript ×1