Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于@Parameter @ModelAttribute @Valid共同注解所获取的数据,在请求时请求数据格式存在问题 #792

Closed
Astrsea opened this issue May 17, 2024 · 1 comment

Comments

@Astrsea
Copy link

Astrsea commented May 17, 2024

使用依赖版本

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>3.2.4</version>
  <relativePath/> <!-- lookup parent from repository -->
</parent>

<java.version>21</java.version>
<knife4j.version>4.4.0</knife4j.version>
<springdoc-openapi.version>2.4.0</springdoc-openapi.version>

<!-- springdoc-openapi-ui界面 -->
<dependency>
	<groupId>org.springdoc</groupId>
	<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
	<version>${springdoc-openapi.version}</version>
</dependency>

<!-- springdoc-openapi-api接口 -->
<dependency>
	<groupId>org.springdoc</groupId>
	<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
	<version>${springdoc-openapi.version}</version>
</dependency>
<dependency>
	<groupId>com.github.xiaoymin</groupId>
	<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
	<version>${knife4j.version}</version>
</dependency>

请求查询参数实体类

@Schema(title = "系统角色表查询对象")
@EqualsAndHashCode(callSuper = true)
@Data
public class SystemRoleQO extends BasePageQuery<SystemRole>{
    @Schema(title = "系统角色id")
    private String systemRoleId;

    @Schema(title = "系统角色名称")
    private String name;

    @Schema(title = "系统角色描述")
    private String description;
}

请求查询参数实体类父类

@Data
public abstract class BasePageQuery<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    @Min(1)
    @Schema(title = "当前页")
    private Integer pageIndex = 1;

    @Min(1)
    @Max(100)
    @Schema(title = "当前页大小")
    private Integer pageSize = 10;

    @Schema(title = "排序字段")
    @Xss
    private String orderBy;

    @Schema(title = "排序方式")
    private Boolean desc;
}

controller

list(@Parameter(name = "列表查询对象", in = ParameterIn.QUERY) @ModelAttribute @Valid SystemRoleQO systemPermissionQO)

swagger中显示的内容及对应的请求内容
image
image
image

knife4j中显示的内容及对应的请求方式
image
image
image

问题:
会出现以单个对象的形式拼接到查询参数中,并非以单独参数的形式拼接到查询参数中

@Astrsea Astrsea changed the title 对于@Parameter @ModelAttribute @Valid一同注解所获取的数据请求时数据格式存在问题 对于@Parameter @ModelAttribute @Valid共同注解所获取的数据,在请求时请求数据格式存在问题 May 17, 2024
@Astrsea
Copy link
Author

Astrsea commented May 21, 2024

@xiaoymin 这个问题如何解决

@Astrsea Astrsea closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant