Generator-jhipster: queryParams mandatory

Created on 30 Jun 2019  ·  6Comments  ·  Source: jhipster/generator-jhipster

Overview of the issue

When creating an entity with the JPA static metamodel, the entry point for the queryParams is mandatory but is should not be.

Motivation for or Use Case
Reproduce the error

With JHipster 6.1.2, create a monoloth and a simple entity with JPA static metamodel.
The queryParams is then mandatory.
image

Related issues
Suggest a Fix

In the web resource, the RequestParam should have (required = false) like this:

public ResponseEntity<List<BookDTO>> getAllBooks(BookCriteria criteria, Pageable pageable, @RequestParam(required = false) MultiValueMap<String, String> queryParams, UriComponentsBuilder uriBuilder) {
JHipster Version(s)

6.1.2

JHipster configuration
##### **JHipster Version(s)**

[email protected] /home/djay/Work/01_PROJECTS/10_JHIPSTER/paging
└── [email protected]



##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**


<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "io.goovy.sampleapp"
    },
    "jhipsterVersion": "6.1.2",
    "applicationType": "monolith",
    "baseName": "paging",
    "packageName": "io.goovy.sampleapp",
    "packageFolder": "io/goovy/sampleapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "darkly",
    "clientThemeVariant": "dark",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": false
  }
}
</pre>
</details>


##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>
entity Book {
  name String,
  author String,
  release LocalDate
}
dto Book with mapstruct
paginate Book with pagination
service Book with serviceImpl
filter Book

</pre>
</details>


##### **Environment and Tools**

java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

git version 2.22.0

node: v12.2.0

npm: 6.9.0

yarn: 1.16.0

Docker version 18.09.6-ce, build 481bc77156

docker-compose version 1.24.0, build unknown


Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System
  • [x ] Checking this box is mandatory (this is just to show you read everything)
area api

All 6 comments

I confirm the issue, I encountered it recently too.

It's related to pagination, not jpaFiltering and exists since https://github.com/jhipster/generator-jhipster/commit/7aa4120f098ba6f70c0fa493f80b968f5cf3ee4e and https://github.com/jhipster/jhipster/commit/b73fe65338c59f7027f142463eab70d105f52df5#diff-8ccd0377d0ab17e7d2b1a14d1414d458

@cbornet : since queryParams is not an actual parameter, it should not even appear in Swagger. Maybe it would be better to use HttpServletRequest request again in the method controller. WDYT?

@pascalgrimaud : this is not an enhancement but a bug. The REST api entry point ask for a mandatory queryParams field which was not the case before and should not be. Can you please review the tags?

@GeCol1 : done ! Thanks for that :)

I think a @ApiIgnore annotation on queryParams should fix that.

@cbornet and why not a required=false ?
@RequestParam(required = false) MultiValueMap<String, String> queryParams

because this is just wrong to do @RequestParam(required = false) MultiValueMap<String, String> queryParams
there is criteria, DTO, VM for something and not to go back to MultiValueMap

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trajakovic picture trajakovic  ·  4Comments

kaidohallik picture kaidohallik  ·  3Comments

tomj0101 picture tomj0101  ·  3Comments

ahmedeldeeb25 picture ahmedeldeeb25  ·  3Comments

SudharakaP picture SudharakaP  ·  3Comments