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

Feature/fake-students-endpoint #70

Merged
merged 19 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@
class AnnotationsStudent
{
/**
* @OA\Get(
* path="/student/list/for-home",
* operationId="getAllStudentsForFigma",
* tags={"Student"},
* summary="Get all Students.",
* description="Get a list of all students registered with the Profile-Home fields in Figma Design. No authentication required",
*
* @OA\Response(
* response=200,
* description="",
*
* @OA\JsonContent(
* @OA\Property(
* type="array",
* property="data",
* @OA\Items(
* type="object",
* @OA\Property(property="fullname", type="string", example="Juan Pérez"),
* @OA\Property(property="subtitle", type="string", example="Desarrollador Frontend"),
* @OA\Property(property="photo",description="Student Image Path",
* type="string",
* example="img/stud_1.png"),
* @OA\Property(property="tags",type="array",@OA\Items(ref="#/components/schemas/Tag"))
*
* )
* )
* )
* )
* )
* @OA\Schema(
* schema="Tag",
* type="object",
* @OA\Property(property="id", type="integer", example=1),
* @OA\Property(property="name", type="string", example="JavaScript")
* )
*/
public function __invoke() {}
/**
* Llista de tots els estudiants
*
* @OA\Get (
Expand Down
15 changes: 15 additions & 0 deletions app/Http/Controllers/api/StudentListController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;

class StudentListController extends Controller
{
public function __invoke()
{
$data = file_get_contents(base_path('database/data/students.json'));

return response()->json(json_decode($data, true));
}
}
187 changes: 116 additions & 71 deletions database/data/students.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,118 @@
[
{
"nombreCompleto": "Juan Pérez",
"profesion": "Desarrollador Frontend",
"foto": "img/stud_2.png",
"lenguajes": ["JavaScript", "React", "HTML", "CSS"],
"id": 1
},
{
"nombreCompleto": "María García",
"profesion": "Diseñadora UX/UI",
"foto": "img/stud_1.png",
"lenguajes": ["CSS", "Sketch", "InVision"],
"id": 2
},
{
"nombreCompleto": "Carlos Rodríguez",
"profesion": "Ingeniero de Software",
"foto": "img/stud_3.png",
"lenguajes": ["Java", "PHP", "JavaScript", "React"],
"id": 3
},
{
"nombreCompleto": "Laura Martínez",
"profesion": "Desarrolladora Full Stack",
"foto": "img/stud_1.png",
"lenguajes": ["JavaScript", "Node.js", "Express", "SQL"],
"id": 4
},
{
"nombreCompleto": "Elena López",
"profesion": "Frontend React",
"foto": "img/stud_2.png",
"lenguajes": ["CSS", "React", "Figma"],
"id": 5
},
{
"nombreCompleto": "Alejandro Ruiz",
"profesion": "Desarrollador Frontend",
"foto": "img/stud_3.png",
"lenguajes": ["JavaScript", "Vue.js", "HTML", "CSS"],
"id": 6
},
{
"nombreCompleto": "Sofía Hernández",
"profesion": "Diseñadora Gráfica",
"foto": "img/stud_1.png",
"lenguajes": ["Illustrator", "Photoshop", "InDesign"],
"id": 7
},
{
"nombreCompleto": "Martín González",
"profesion": "Ingeniero de Software",
"foto": "img/stud_2.png",
"lenguajes": ["Java", "PHP", "JavaScript", "React"],
"id": 8
},
{
"nombreCompleto": "Ana Castro",
"profesion": "Desarrolladora Full Stack",
"foto": "img/stud_3.png",
"lenguajes": ["JavaScript", "Node.js", "Express", "SQL"],
"id": 9
},
{
"nombreCompleto": "Javier Díaz",
"profesion": "Analista de Datos",
"foto": "img/stud_1.png",
"lenguajes": ["Python", "Pandas", "SQL"],
"id": 10
}

{
"fullname": "Juan Pérez",
"subtitle": "Desarrollador Frontend",
"photo": "img/stud_2.png",
"tags": [
{"id": 1, "name": "JavaScript"},
{"id": 2, "name": "React"},
{"id": 3, "name": "HTML"},
{"id": 4, "name": "CSS"}
],
"id": 1
},
{
"fullname": "María García",
"subtitle": "Diseñadora UX/UI",
"photo": "img/stud_1.png",
"tags": [
{"id": 4, "name": "CSS"},
{"id": 6, "name": "Sketch"},
{"id": 7, "name": "InVision"}
],
"id": 2
},
{
"fullname": "Carlos Rodríguez",
"subtitle": "Ingeniero de Software",
"photo": "img/stud_3.png",
"tags": [
{"id": 8, "name": "Java"},
{"id": 9, "name": "PHP"},
{"id": 1, "name": "JavaScript"},
{"id": 2, "name": "React"}
],
"id": 3
},
{
"fullname": "Laura Martínez",
"subtitle": "Desarrolladora Full Stack",
"photo": "img/stud_1.png",
"tags": [
{"id": 1, "name": "JavaScript"},
{"id": 10, "name": "Node.js"},
{"id": 11, "name": "Express"},
{"id": 12, "name": "SQL"}
],
"id": 4
},
{
"fullname": "Elena López",
"subtitle": "Frontend React",
"photo": "img/stud_2.png",
"tags": [
{"id": 4, "name": "CSS"},
{"id": 2, "name": "React"},
{"id": 13, "name": "Figma"}
],
"id": 5
},
{
"fullname": "Alejandro Ruiz",
"subtitle": "Desarrollador Frontend",
"photo": "img/stud_3.png",
"tags": [
{"id": 1, "name": "JavaScript"},
{"id": 14, "name": "Vue.js"},
{"id": 3, "name": "HTML"},
{"id": 4, "name": "CSS"}
],
"id": 6
},
{
"fullname": "Sofía Hernández",
"subtitle": "Diseñadora Gráfica",
"photo": "img/stud_1.png",
"tags": [
{"id": 15, "name": "Illustrator"},
{"id": 16, "name": "Photoshop"},
{"id": 17, "name": "InDesign"}
],
"id": 7
},
{
"fullname": "Martín González",
"subtitle": "Ingeniero de Software",
"photo": "img/stud_2.png",
"tags": [
{"id": 8, "name": "Java"},
{"id": 9, "name": "PHP"},
{"id": 1, "name": "JavaScript"},
{"id": 2, "name": "React"}
],
"id": 8
},
{
"fullname": "Ana Castro",
"subtitle": "Desarrolladora Full Stack",
"photo": "img/stud_3.png",
"tags": [
{"id": 1, "name": "JavaScript"},
{"id": 10, "name": "Node.js"},
{"id": 11, "name": "Express"},
{"id": 12, "name": "SQL"}
],
"id": 9
},
{
"fullname": "Javier Díaz",
"subtitle": "Analista de Datos",
"photo": "img/stud_1.png",
"tags": [
{"id": 18, "name": "Python"},
{"id": 19, "name": "Pandas"},
{"id": 12, "name": "SQL"}
],
"id": 10
}
]
9 changes: 3 additions & 6 deletions routes/api/v1.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use App\Http\Controllers\api\AuthController;
use App\Http\Controllers\api\RecruiterController;
use App\Http\Controllers\api\StudentController;
use App\Http\Controllers\api\StudentListController;
use App\Http\Controllers\api\TagController;
use App\Http\Controllers\api\SpecializationListController;
use Illuminate\Support\Facades\Route;
Expand All @@ -29,12 +30,8 @@
Route::get('/recruiters', [RecruiterController::class, 'index'])->name('recruiter.list');
Route::get('/recruiters/{id}', [RecruiterController::class, 'show'])->name('recruiter.show');

//! ENDPOINT FALSO
Route::get('/fake-students', function () {
$data = file_get_contents(base_path('database/data/students.json'));

return response()->json(json_decode($data, true));
});
// Students
Route::get('/student/list/for-home', StudentListController::class)->name('profiles.home');

// Specialization List Endpoint
Route::get('/specialization/list', SpecializationListController::class)->name('roles.list');
Expand Down
64 changes: 64 additions & 0 deletions storage/api-docs/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,57 @@
}
],
"paths": {
"/student/list/for-home": {
"get": {
"tags": [
"Student"
],
"summary": "Get all Students.",
"description": "Get a list of all students registered with the Profile-Home fields in Figma Design. No authentication required",
"operationId": "getAllStudentsForFigma",
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"properties": {
"data": {
"type": "array",
"items": {
"properties": {
"fullname": {
"type": "string",
"example": "Juan Pérez"
},
"subtitle": {
"type": "string",
"example": "Desarrollador Frontend"
},
"photo": {
"description": "Student Image Path",
"type": "string",
"example": "img/stud_1.png"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Tag"
}
}
},
"type": "object"
}
}
},
"type": "object"
}
}
}
}
}
}
},
"/students": {
"get": {
"tags": [
Expand Down Expand Up @@ -1823,6 +1874,19 @@
},
"components": {
"schemas": {
"Tag": {
"properties": {
"id": {
"type": "integer",
"example": 1
},
"name": {
"type": "string",
"example": "JavaScript"
}
},
"type": "object"
},
"AnnotationsAdmin": {
"title": "Admin",
"description": "Admin Model",
Expand Down
20 changes: 20 additions & 0 deletions tests/Feature/Student/StudentListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,24 @@ public function a_list_of_registered_students_can_be_retrieved(): void
$response->assertHeader('Content-Type', 'application/json');

}
public function test_student_list_controller()
{
$response = $this->get('api/v1/student/list/for-home');

$response->assertStatus(200);

$response->assertJsonStructure([
'*' => [
'fullname',
'subtitle',
'photo',
'tags',
'id'
]/* ,
'*.tags.*' => [
'id',
'name'
] */
]);
}
}