- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我们有一个用 Java 编写的 rest API(托管在 Wildfly 中)。我们的服务在 kubernetes (GKE) 中运行。我们希望利用 Cloud Endpoints 来跟踪 API 的使用情况和响应能力。 API 不是新的,多年来我们一直在发布与之交互的软件。它也相当大(数以千计的公共(public)方法)。我们的 API 有 Swagger 文档,并且没有验证错误。当我尝试使用以下方式部署我们的 Swagger 时:
gcloud beta service-management deploy swagger.yaml
没有成功。我收到以下错误重复 237 次:
ERROR: unknown location: http: body field path 'body' must be a non-repeated message.
我已经追踪到 237 个方法,这些方法在主体参数中包含一个 json 数组。在我们的 API 中,这些是接受或返回对象列表的方法。有什么方法可以让 service-management deploy
接受它?更改我们的 API 不是一个选项,但我们真的希望能够使用端点。
例如这个方法签名:
@PUT
@Path ("/foobars/undelete")
@Consumes (MediaType.APPLICATION_JSON)
@Produces (MediaType.APPLICATION_JSON)
@ApiOperation (value = "Undelete foobars")
@ApiResponses (value =
{
@ApiResponse (
code = 200,
message = "foobars undeleted",
response = FooBar.class,
responseContainer = "List"
) , @ApiResponse (
code = 206,
message = "Not all foobars undeleted",
response = FooBar.class,
responseContainer = "List"
) , @ApiResponse (
code = 410,
message = "Not found"
) , @ApiResponse (
code = 500,
message = "Server Error"
)
})
public Response undeleteFooBars (@ApiParam (value = "FooBar ID List") List<UUID> entityIds)
生成这个 swagger 片段:
"/foobars/undelete":
put:
tags:
- foo
summary: Undelete FooBars
description: ''
operationId: undeleteFooBars
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
description: FooBar ID List
required: false
schema:
type: array
items:
type: string
format: uuid
responses:
'200':
description: Foo Bars undeleted
schema:
type: array
items:
"$ref": "#/definitions/FooBar"
'206':
description: Not all FooBars undeleted
schema:
type: array
items:
"$ref": "#/definitions/FooBar"
'410':
description: Not found
'500':
description: Server Error
最佳答案
我在端点上遇到了完全相同的问题,它似乎认为传递对象数组作为正文参数是无效的。我通过使用一个通用对象和一个体面的描述来解决这个问题。该描述不会以编程方式修复任何问题,但使用通用对象允许 Endpoints 工作,并且该描述向 API 的使用者提供有关预期内容的信息。
parameters:
- in: body
name: body
description: Array of FooBar objects
required: false
schema:
type: object
这似乎是 Endpoints 团队恕我直言的疏忽,因为在正文中使用一组对象非常适合 OpenApi 规范,并且可以与 http://editor.swagger.io/ 等工具一起使用。
编辑:我还应该补充一点,仅使用原始数组作为请求主体或响应主体通常是不好的做法,因为如果在未来,比如计数或分页信息。
如果这是一个现有的 API,而您只是在记录现有的契约(Contract),那么这个解决方案可以完成工作,但如果您正在设计一个新的 API,那么更好的定义是:
parameters:
- in: body
name: body
description: All the FooBar objects
required: false
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/definitions/FooBarResource'
因为这以后可以扩展以添加其他属性,例如
parameters:
- in: body
name: body
description: All the FooBar objects
required: false
schema:
type: object
properties:
count:
type: integer
description: The total count of resources
callbackUrl:
type: string
description: The URL to trigger once creation is complete
items:
type: array
items:
$ref: '#/definitions/FooBarResource'
description: The resources to create
关于google-app-engine - 谷歌云端点主体阵列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43145757/
是否可以进行 Puppet 设置,在其中使用 JClouds 在云上实例化新虚拟机,然后通过 Puppet 定义和实现其配置(软件堆栈)? 或者 Puppet 的本质是否存在某些固有的因素阻碍其在 A
作者:京东零售 郑炳懿 前言: 当今世界,云计算技术在快速发展,不断为我们带来新的应用场景和解决方案。作为一名前端开发者,了解云技术并掌握如何在前端中应用它们是必不可少的。
我在我们的 iOS 通用应用程序中使用核心数据,并希望用户能够将其数据备份到我们的服务器。因此他们可以使用另一台设备登录并将该数据拉取到该设备。有人对此有什么建议吗?我想在服务器上分析数据,以便与我们
我在 Xcode 的验证过程中收到此错误,这让我抓狂。我花了几个小时试图修复它,但找不到解决方案。 我们拥有正确的分发证书、供应配置文件以及我能想到的与此相关的一切。我已经撤销并重建了我所有的项目,但
今天我对一个项目有了一个非常好的想法,不幸的是存在信息/经验障碍。 我基本上想要的是在云中运行游戏并将图像流式传输给用户。 我知道 ec2 可以选择使用 GPU,但它可能有错误的定价模型来满足我的需求
我是 Cloud Firestore 的新手(我们不都是这样吗?)并且我已经使用 Node.js 中的管理 SDK 向我的数据库添加了一些数据。它显示在控制台上,但在文档下显示“此文档不存在,它不会出
我有一个托管在 s3 存储桶上的静态 html 网站。我已经使用 let's encrypt 生成了一个免费的 ssl 证书,并将其导入到 ACM 中。 certbot --manual --serv
我一直在阅读 Cloudfront 文档,我想确保我的计划是合理的。我有一个后端 API,结构为 EC2 HTTP 服务器,内容经常更新(每秒几次更改)。这是我的理解: 我不应该将此 HTTP 服务器
我是一名优秀的程序员,十分优秀!