There are two minor issues with the AccountResource.java:
saveAccount uses @PostMapping("/account") wherein it should be using @PutMapping("/account") as per the REST API convention.registerAccount(...), shouldn't we change the URI from @PostMapping("/register") to @PostMapping("/account") to make it adhere to the REST API convention?Using JHipster version installed globally
Executing jhipster:info
Options:
Welcome to the JHipster Information Sub-Generator
[email protected] E:\workspace\sts_workspace\CalorieCounterBackend
`-- (empty)
##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.example",
"nativeLanguage": "en"
},
"jhipsterVersion": "4.14.3",
"baseName": "CalorieCounterBackend",
"packageName": "com.example",
"packageFolder": "com/example",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "no",
"enableHibernateCache": false,
"websocket": false,
"databaseType": "mongodb",
"devDatabaseType": "mongodb",
"prodDatabaseType": "mongodb",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"enableSwaggerCodegen": false,
"jwtSecretKey": "replaced-by-jhipster-info",
"enableTranslation": true,
"applicationType": "monolith",
"testFrameworks": [],
"jhiPrefix": "jhi",
"nativeLanguage": "en",
"languages": [
"en",
"de"
],
"clientPackageManager": "yarn",
"skipClient": true
}
}
entityName.json files generated in the .jhipster directory
JDL entity definitions
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) Client VM (build 25.172-b11, mixed mode, sharing)
git version 2.12.2.windows.2
node: v8.11.4
npm: 6.4.0
yarn: 1.3.2
Docker version 18.03.0-ce, build 0520e24302
docker-compose version 1.20.1, build 5d8c71b2
While we're at it, /account should be changed by /accounts and the user account could be on /accounts/me
It will be a breaking change for our users who want to upgrade the application ?
Indeed, breaking it is.
Then we shouldn't break all apps with a minor release... This isn't urgent as nobody noticed it yet, so let's postpone this until our next major release -> sorry @yatendragoel you are correct, but this isn't the right time to do this.
@jdubois @cbornet Another related thing is, we should have all the Resource classes contain proper class-level @RequestMapping. That will be helpful in even avoiding the bugs similar to the one reported in this issue. Also, we won't need to duplicate the same URL again and again in the method-level @RequestMapping
e.g.
AccountResources class-level request mapping @RequestMapping("/api") should be changed to @RequestMapping("/api/accounts")UserResources class-level request mapping @RequestMapping("/api") should be changed to @RequestMapping("/api/users")By doing so, all the endpoints within that Resource will automatically inherit the class level prefix-uri such as /api/accounts or api/users and will make them adhere to the REST API URI conventions automatically.
Adding few things to be taken care of whenever this issue gets picked up for implementation:
When we will be updating the URIs of createAccount (registerAccount(...)) and updateAccount (saveAccount(...)) endpoints, the end result would be the same URI i.e. .../accounts for both of them with different HTTP methods. So we will need to update the SecurityConfiguration.java as well as follows:
from: .antMatchers("/api/register").permitAll()
to: .antMatchers(HttpMethod.POST, "/api/accounts").permitAll()
because we would want only the createAccount to be unauthenticated but not the updateAccount
Thansk @yatendragoel for the added comments.
Most helpful comment
While we're at it,
/accountshould be changed by/accountsand the user account could be on/accounts/me