Swagger は JsonView をサポートしていると思われますが、動作させることができません。
ここに私のバージョンがあります:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.24</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.24</version>
</dependency>
これが私のモデルです:
@JsonView(View.WriteView.class)
LocalDateTime serviceTime;
String location;
String serviceType;
String assignee;
String status;
これが私のコントローラーです:
@ApiOperation(value = "Create a new order")
@PostMapping("/orders")
@ResponseStatus(HttpStatus.CREATED)
@JsonView({View.WriteView.class})
public Order createOrder(@Valid @RequestBody @JsonView(View.WriteView.class) Order order) {
return orderRepository.save(order);
}
入力と出力の両方が機能していません。これが私の闊歩UIです:
また、コードが機能することも確認しました。REST API を呼び出すと 1 つのフィールドのみが返されます。

