Questions tagged [fosrestbundle]
A Symfony 2 plugin by FriendsOfSymfony (FOS) which provides various tools to rapidly develop RESTful API's with Symfony 2.
804
questions
0
votes
0
answers
22
views
FOSUser + LexikJWT still returning 401 (Full authentication is required to access this resource.)
I'm working on a project that implements two-level authentication (username + password) and TOTP authentication using the FOS User bundle. Additionally, I'm integrating a REST API using the FOSRest ...
0
votes
0
answers
76
views
Symfony FosRestBundle: disable exception stack trace
I have a Symfony v6 application with FosRestBundle.
When I go to an endpoint which throw an exception, I got a page with the full error and the stack trace. Also in production mode.
The kernel is ...
0
votes
0
answers
77
views
FOSRestBundle events not caught
I'm migrating a bunch of code from a really old Symfony project to a new one based on Symfony 6.2 and I have these issue with the FOSRestBundle:
Request format is treated as text/html even when ...
0
votes
0
answers
229
views
Access Denied Error Symfony with roles without prefix 'ROLE_'
Good morning, I want to update my symfony 2.8 application to version 5.4.
I am having problems with the is_granted function of symfony.
My connected user has all the roles in the token (classic roles +...
0
votes
1
answer
124
views
Invalid JSON in Tests Authentifications PHPUnit
Good morning all , I did a complete migration of my symfony 2.8 application to version 5.4. I am now at the unit testing stage. I copied the tests to my new project, however I'm having some ...
0
votes
1
answer
226
views
Change default username field in LexikJWTAuthenticationBundle
I want to update my symfony 2.8 applcation to version 5.4.
I am using fos rest bundle for API as well as jwt auth bundle for authentication with token. My issue is that retrieving the token requires ...
0
votes
2
answers
314
views
Alternative to Symfony's "Collection" constraint
I have a FOSRestBundle annotation on an existing controller that works well. It takes in a collection of nested JSON objects. Like this:
use Symfony\Component\Validator\Constraints;
...
* @Rest\...
0
votes
1
answer
142
views
JsonResponse returns the json response plus the request data in string format problem
I'm making post requests using ajax in my symfony 4.4 project, and i return the response using fosrestbundle, sometimes it returns a correct json response but sometimes, the response includes also the ...
1
vote
1
answer
979
views
Symfony: how to add a serializer group on a Route depending on logged in user's roles
I'm using JMSSerializerBundle in my entities definition, and RestBundle's annotations in controllers.
I have an entity with public and admin-protected attributes, let's say
use JMS\Serializer\...
0
votes
0
answers
384
views
Handle PATCH action null values with Symfony ParamConverter
I have a PATCH action in my controller:
/**
* @ParamConverter("patchRequest", class="array<App\Model\Request\Product\ProductPatchInternalRequest>", converter="fos_rest....
0
votes
1
answer
300
views
FOSRestBundle routes versioning
I wanted to implement versioning of endpoints for my project.. turns out the FOSRestBundle implementation is not quite clear so I wanted to implement like follow:
Symfony 5.4
FOSRestBundle 3
see below ...
0
votes
1
answer
192
views
Symfony5: save related (oneToMany) entity with REST API
I have two entity classes: Product and Price. Product has many Prices. The relations are defined as (only relevant code is shown):
Product.php
public function __construct()
{
$this->prices = ...
0
votes
1
answer
100
views
Sulu CMF - CRUD Filtered Multi-Item-Selection for association entities
I have three entities:
class DataSet {
string $name;
Collection $points; // List<DataPoint>
Collection $groups; // List<DataGroup>
}
class DataGroup {
string $name;
Collection $...
1
vote
1
answer
162
views
Sulu CMF - Filtered Single autocomplete selection for associated entity
I have two entities:
class DataSet {
string $name;
Collection $groups; // List<DataGroup>
}
class DataGroup {
string $name;
DataSet $set;
DataGroup $nextGroup;
}
I created some basic ...
2
votes
1
answer
302
views
How to extend FOSRestBundle RequestBodyParamConverter?
I am new to Symfony (5.3) and would like to extend the RequestBodyParamConverter (FOSRestBundle 3.0.5) to create a REST api. Using @ParamConverter annotation with the RequestBodyParamConverter works ...
2
votes
1
answer
2k
views
Symfony 4.4 / NelmioApiDocBundle 4.0.1 Issue with Annotations
A similar question is already out, but with a different versioning on Symfony and NelmioApiDoc. And I am not sure it is this combination or that fact that also I am using FesRestBundle on top.
My ...
0
votes
1
answer
562
views
FOSRest errors formated as HTML instead of JSON
My API returns HTML on error instead of JSON response.
If I rise throw new BadRequestException('aaa'); HTML with debug and profiler is returned instead of JSON.
I use fos/rest 3.0.5
my fos_rest.yaml:
...
0
votes
1
answer
507
views
No fos_rest.yaml after installing FOSRestBundle
I just installed the FOSRestBundle to my Symfony 5 project using "composer require friendsofsymfony/rest-bundle", however no fos_rest.yaml file is generated in my project. What can be done ...
1
vote
1
answer
4k
views
symfony 5 custom authentication for API REST
I'm working on a project with Symfony 5.
I created the User entity, created the authentication flow on security.yaml and all works well: if user wants to access to protected area, login page was shown ...
1
vote
1
answer
393
views
Sulu: custom entity type - FOS rest api routes are missing
I followed Sulu documentations for adding custom entity types to Sulu and at point:
https://docs.sulu.io/en/2.2/book/extend-admin.html#configure-resources
when calling : bin/adminconsole debug:router |...
0
votes
0
answers
163
views
Symfony FOS rest bundle not getting my json data from API urls
I am trying to call this api : http://localhost/api/columns {"tab":"client"}
but I couldn't get that one value from the json format
I get this error from the browser : {"code&...
0
votes
1
answer
216
views
Convert single property for response with the FOSRestBundle in Symfony 5
I'm working with numbers with a lot of decimal places in my symfony application. In my doctrine entity I have for example this property:
/**
* @ORM\Column(type="float")
*/
private float $...
2
votes
2
answers
3k
views
The annotation "@Swagger\Annotations\Response" in method was never imported
I have a problem with fresh install of Swagger and FosRestBundle on Symfony 5 app.
I have this error :
[Semantical Error] The annotation "@Swagger\Annotations\Response" in method ... was ...
2
votes
1
answer
237
views
"@Sensio\Bundle\FrameworkExtraBundle\Configuration\Route" in method ... does not exist, or could not be auto-loaded"
i'm upgrading symfony's version from 2.8 to 3.0.9, and after fixing the errors with some library's versions and other problems, i have tried run the command "php bin/console cache:clear" ...
0
votes
2
answers
1k
views
Symfony 5 tests of API endpoints return html with redirect
In a migration from Symfony 3.4 to Symfony 5.2 I'm facing following issue only in tests (in the application it works):
FOSRest
Symfony 5
Lexik
fos_rest.yaml
fos_rest:
body_listener:
...
0
votes
0
answers
149
views
Getting anon when trying to get loogged in user [Symfony 3.4] FOSUserBundke+Lexik+FosRest
I'm new in symfony and tried to implement a auth service that allows me to register+login+getting the logged in user for my angular app.
the login worked like a charm, got the token and connected ...
0
votes
1
answer
59
views
Unable to include Collection of Entities inside API POST-call
The error in question:
Entity of type App\Entity\Nutt is missing an assigned ID for field 'squirrel'.
The identifier generation strategy for this entity requires the ID field to be populated before ...
1
vote
1
answer
753
views
How can I all errors show in json format in friendsofsymfony/rest-bundle v3
I want intercept all errors of Symfony after that show them in JSON.
In friendsofsymfony/rest-bundle v2 I can set parameters
fos_rest:
exception:
enabled: true
...
1
vote
2
answers
1k
views
Send Nested Json to a Symfony Form
I have a nested JSON object that I am trying to send to a Symfony API which is using FOSRestBundle.
{
"firstName": "John",
"lastName": "Doe",
"...
3
votes
3
answers
6k
views
Cannot load resource "". Make sure there is a loader supporting the "rest" type
I face this Error while creating a REST API using Symfony V4.99 and fosrestbundle.
When I Run php bin/console debug:router I get this:
Cannot load resource "App\Controller\ListController". ...
1
vote
1
answer
1k
views
Symfony 3.4 JMS Serializer DoctrineObjectConstructor::__construct() expect ManagerRegistry, instance of Doctrine\Bundle\DoctrineBundle\Registry given
Please help me , I am stuck here. I have recently upgraded Symfony version from 2.8 to Symfony 3.4 LTS version. All works fine except the Rest API end point where I extend the Sonata\UserBundle\...
0
votes
1
answer
330
views
Fosrestbundle form error the value is not valid entitytype
I am using FosrestBundle and in my form, I've got an entitytype on a manytomany relations.
I am using postman and I have tried many differents kind of syntax to validate form but I am getting ...
1
vote
1
answer
748
views
Testing Controllers in Symfony 4.4 while using annotations
I'm facing a problem of testing my Controllers in Symfony 4.4 with FOSRestBundle & JMSSserializer. My controllers are pretty simple, usually containing nothing but call to another services, but I'...
-1
votes
1
answer
2k
views
Symfony 5 dynamic routing resolve
I am migrating legacy project routing (Yii1) to Symfony 5
Right now my config/routing.yaml looks something like this:
- {path: '/login', methods: ['GET'], controller: 'App\Controller\RestController::...
1
vote
0
answers
191
views
Customization ConstraintViolationList with RestBudnle
I use FosRestBundle which use jms serializer (looks like default) and I am unable to override default handlers in jms serializer bundle. How can I stop the default handler from overriding my custom ...
0
votes
1
answer
573
views
Custom error pages not working when exception controller is enabled
When implementing fos_rest bundle with symfony, I cannot seem to have Symfony's normal behavior when handling custom error pages on a 404, 405, 500 or any other error triggered by Symfony.
It works ...
2
votes
1
answer
3k
views
Assets not loaded
I have problem, my assets not loaded - 404 Not Found
"nelmio/api-doc-bundle": "^3.6@dev"
I executed php bin/console assets:install and php bin/console assets:install --symlink
Locally works, but on ...
0
votes
0
answers
152
views
Symfony 3.4: problem with POST http method Rest
I use following libraries: JMSSerializer, FOSUserBundle FOSRestBundle + Symfony 3.4 + PHP 5
My need is to add an order to an unregistered customer( the user choose the offer and enter his info in form ...
0
votes
1
answer
1k
views
Symfony 4: JSON to Form Collection
Im working on a FormType that will be populated through JSON (FOSRestBundle). This form has a CollectionType and I have the entry_type set to another FormType.
But whatever I try, I end up with the ...
3
votes
1
answer
3k
views
How to use normalizer option in Symfony constraints component
The documentation
https://symfony.com/doc/4.4/reference/constraints/Length.html#normalizer
states that
This option allows to define the PHP callable applied to the given value before checking if it ...
3
votes
2
answers
6k
views
Unable to install FOSRestBundle with Symfony 5
I was trying to install FOSRestBundle on Symfony 5 using composer but got the following error message:
friendsofsymfony/rest-bundle 2.7.1 requires symfony/config ^3.4|^4.3
Is it possible to ...
4
votes
1
answer
1k
views
Symfony "fos_rest.request_body" converter: do not deserialize nested DTO classes
I have a OrderDto class with a nested PointDto class (array of points):
class OrderDto
{
/**
* @var PointDto[]
* @Assert\All({
* @Assert\Type("App\Dto\PointDto")
* })
...
-3
votes
1
answer
119
views
Best practice - How to respond with different entity views to improve performance in a RESTful API (Symfony 4) [closed]
When listing an using a REST index endpoint I would like to have different outputs for performance reasons.
ex: on the same GET path for CRUD indexing
- List of Entities with all associations
- List ...
-2
votes
2
answers
3k
views
Adding services to a Controller through "container.service_subscriber" not working as expected
I am trying to use the container.service_subscriber tag on my Controller to make some services available without injecting them through the constructor. In our project we don't want to use the ...
0
votes
1
answer
31
views
Doctrine 2 avec Symfony 4.2.5 et FOSRestBundle - OneToMany association - Redondant registering
Here is the problem:
Two entities Books and Auteurs. A book has only one auteur, an auteur can have multiple books.
When the base is populated if I create a book with an existing auteur in the ...
1
vote
0
answers
254
views
Post data contains list attribute in symfony
I have a manyToMany association between Tweet and Hashtag. I am trying to submit the Tweet form to create a tweet with the selected hashtags from the checked boxs. In addition, i'm using FosRestBundle....
2
votes
0
answers
3k
views
Symfony 4 Fos Rest : Error 415 Unsupported Media Type
Impossible to create a new event, I always get 415 error
I test with postman, if I test the same endpoint with ParamConverter annotation, I can reach the function.
So the error should come from ...
-3
votes
1
answer
936
views
Limit login attempts under Symfony 4 and FOSRestBundle
I use FOSRestBundle in Symfony 4 and I want to secure my Login Form using this.
I want to set up a limited number of connection attempts on the login form (5 maximum for 15 minutes, then 30 minutes ...
0
votes
0
answers
170
views
fos_rest.decoder.jsontoform does not work with Symfony 4 FOS Rest Bundle
I try to send boolean value to api endpoint and FOS rest bundle return:
"foo": {
"errors": [
"This value should not be blank."
]
},
My FOS Rest bundle config:
fos_rest:
...
2
votes
1
answer
1k
views
Rest-bundle of Symfony 4 requires config in 4.3 version, while Symfony 4 uses 5.0
Following this tutorial I tried to configure REST API on fresh new Symfony 4 install.
The first step in the tutorial is doing:
composer create-project symfony/skeleton rest_api_project
Followed by
...