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

@ParameterObject support nested parameter objects #590

Closed
luhuiguo opened this issue Apr 21, 2020 · 1 comment · Fixed by #605
Closed

@ParameterObject support nested parameter objects #590

luhuiguo opened this issue Apr 21, 2020 · 1 comment · Fixed by #605

Comments

@luhuiguo
Copy link

luhuiguo commented Apr 21, 2020

When use Jhipster generator entity filtering
https://www.jhipster.tech/entities-filtering/

Parameter object

public class BookCriteria implements Serializable, Criteria {
  private LongFilter id;
  private StringFilter name;
  ......

Inner object

public class StringFilter extends Filter<String> {
    private String contains;
    private String doesNotContain;
    ......
  @GetMapping("/books")
  public ResponseEntity<List<BookDTO>> getBooks(@ParameterObject BookCriteria criteria, @ParameterObject Pageable pageable) {
    log.debug("REST request to get Book by criteria: {}", criteria);
    Page<BookDTO> page = bookQueryService.findByCriteria(criteria, pageable);
    ......

** Springfox
For each entity, you can enable filtering in the entity generator, and after, you can call your /api/my-entity GET endpoint with the following parameters :

For each xyz field
xyz.equals=someValue
To list all the entities, where xyz equals to ‘someValue’
xyz.in=someValue,otherValue
To list all the entities, where xyz equals to ‘someValue’ or ‘otherValue’
xyz.specified=true
To list all the entities, where xyz is not null, specified.
xyz.specified=false
To list all the entities, where xyz is null, unspecified.
If xyz’s type is string:
xyz.contains=something
To list all the entities, where xyz contains ‘something’.
......

** Springdoc @ParameterObject does't support nested parameter objects

id : {
  "equals": 0,
  "notEquals": 0,
  "specified": true,
  "in": [
    0
  ],
  "greaterThan": 0,
  "lessThan": 0,
  "greaterThanOrEqual": 0,
  "lessThanOrEqual": 0,
  "greaterOrEqualThan": {
    "equals": 0,
    "notEquals": 0,
    "specified": true,
    "in": [
      0
    ],
    "greaterThan": 0,
    "lessThan": 0,
    "greaterThanOrEqual": 0,
    "lessThanOrEqual": 0
  },
  "lessOrEqualThan": {
    "equals": 0,
    "notEquals": 0,
    "specified": true,
    "in": [
      0
    ],
    "greaterThan": 0,
    "lessThan": 0,
    "greaterThanOrEqual": 0,
    "lessThanOrEqual": 0
  }
}
@bnasslahsen
Copy link
Contributor

@luhuiguo,

Can you have a look, you this enhancement using the last snapshot and give us your feedback?

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

Successfully merging a pull request may close this issue.

2 participants