小编use*_*759的帖子

如何在BigDecimal(Java)中存储无穷大?

我在返回BigDecimal值的方法中编写算法,但现在计算的结果将是+或 - 无穷大.
而不是程序崩溃我想捕获异常并返回无穷大作为一个值,如果该方法返回双精度的方式.

例如Double.POSITIVE_INFINITY;

那么如何在BigDecimal中存储无穷大?还是有另一种方法吗?

public static BigDecimal myalgorithm(){

//code to store infinity in a BigDecimal
//return the BigDecimal holding infinity 

}
Run Code Online (Sandbox Code Playgroud)

java algorithm exception bigdecimal infinity

12
推荐指数
1
解决办法
6093
查看次数

Swagger UI 未显示具有相同路径但不同 HTTP 方法的操作

例如我有 2 个 API 操作:

获取 v1/people/{id}

发布 v1/people/{id}

我的 Swagger UI API 文档中仅显示了这些操作之一,但我希望同时显示这两个操作。我有很多这样的例子。Swagger 文档中指出:

Swagger 将独特的操作定义为路径和 HTTP 方法的组合。

这会让我觉得我想做的事情是可能的,因为它们是由 HTTP 方法唯一标识的。

如果我更改 swagger.yaml 文件中的一个路径参数,它们都会显示。例如:

获取 v1/people/{personid}

发布 v1/people/{id}

但我宁愿保持它们都是标准的,否则我的 API 文档会显得混乱。

我正在使用 swagger-ui-express 4.1.4。

/v1/people/{id}:
get:
  summary: Get people.
  security:
    - cookieAuth: []
  tags:
    - People
  parameters:
    - in: path
      name: id
      required: true
      schema:
        type : integer
        example: 123
  responses: 
    '200':
      description: OK



/v1/people/{id}:
    post:
      summary: Get people.
      security:
        - cookieAuth: []
      tags:
        - People
      parameters: …
Run Code Online (Sandbox Code Playgroud)

node.js swagger swagger-ui

1
推荐指数
1
解决办法
5324
查看次数