{"activeVersionTag":"latest","latestAvailableVersionTag":"latest","collection":{"info":{"_postman_id":"f7a6c695-811c-41aa-a06e-6f392c4f047c","name":"Spring Lemon 1.0","description":"This is the API documentation of the _Spring Lemon Demo Application_, which shows how to easily develop a production grade REST Service with a full-featured user module by using the [Spring Lemon](https://github.com/naturalprogrammer/spring-lemon) open source library.\n\nBefore you dive in, let’s first look at a few key thing to keep in mind when using the API.\n\nCORS\n====\nYour API could be accessed from multiple clients. One of those could be a JavaScript web front-end, such as an AngularJS single page application.\n\nWhen developing a JavaScript web front-end, you will have two choices:\n\n1. Put it in the same project, say inside _src/main/resources/static_, and deploy both the server and the client as a single unit.\n1. Keep it separate, say as a Grunt/Gulp project, and deploy it in a different domain. For example, your API could be hosted at example.cfapps.io, whereas your AngularJS application could be hosted at www.example.com.\n\nIf you go for the second option, your JavaScript can’t call your API unless you deal with the [same origin policy](https://en.wikipedia.org/wiki/Same-origin_policy).\n\nSpring Lemon uses CORS at the server side to deal with this. You just have to add a line like this in _application.properties_:\n\n```\nlemon.cors.allowed-origins: http://localhost:9000,http://www.example.com\n```\n\nYou may also need a little configuration at the client side. For example, in AngularJS, you will need to set the withCredentials flag of [$http](https://docs.angularjs.org/api/ng/service/$http#cross-site-request-forgery-xsrf-protection) service, like this:\n\n```\nangular.module('myApp', ['ngCookies', ... ])\n.config(['$httpProvider', function ($httpProvider) {\n\n    $httpProvider.defaults.withCredentials = true;\n    ...\n}]);\n```\n\nRefer [documentation and resources](https://github.com/naturalprogrammer/spring-lemon#documentation-and-resources) for more details.\n\nHandling Errors\n===============\nIf some request data would not comply to the business rules, the API would respond with _422 Unprocessable Entity_, with a JSON body holding field-wise error details. For example, trying to sign up with some invalid data could produce the following JSON data:\n```\n{\n  \"exception\": \"ConstraintViolationException\",\n  \"error\": \"Unprocessable Entity\",\n  \"message\": \"Validation Error\",\n  \"status\": 422,\n  \"errors\": [\n    {\n      \"field\": \"user.email\",\n      \"code\": \"{com.naturalprogrammer.spring.invalid.email}\",\n      \"message\": \"Not a well formed email address\"\n    },\n    {\n      \"field\": \"user.password\",\n      \"code\": \"{com.naturalprogrammer.spring.invalid.password.size}\",\n      \"message\": \"Password must be between 6 and 50 characters\"\n    },\n    {\n      \"field\": \"user.name\",\n      \"code\": \"{blank.name}\",\n      \"message\": \"Name required\"\n    },\n    {\n      \"field\": \"user.email\",\n      \"code\": \"{com.naturalprogrammer.spring.invalid.email.size}\",\n      \"message\": \"Email must be between 4 and 250 characters\"\n    }\n  ]\n}\n```\nEach error in errors above will have three fields:\n\n* *field*: Name of the field, or null in case of a form level error.\n* *code*: The error code.\n* *message*: An internationalized message, which could vary depending on the locale of the user.\n\nCommon terms\n============\nSome terms that we would be using often in the documentation are given below.\n\n<dl>\n  <dt>ADMIN</dt>\n  <dd>A user having \"ADMIN\" in his roles collection.</dd>\n\n  <dt>Unverified user</dt>\n  <dd>A user having \"UNVERIFIED\" in his roles collection.</dd>\n\n  <dt>Blocked user</dt>\n  <dd>A user having \"BLOCKED\" in his roles collection.</dd>\n  \n  <dt>Bad user</dt>\n  <dd>An unverified or blocked user.</dd>\n\n  <dt>Good user</dt>\n  <dd>A user who is not bad.</dd>\n\n  <dt>Bad ADMIN</dt>\n  <dd>An ADMIN who is a bad user.</dd>\n  \n  <dt>Good ADMIN</dt>\n  <dd>An ADMIN who is a good user.</dd>\n</dl>\n\nCommon Business Rules\n=====================\nThis section documents the common business rules, which are referred at multiple places in the API documentation.\n\n### Accessing Users\n\n#### Who is permitted to edit a User entity\n##### Editing the fields\nA user can be edited either by himself or a good ADMIN.\n\n##### Adding or removing roles\n1. roles can only be edited by good ADMINs.\n1. A user can’t edit his own roles even if he is a good ADMIN.\n\n#### Confidential fields\nWhen fetching a user (either by email or id), _password_ is not returned. _email_ is returned if the logged in user does not have right to edit the fields (see above) of the user being fetched.\n\n### User entity validation constraints\n\n#### email\n1. Should not be null\n1. Should not be blank\n1. Should be between 4 and 250 characters long\n1. Should be well-formed email format\n1. Should be unique\n\n#### password\n1. Should not be null\n1. Should not be blank\n1. Should be between 4 and 50 characters long\n\n#### name\n1. Should not be blank\n1. Should be between 1 and 50 characters long\n","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","isPublicCollection":false,"owner":"305915","team":4765336,"collectionId":"f7a6c695-811c-41aa-a06e-6f392c4f047c","publishedId":"RVu2mqEH","public":true,"publicUrl":"https://documenter-api.postman.tech/view/305915/RVu2mqEH","privateUrl":"https://go.postman.co/documentation/305915-f7a6c695-811c-41aa-a06e-6f392c4f047c","customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"documentationLayout":"classic-double-column","version":"8.10.1","publishDate":"2018-04-04T11:35:41.000Z","activeVersionTag":"latest","documentationTheme":"light","metaTags":{},"logos":{}},"statusCode":200},"environments":[{"name":"Spring Lemon Local Documentation","id":"5117dcc8-5f3f-4bb8-bc81-786b8691d897","owner":"305915","values":[{"type":"text","enabled":true,"key":"lemonDemoUrl","value":"http://localhost:8080"},{"type":"text","enabled":true,"key":"userAuthHeader","value":"Bearer eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiZGlyIn0..U8Hz1wGgzFDpXP1e4D0WaA.Pl1cWtkhWCKy__L5zRU3efQwnxG3_sTALrp6iyh9Oc0qwHU2iIt3AlgtbombOn14msyuRn2IJm-SXfNQ-4Zomvux-kUJGdNKaYAODAU5j9yDDP3v98fW3KYNxzbFDJBr.sraeDLzaqq4xqDAffuNSTQ"},{"type":"text","enabled":true,"key":"userId","value":"2"},{"type":"text","enabled":true,"key":"registeredEmail","value":"skpatel20+lemon7441029@example.com"},{"type":"text","enabled":true,"key":"userEmail","value":"skpatel20+changedlemon6524790@example.com"},{"type":"text","enabled":true,"key":"userVersion","value":"2"},{"type":"text","enabled":true,"key":"newEmail","value":"skpatel20+changedlemon6524790@example.com"}],"published":true}],"user":{"authenticated":false,"permissions":{"publish":false}},"run":{"button":{"js":"https://run.pstmn.io/button.js","css":"https://run.pstmn.io/button.css"}},"web":"https://www.getpostman.com/","team":{"logo":"https://res.cloudinary.com/postman/image/upload/t_team_logo_pubdoc/v1/team/22330326ac5e0ee30bcf53aa25b43d94e6b733d071faf613f5fa9e34c0f515b5","favicon":""},"isEnvFetchError":false,"languages":"[{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"HttpClient\"},{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"RestSharp\"},{\"key\":\"curl\",\"label\":\"cURL\",\"variant\":\"cURL\"},{\"key\":\"dart\",\"label\":\"Dart\",\"variant\":\"http\"},{\"key\":\"go\",\"label\":\"Go\",\"variant\":\"Native\"},{\"key\":\"http\",\"label\":\"HTTP\",\"variant\":\"HTTP\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"OkHttp\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"Unirest\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"Fetch\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"jQuery\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"XHR\"},{\"key\":\"c\",\"label\":\"C\",\"variant\":\"libcurl\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Axios\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Native\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Request\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Unirest\"},{\"key\":\"objective-c\",\"label\":\"Objective-C\",\"variant\":\"NSURLSession\"},{\"key\":\"ocaml\",\"label\":\"OCaml\",\"variant\":\"Cohttp\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"cURL\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"Guzzle\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"HTTP_Request2\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"pecl_http\"},{\"key\":\"powershell\",\"label\":\"PowerShell\",\"variant\":\"RestMethod\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"http.client\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"Requests\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"httr\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"RCurl\"},{\"key\":\"ruby\",\"label\":\"Ruby\",\"variant\":\"Net::HTTP\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"Httpie\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"wget\"},{\"key\":\"swift\",\"label\":\"Swift\",\"variant\":\"URLSession\"}]","languageSettings":[{"key":"csharp","label":"C#","variant":"HttpClient"},{"key":"csharp","label":"C#","variant":"RestSharp"},{"key":"curl","label":"cURL","variant":"cURL"},{"key":"dart","label":"Dart","variant":"http"},{"key":"go","label":"Go","variant":"Native"},{"key":"http","label":"HTTP","variant":"HTTP"},{"key":"java","label":"Java","variant":"OkHttp"},{"key":"java","label":"Java","variant":"Unirest"},{"key":"javascript","label":"JavaScript","variant":"Fetch"},{"key":"javascript","label":"JavaScript","variant":"jQuery"},{"key":"javascript","label":"JavaScript","variant":"XHR"},{"key":"c","label":"C","variant":"libcurl"},{"key":"nodejs","label":"NodeJs","variant":"Axios"},{"key":"nodejs","label":"NodeJs","variant":"Native"},{"key":"nodejs","label":"NodeJs","variant":"Request"},{"key":"nodejs","label":"NodeJs","variant":"Unirest"},{"key":"objective-c","label":"Objective-C","variant":"NSURLSession"},{"key":"ocaml","label":"OCaml","variant":"Cohttp"},{"key":"php","label":"PHP","variant":"cURL"},{"key":"php","label":"PHP","variant":"Guzzle"},{"key":"php","label":"PHP","variant":"HTTP_Request2"},{"key":"php","label":"PHP","variant":"pecl_http"},{"key":"powershell","label":"PowerShell","variant":"RestMethod"},{"key":"python","label":"Python","variant":"http.client"},{"key":"python","label":"Python","variant":"Requests"},{"key":"r","label":"R","variant":"httr"},{"key":"r","label":"R","variant":"RCurl"},{"key":"ruby","label":"Ruby","variant":"Net::HTTP"},{"key":"shell","label":"Shell","variant":"Httpie"},{"key":"shell","label":"Shell","variant":"wget"},{"key":"swift","label":"Swift","variant":"URLSession"}],"languageOptions":[{"label":"C# - HttpClient","value":"csharp - HttpClient - C#"},{"label":"C# - RestSharp","value":"csharp - RestSharp - C#"},{"label":"cURL - cURL","value":"curl - cURL - cURL"},{"label":"Dart - http","value":"dart - http - Dart"},{"label":"Go - Native","value":"go - Native - Go"},{"label":"HTTP - HTTP","value":"http - HTTP - HTTP"},{"label":"Java - OkHttp","value":"java - OkHttp - Java"},{"label":"Java - Unirest","value":"java - Unirest - Java"},{"label":"JavaScript - Fetch","value":"javascript - Fetch - JavaScript"},{"label":"JavaScript - jQuery","value":"javascript - jQuery - JavaScript"},{"label":"JavaScript - XHR","value":"javascript - XHR - JavaScript"},{"label":"C - libcurl","value":"c - libcurl - C"},{"label":"NodeJs - Axios","value":"nodejs - Axios - NodeJs"},{"label":"NodeJs - Native","value":"nodejs - Native - NodeJs"},{"label":"NodeJs - Request","value":"nodejs - Request - NodeJs"},{"label":"NodeJs - Unirest","value":"nodejs - Unirest - NodeJs"},{"label":"Objective-C - NSURLSession","value":"objective-c - NSURLSession - Objective-C"},{"label":"OCaml - Cohttp","value":"ocaml - Cohttp - OCaml"},{"label":"PHP - cURL","value":"php - cURL - PHP"},{"label":"PHP - Guzzle","value":"php - Guzzle - PHP"},{"label":"PHP - HTTP_Request2","value":"php - HTTP_Request2 - PHP"},{"label":"PHP - pecl_http","value":"php - pecl_http - PHP"},{"label":"PowerShell - RestMethod","value":"powershell - RestMethod - PowerShell"},{"label":"Python - http.client","value":"python - http.client - Python"},{"label":"Python - Requests","value":"python - Requests - Python"},{"label":"R - httr","value":"r - httr - R"},{"label":"R - RCurl","value":"r - RCurl - R"},{"label":"Ruby - Net::HTTP","value":"ruby - Net::HTTP - Ruby"},{"label":"Shell - Httpie","value":"shell - Httpie - Shell"},{"label":"Shell - wget","value":"shell - wget - Shell"},{"label":"Swift - URLSession","value":"swift - URLSession - Swift"}],"layoutOptions":[{"value":"classic-single-column","label":"Single Column"},{"value":"classic-double-column","label":"Double Column"}],"versionOptions":[],"environmentOptions":[{"value":"0","label":"No Environment"},{"label":"Spring Lemon Local Documentation","value":"305915-5117dcc8-5f3f-4bb8-bc81-786b8691d897"}],"canonicalUrl":"https://documenter.gw.postman.com/view/metadata/RVu2mqEH"}