我正在使用带有 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) 我想做这样的事情:
increase without (filename) (rejected_files_total[10h])
Run Code Online (Sandbox Code Playgroud)
但我收到下一个错误:
执行查询时出错:参数“查询”无效:1:10:解析错误:意外
“without”和“by”只能用于聚合运算符吗?如果是这样,还有其他方法可以在增加功能的情况下获得不带效果的效果吗?
我有 2 个日期:
LocalDate date1 = LocalDate.now().minusDays(40);
LocalDate date2 = LocalDate.now();
Run Code Online (Sandbox Code Playgroud)
我想弄清楚我可以选择的最大时间单位是什么来定义两者之间的差异(天、月、年),并获取它的数字。我认为,对我来说完美的解决方案是 if Durationapi java.timehad alsotoMonthsPart和toYearsPartas 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中并没有这样的方法。是否有另一个包可以提供此功能,或者您知道实现我的目标的不同方法吗?
date ×1
duration ×1
java ×1
java-time ×1
localdate ×1
openapi ×1
polymorphism ×1
prometheus ×1
promql ×1
swagger ×1