From b938a5ba507a54dce7e2729f9e9546814224deaa Mon Sep 17 00:00:00 2001 From: Bhanu Teja Date: Wed, 29 Nov 2017 21:27:42 +0530 Subject: [PATCH 1/4] very small typo --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ddce3f9..a65cb6c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -46,7 +46,7 @@ We welcome pull requests from beginners and django developers alike! ### Work on Issues -1. Find an issue that needs assistance by searching for the [open issues](https://github.com/coderplex/coderplex-backend/labels/help wanted). +1. Find an issue that needs assistance by searching for the [open issues](https://github.com/coderplex/coderplex-backend/labels/help-wanted). 1. If you decide to fix an issue, please be sure to check the comment thread in case somebody is already working on a fix. If nobody is working on it at the moment, please leave a comment stating that you intend to work on it so other people don’t accidentally duplicate your effort. 1. If somebody claims an issue but doesn’t follow up for more than a weeks, it’s fine to take over it but you should still leave a comment. From ae953f956948dfe53b9ccb8be2013c553d691c29 Mon Sep 17 00:00:00 2001 From: Bhanu Teja Date: Wed, 29 Nov 2017 21:42:55 +0530 Subject: [PATCH 2/4] added swagger documentation api --- webapp/coderplex_apis/db.sqlite3 | Bin 315392 -> 315392 bytes webapp/coderplex_apis/settings.py | 1 + webapp/coderplex_apis/urls.py | 4 +++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/coderplex_apis/db.sqlite3 b/webapp/coderplex_apis/db.sqlite3 index 738daa19f55c8d924778f5bf08de967f41624962..88488e9a2fced7ed5a58a9ce6e0c9afb7c3fc357 100644 GIT binary patch delta 1701 zcmZ{i%WoT16o-AsH+B4&xpp1n%CDKkamI<8@x1PMCO|?I3B;mlq;^qNRFRvwNz}w1 znq)yKN+n(r6t&V7nFXK*i7luii)<(=5&}WH05<8a`~_^F5<9pvo{Sw-EZNfc-Sazh z<{sbNOW)i}-&@ad#+0H?sSU}JP1C~Udd>(`qan+tMZV3Q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$*SyV4c*c4u22q3kvbsr)zmJ^p8Yjl0Qx&fVhoxCi_@{8jFd`-4yKm&6MkzB!vnztZVk9OPg&1H50G z-R5cwe>OXbf1eeKY#vGi*z7E?H#eHg%bo4^Rv@}v1|QBAu{!tOSQ=(Zpt-%Z)@@zB zw7$8y-f2S)X0kq8z1-RE;-BW^^ke=me~W*cf1O|DpXF74h8@aOr{ zyn;s;CBDPHz&^v)*dgXG<`?Fx{d0>~lP`Lc7=sX$!Qk>*v%T6{@`%nsPy~a`l@(uV zenM)cwb9yYEqR+$dnB-UMDZ;t&*HDPdj73a4gv(&z}ELNsTXojPEx}=6Ilopz#~IOrYTshoyD0?e^0-R{^31R6;8RoLoWY_&_hfM28B3flS+F#|yz zB>yYp)BWo&W3c1T36Itg{t1{KKUzk}lfw|y0Q6T9!o&~+6%Y-I__vDpP~i7bjE6t~ zQP1jY+S~V=yGsYVOJL_gJi-0SJ>ov(Hr!E>nn)%7PCQIpPduLx6N5FvW)Mr!pnc$w2(zi3AZf z4Z1Of5~s%EL{+ByHt#*9cL~v7^H{8x Date: Wed, 29 Nov 2017 21:54:03 +0530 Subject: [PATCH 3/4] changed the url of swagger docs to '/api-docs' --- webapp/coderplex_apis/urls.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/coderplex_apis/urls.py b/webapp/coderplex_apis/urls.py index 97742c2..a51a85f 100644 --- a/webapp/coderplex_apis/urls.py +++ b/webapp/coderplex_apis/urls.py @@ -25,7 +25,8 @@ urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', include('books.urls')), - url(r'^$', schema_view), + url(r'^$', views.HelloWordView.as_view()), + url(r'^api-docs$', schema_view), url(r'^v1/', include('authentication.urls')), url(r'^callback', views.SocialCodeView.as_view()), url(r'^api-token-auth', obtain_jwt_token), From f2e637770cdafec25c6deca3c504ed622a91b6d6 Mon Sep 17 00:00:00 2001 From: Bhanu Teja Date: Wed, 29 Nov 2017 22:13:01 +0530 Subject: [PATCH 4/4] added about swagger route in Contributing Guidelines and deleted API.md --- .github/CONTRIBUTING.md | 15 +- API.md | 510 ---------------------------------------- 2 files changed, 10 insertions(+), 515 deletions(-) delete mode 100644 API.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index a65cb6c..b0bdde6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -17,6 +17,7 @@ Coderplex web application comprises of two repositories : - [Prerequisites](#prerequisites) - [Sending a Pull Request](#sending-a-pull-request) - [Running Locally](#running-locally) + - [Notes](#notes) - [Docker Deployment in production](#docker-deployment-in-production) - [Before submitting](#before-submitting) - [Submitting PullRequest](#submitting-pullrequest) @@ -130,8 +131,14 @@ We welcome pull requests from beginners and django developers alike! python webapp/manage.py runserver ``` You can now open the App at `localhost:8000` in your browser -1. You can see all the implemented APIs in [API.md](../API.md) - + +##### Notes +1. You can see all the implemented APIs in the route `/api-docs`. Any new api that you will create will be automatically appear in `/api-docs` route. +1. To get `code` that will be used to in the `GitHub Login API`, run this [url](https://github.com/login/oauth/authorize?scope=user:email&client_id=97d600c693730ed91ac0) + in the browser and authorize, then the `code` will be appended as a url param to the redirected_url +1. To get `code` that will be used to in the `LinkedIn Login API`, run this [url](https://www.linkedin.com/oauth/v2/authorization?client_id=81ptws4wm9kflx&response_type=code&redirect_uri=http://127.0.0.1:8000/callback) + in the browser and authorize, then the `code` will be appended as a url param to the redirected_url + #### For Production (Contributors can ignore this) 1. Change `client_id` and `client_secret` of social applications 1. Add environment variables `GITHUB_CALLBACK_URL` and `LINKEDIN_CALLBACK_URL` and set those with ` + "/callback"` @@ -165,9 +172,7 @@ We welcome pull requests from beginners and django developers alike! ```bash python webapp/manage.py test ``` -1. If any documentation is needed, add docs -1. If any exisitng APIs are modified, make those changes in [API.md](../API.md) -1. If any new APIs are added, make those changes in [API.md](../API.md) according to [iros's template](https://gist.github.com/iros/3426278) +1. If any documentation is needed, add docs 1. Add and commit your code. Please give meaningful commit messages. #### Submitting PullRequest diff --git a/API.md b/API.md deleted file mode 100644 index 5ef17f2..0000000 --- a/API.md +++ /dev/null @@ -1,510 +0,0 @@ -**GitHub Code** ----- - To Fetch GitHub `code` from GitHub api for oauth authorization, run the following url in browser - -* **URL** - - **`https://github.com/login/oauth/authorize?scope=user:email&client_id=97d600c693730ed91ac0`** - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** `code` will be appended as param to your `callback_url` or `redirect_uri` - -**LinkedIn Code** ----- - Fetch code from **LINKEDIN** api for oauth authorization - -* **URL** - - **`https://www.linkedin.com/oauth/v2/authorization?client_id=81ptws4wm9kflx&response_type=code&redirect_uri=http://127.0.0.1:8000/callback`** - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** `code` will be appended as param to your `callback_url` or `redirect_uri` - -**GitHub Login** ----- - Login to the application using **GitHub** - -* **URL** - - **`/v1/auth/github`** - -* **Method:** - - **`POST`** - -* **Data Params** - - **Required:** - - `code=[string]` - -* **Headers** - - **Required:** - - `content-type: application/json` - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** - ```json - { - "token": "eyJ0eXAiOiJKV1QiLCJhbGc", - "user": { - "username": "user123", - "first_name": "P", - "last_name": "User Name", - "avatar": "http://www.sample.com/image.jpg", - "email" : "email@example.com" - } - } - ``` - - -* **Error Response:** - - * **Code:** 400 BAD REQUEST
- **Content:** `{"non_field_errors": ["Incorrect input. access_token or code is required."]}`
- **Problem:** `code is blank or code is not passed as data` - - -* **Sample Call:** - - ``` - curl -X POST \ - http://localhost:8000/v1/auth/github \ - -H 'content-type: application/json' \ - -d '{ - "code" : "e47deee658cb2c59a6" - }' - ``` - -* **Notes:** - - - You may get **500 INTERNAL SERVER ERROR** sometimes, in that case check the error content to find out the problem. - -**LinkedIn Login** ----- - Login to the application using **LinkedIn** - -* **URL** - - **`/v1/auth/linkedin`** - -* **Method:** - - **`POST`** - -* **Data Params** - - **Required:** - - `code=[string]` - -* **Headers** - - **Required:** - - `content-type: application/json` - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** - ```json - { - "token": "eyJ0eXAiOiJKV1QiLCJhbGc", - "user": { - "username": "user123", - "first_name": "P", - "last_name": "User Name", - "avatar": "http://www.sample.com/image.jpg", - "email" : "email@example.com" - } - } - ``` - - -* **Error Response:** - - * **Code:** 400 BAD REQUEST
- **Content:** `{"non_field_errors": ["Incorrect input. access_token or code is required."]}`
- **Problem:** `code is blank or code is not passed in data` - - -* **Sample Call:** - - ``` - curl -X POST \ - http://localhost:8000/v1/auth/linkedin \ - -H 'content-type: application/json' \ - -d '{ - "code" : "e47deee658cb2c59a6" - }' - ``` - -* **Notes:** - - - You may get **500 INTERNAL SERVER ERROR** sometimes, in that case check the error content to find out the problem. - -**JWT Token** ----- - Fetch JWT Token using user credentials - -* **URL** - - **`/api-token-auth`** - -* **Method:** - - **`POST`** - -* **Data Params** - - **Required:** - - `username=[string]` - - `password=[string]` - -* **Headers** - - **Required:** - - `content-type: application/json` - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** ` - { - "token": "eyJ0eXAiOiJKV1QiLCJhbGciO" - }` - - -* **Error Response:** - - * **Code:** 400 BAD REQUEST
- **Content:** `{ - "non_field_errors": [ - "Unable to log in with provided credentials." - ] - }` - - OR - - * **Code:** 400 BAD REQUEST
- **Content:** `{ - "password": [ - "This field may not be blank." - ] - }` - - OR - - * **Code:** 400 BAD REQUEST
- **Content:** `{ - "password": [ - "This field is required." - ] - }` - - -* **Sample Call:** - - ``` - curl -X POST \ - http://localhost:8000/api-token-auth \ - -H 'content-type: application/json' \ - -d '{ - "username": "admin", - "password" : "admin_password" - }' - ``` - -* **Notes:** - - - None - -**User View** ----- - Fetch the details of logged_in user - -* **URL** - - **`/user`** - -* **Method:** - - **`GET`** - -* **Headers** - - **Required:** - - `authorization: JWT ` - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** - ```json - { - "username": "user123", - "first_name": "First", - "last_name": "Last", - "email": "email@example.com" - } - ``` - - -* **Sample Call:** - - ``` - curl -X GET \ - http://localhost:8000/user \ - -H 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6Ik' \ - ``` - -* **Notes:** - - None - -**User Update** ----- - Update the details of logged_in user - -* **URL** - - **`/user`** - -* **Method:** - - **`POST`** - -* **URL Params** - - **Optional:** - - `username=[string]` - - `email=[email]` - - `first_name=[string]` - - `last_name=[string]` - - -* **Headers** - - **Required:** - - `authorization: JWT ` - - `content-type: application/json` - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** - ```json - { - "username": "user123", - "first_name": "P", - "last_name": "User Name", - "email" : "email@example.com" - } - ``` - - -* **Sample Call:** - - ``` - curl -X POST \ - http://localhost:8000/user \ - -H 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MTE0ODMzOTQsImVtYWlsIjoiIiwidXNlcm5hbWUiOiJiaGFudV90ZWphIiwidXNlcl9pZCI6NzR9.Hc1H8Tt9d2FSJkTEHKjx-fB8cblrg1yKDVK9lzuZ914' \ - -H 'content-type: application/json' \ - -d '{ - "username" : "user123", - "first_name" : "First", - "last_name" : "last", - "email" : "email@example.com" - }' - ``` - -* **Notes:** - - None - -**User Profile View** ----- - Fetch the profile of logged_in user - -* **URL** - - **`/user/profile`** - -* **Method:** - - **`GET`** - -* **Headers** - - **Required:** - - `authorization: JWT ` - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** - ```json - { - "user": { - "username": "user123", - "first_name": "First", - "last_name": "Last", - "email": "email@example.com" - }, - "avatar": "https://avatars3.githubusercontent.com/u/17903466?v=4", - "mobile_number": null, - "short_bio": "This is my short bio", - "job_status": true, - "company_name": "company112", - "looking_for_job": false, - "github_profile": "https://github.com/user123", - "facebook_profile": null, - "twitter_profile": null, - "linkedin_profile": null, - "codepen_profile": null, - "discord_profile": null, - "familiar_technologies": null, - "interested_technologies": null - } - ``` - - -* **Sample Call:** - - ``` - curl -X GET \ - http://localhost:8000/user \ - -H 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6Ik' \ - ``` - -* **Notes:** - - None - -**User Profile Update** ----- - Update the profile of logged_in user - -* **URL** - - **`/user/profile`** - -* **Method:** - - **`POST`** - -* **URL Params** - - **Optional:** - - `avatar=[url]` - - `mobile_number=[string]` - - `short_bio=[string]` - - `job_status=[boolean]` - - `company_name=[string]` - - `looking_for_job=[boolean]` - - `github_profile=[url]` - - `facebook_profile=[url]` - - `twitter_profile=[url]` - - `linkedin_profile=[url]` - - `codepen_profile=[url]` - - `discord_profile=[url]` - - `familiar_technologies=[string]` - - `interested_technologies=[string]` - - -* **Headers** - - **Required:** - - `authorization: JWT ` - - `content-type: application/json` - -* **Success Response:** - - * **Code:** 200 OK
- **Content:** - ```json - { - "user": { - "username": "user123", - "first_name": "First", - "last_name": "Last", - "email": "email@example.com" - }, - "avatar": "https://avatars3.githubusercontent.com/u/17903466?v=4", - "mobile_number": null, - "short_bio": "This is my short bio", - "job_status": true, - "company_name": "company112", - "looking_for_job": false, - "github_profile": "https://github.com/user123", - "facebook_profile": null, - "twitter_profile": null, - "linkedin_profile": null, - "codepen_profile": null, - "discord_profile": null, - "familiar_technologies": null, - "interested_technologies": null - } - ``` - - -* **Sample Call:** - - ``` - curl -X POST \ - http://localhost:8000/user \ - -H 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MTE0ODMzOTQsImVtYWlsIjoiIiwidXNlcm5hbWUiOiJiaGFudV90ZWphIiwidXNlcl9pZCI6NzR9.Hc1H8Tt9d2FSJkTEHKjx-fB8cblrg1yKDVK9lzuZ914' \ - -H 'content-type: application/json' \ - -d '{ - "avatar": "https://avatars3.githubusercontent.com/u/17903466?v=4", - "mobile_number": "9854785985", - "short_bio": "This is my short bio", - "job_status": true, - "company_name": "company112", - "looking_for_job": false, - "github_profile": "https://github.com/user123", - "facebook_profile": "https://facebook.com/user123", - "twitter_profile": "https://twitter.com/user123", - "linkedin_profile": "https://linkedin.com/user123", - "codepen_profile": "https://codepen.com/user123", - "discord_profile": "https://discord.com/user123", - "familiar_technologies": "c", - "interested_technologies": "c" - }' - ``` - -* **Notes:** - - None \ No newline at end of file