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

Practice App: Implementing POST Category endpoint #165

Closed
8 tasks done
mbatuhancelik opened this issue May 7, 2022 · 6 comments · Fixed by #166
Closed
8 tasks done

Practice App: Implementing POST Category endpoint #165

mbatuhancelik opened this issue May 7, 2022 · 6 comments · Fixed by #166
Assignees
Labels
practice-app:back-end Related to the back-end of the practice app practice-app Related to the practice app project priority-medium Medium level priority issue Status: Completed Issue is solved

Comments

@mbatuhancelik
Copy link
Contributor

mbatuhancelik commented May 7, 2022

Issue Description

As discussed in meeting 9 we are to add following endpoints regarding categories:

POST /category : creates a new category and returns it upon completion.

And this issue is about creating this endpoint.

As the development for category model continues under #163, I will begin implementing endpoints regarding categories using the prototype I proposed.

Step Details

Steps that will be performed:

  • Check the incoming data is valid.
  • Check if the category already exists.
  • Create and save the category.
  • Return the created category as a response.
  • Return an error message if an error occurs in previous steps
  • Test the endpoint using Postman.
  • Save requests as a collection in Postman.
  • Create documentation for the endpoint.

Final Actions

After POST endpoint is created, it should be tested using postman and a collection shall be created using those tests, additionally unit tests should be created, and a GET endpoint for categories should be implemented.

Deadline of the Issue

07.05.2022 - Saturday - 23:59

Reviewer

Muhammed Enes Sürmeli
Ecenur Sezer

Deadline for the Review

08.05.2022 - Sunday - 23:59 PM

@mbatuhancelik mbatuhancelik added priority-medium Medium level priority issue status-new New issue in initial state practice-app Related to the practice app project practice-app:back-end Related to the back-end of the practice app labels May 7, 2022
@mbatuhancelik mbatuhancelik self-assigned this May 7, 2022
@mbatuhancelik
Copy link
Contributor Author

Regarding checking if a category already exists:

One problem we encounter is that user may describe categories in several different ways. For example both "Node js" and "node.js" perfectly describe Node.js but we do not want to allow duplicates.

Yet another issue is that, user may input the category's name wrong, as illustration he/she can input "noode js"

In meeting 9, we discussed about using wikipedia API for category description and decided to use it if it was not complex.

I checked the API and it was really intuitive with examples, thus I decided to use it both for standardizing categories. For example, when all these 3 representations of Node.js are searched in wiki API, it returns "Node.js" for all of them, thus all three representations are mapped to one title.

@mbatuhancelik
Copy link
Contributor Author

Further exploring the wikipedia API, once we standardized category titles using wikipedia search, it is fairly easy to get a description from wikipedia too! I will be adding this functionality.

@mbatuhancelik
Copy link
Contributor Author

I now created a prototype and pushed the development up to this point to branch related to this issue.
Now I will work on error messages and testing.

@mbatuhancelik mbatuhancelik added status-inprogress Issue is currently worked and removed status-new New issue in initial state labels May 7, 2022
@mbatuhancelik
Copy link
Contributor Author

I made the last changes to the endpoint and tested it using postman, here is the postman collection used for testing:

{
	"info": {
		"_postman_id": "28da51cf-ee65-4eaa-9488-5e2573d634ff",
		"name": "api/category",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "create new category",
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"title\" : \"computer vision\"\r\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "localhost:3000/api/category",
					"host": [
						"localhost"
					],
					"port": "3000",
					"path": [
						"api",
						"category"
					]
				}
			},
			"response": []
		},
		{
			"name": "Incorrect title",
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"title\" : \"a\"\r\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "localhost:3000/api/category",
					"host": [
						"localhost"
					],
					"port": "3000",
					"path": [
						"api",
						"category"
					]
				}
			},
			"response": []
		},
		{
			"name": "creating already exiting cagegory",
			"request": {
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"title\" : \"artificial intelligence\"\r\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "localhost:3000/api/category",
					"host": [
						"localhost"
					],
					"port": "3000",
					"path": [
						"api",
						"category"
					]
				}
			},
			"response": []
		}
	]
}

and here are the results(since we have not a common postman project yet):

image

image

image

@mbatuhancelik
Copy link
Contributor Author

Postman documentation can be found here

@mbatuhancelik mbatuhancelik added status-needreview A review to the issue is needed and removed status-inprogress Issue is currently worked labels May 7, 2022
@mbatuhancelik mbatuhancelik linked a pull request May 8, 2022 that will close this issue
@mbatuhancelik mbatuhancelik changed the title Practice App: POST Category endpoint Practice App: Implementing POST Category endpoint May 8, 2022
@mbatuhancelik
Copy link
Contributor Author

A PR is created for implementation of this issue and it is ready for a review from @codingAku and @surmelienes1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
practice-app:back-end Related to the back-end of the practice app practice-app Related to the practice app project priority-medium Medium level priority issue Status: Completed Issue is solved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants