小编Tom*_*rmi的帖子

使用 oneOf 时未生成 OpenAPI 模型

我正在使用带有 Spring Boot 的 OpenAPI+OpenAPI-generator,并尝试使用oneof如下架构:

这是 requests.yaml 文件中的配置:

...

requestBody:
 name: request
 required: true
 content:
   application/json:
     schema:
       oneOf:
         - $ref: 'components.yaml#/Request'
         - $ref: 'components.yaml#/ComplexRequest'

...
Run Code Online (Sandbox Code Playgroud)

这是 Components.yaml 文件中的相关配置:

Request:
  allOf:
    - $ref: '#/BaseInfo'
    - type: object
      properties:
        should_create:
          type: boolean
          enum: [ false ]
        reference_id:
          type: string
        required:
          - reference_id

ComplexRequest:
  allOf:
    - $ref: '#/BaseInfo'
    - type: object
      properties:
        should_create:
          type: boolean
          enum: [ true ]
        create_data:
          $ref: '#/Reference'
      required:
        - create_data

BaseInfo:
  type: object
  properties:
    customer_id:
      type: …
Run Code Online (Sandbox Code Playgroud)

polymorphism swagger openapi openapi-generator

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

是否可以在PromQL中使用没有标签的increase()函数?

我想做这样的事情:

increase without (filename) (rejected_files_total[10h])
Run Code Online (Sandbox Code Playgroud)

但我收到下一个错误:

执行查询时出错:参数“查询”无效:1:10:解析错误:意外

“without”和“by”只能用于聚合运算符吗?如果是这样,还有其他方法可以在增加功能的情况下获得不带效果的效果吗?

prometheus promql

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

定义具有整数的日期差的最大时间单位

我有 2 个日期:

LocalDate date1 = LocalDate.now().minusDays(40);
LocalDate date2 = LocalDate.now();
Run Code Online (Sandbox Code Playgroud)

我想弄清楚我可以选择的最大时间单位是什么来定义两者之间的差异(天、月、年),并获取它的数字。我认为,对我来说完美的解决方案是 if Durationapi java.timehad alsotoMonthsParttoYearsPartas it has toDaysPart. 这样我就可以这样做:

Duration dif = Duration.between(date1, date2);

long daysPart = dif.toDaysPart();
if (daysPart > 0) {
    return ChronoUnit.DAYS.between(date1, date2);
}

long monthPart = dif.getMonthsPart();
if (monthPart > 0) {
    return ChronoUnit.MONTHS.between(date1, date2);
}

long yearPart = dif.getYearsPart();
if (yearPart > 0) {
    return ChronoUnit.YEARS.between(date1, date2);
}

throw new Exception("no difference");
Run Code Online (Sandbox Code Playgroud)

但API中并没有这样的方法。是否有另一个包可以提供此功能,或者您知道实现我的目标的不同方法吗?

java duration date java-time localdate

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