create user _index and _entity endpoint

This commit is contained in:
Julien Fastré 2021-06-26 10:41:22 +02:00
parent aa5c7f333e
commit aaa9a1ec7b
3 changed files with 80 additions and 1 deletions

View File

@ -0,0 +1,10 @@
<?php
namespace Chill\MainBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
class UserApiController extends ApiController
{
}

View File

@ -347,7 +347,28 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
]
],
]
],
[
'class' => \Chill\MainBundle\Entity\User::class,
'controller' => \Chill\MainBundle\Controller\UserApiController::class,
'name' => 'user',
'base_path' => '/api/1.0/main/user',
'base_role' => 'ROLE_USER',
'actions' => [
'_index' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true
],
],
'_entity' => [
'methods' => [
Request::METHOD_GET => true,
Request::METHOD_HEAD => true,
]
],
]
],
]
]);
}

View File

@ -10,6 +10,19 @@ servers:
components:
schemas:
User:
type: object
properties:
id:
type: integer
type:
type: string
enum:
- user
username:
type: string
text:
type: string
Center:
type: object
properties:
@ -425,3 +438,38 @@ paths:
description: "not found"
401:
description: "Unauthorized"
/1.0/main/user.json:
get:
tags:
- user
summary: Return a list of all user
responses:
200:
description: "ok"
/1.0/main/user/{id}.json:
get:
tags:
- user
summary: Return a user by id
parameters:
- name: id
in: path
required: true
description: The user id
schema:
type: integer
format: integer
minimum: 1
responses:
200:
description: "ok"
content:
application/json:
schema:
$ref: '#/components/schemas/User'
404:
description: "not found"
401:
description: "Unauthorized"