java - 如何在 Swagger Codegen 生成的 jaxrs-cxf-client 中读取响应的 HTTP 状态?
问题描述
我正在使用通过 SwaggerHub 上的 OpenAPI 指定的 REST API 的客户端。在这里,我读到了这样的内容:
put:
tags:
- load
summary: adds a Demand item
operationId: addDemandItem
description: Adds a Demand item to the system
security:
- basicAuth: []
responses:
'200':
description: item correctly saved
'401':
description: 'unauthorized'
'400':
description: 'invalid input, object invalid'
parameters:
- in: path
name: partnerReferenceId
schema:
type: string
required: true
description: partnerReferenceId identifying the demand
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DemandItem'
description: Demand item to add
自动生成的客户端 (jaxrs-cxf-client) 具有以下 Java 代码:
@PUT
@Path(value = "/demands/{partnerReferenceId}")
@Consumes(value = {"application/json"})
@Operation(summary = "adds a Demand item", tags = {})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "item correctly saved"),
@ApiResponse(responseCode = "400", description = "invalid input, object invalid"),
@ApiResponse(responseCode = "401", description = "unauthorized")})
public void addDemandItem(@PathParam(value = "partnerReferenceId") String string, DemandItem di);
如何读取响应的 HTTP 状态?
解决方案
推荐阅读
- scala - 适用于 RDD 和 Seq 的通用方法
- jquery - jQuery Animate - 恢复到原始大小
- bash - 从 bash 脚本中运行时,flake8 的行为不同
- node.js - setTimeouts 并不总是适用于 node.js discord bot
- sql - 如何在 SQL Server 中将数据从 prod 服务器插入到 dev 服务器
- python - 动态规划,最小硬币数量
- java - Android 权限 ACCESS_FINE_LOCATION 始终被拒绝
- ios - MapBox 用户位置图标 | iOS
- javascript - 获取当前 tbody 下方的 tbody
- java - 将一些 JSON 从 php 解析到 android 时出现问题