Skip to content

Add annotation that specify allowed sort properties [DATACMNS-966] #1422

Open
@spring-projects-issues

Description

@spring-projects-issues

Kazuki Shimizu opened DATACMNS-966 and commented

I'll suggest to add annotation that specify allowed sort properties to limit an injection as follow:

@Documented
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface AllowedSortProperties {
	String[] value();
}
@RequestMapping("/accounts")
@RestController
public class AccountsRestController {
    @GetMapping
    public Page<Account> findPage(@AllowedSortProperties({"id", "name"}) Pageable pageable) {
        // ...
    }
}

When an invalid property is detected, i think better it is ignore from sort property.
What do you think for this suggestion ?
I will submit pull request at later.

Thanks.


Affects: 1.12.6 (Hopper SR6)

Referenced from: pull request #190

1 votes, 3 watchers

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions