I am migrating from Swagger 2.x to OpenAPI 3.0 and encountered some sort of troubles: I was using ApiModel with ApiModelProperties to show dto fields as parameters to a method, but now it only shows up as a JSON object with no field descriptions. Now it looks like: But i want it:
@RequestMapping("/smth")
@RequiredArgsConstructor
@RestController
public class Controller {
@GetMapping
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "Filtered values")
public List<GD> findAll(Parameter(explode = Explode.TRUE) final PageFilter pageFilter) {
return baseAdapter.findAll(pageFilter);
}
Dto:
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@Schema(type = "object")
public class PageFilter {
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)
private static final String DELIMITER = ";";
@Schema(
name = "page",
description = "Results page you want to retrieve (0..N)",
example = DEFAULT_PAGE_STRING,
type = "integer")
private Integer page;
@Schema(
description = "Number of records per page",
example = DEFAULT_SIZE_STRING,
type = "integer")
private Integer size;
@Schema(
description =
"Sorting criteria in the format: property(propertyName;asc|desc). "
+ "Default sort order is ascending. Multiple sort criteria are supported.")
private String[] sort;
}
Add:
@Parameter
annotation on the fields of your Dto object, and@ParameterObject
annotation on your controller's parameterCredit to @Shamil Mukhetdinov for the fix! (the answer is in the comments of the issue.)