question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom operation, Parameter "id" not found

See original GitHub issue

Hello,

I’m trying to add a custom route to my application in order to collect data from two entity. I have an entity “Card” and an entity “ScenarioCard”. I created my custom operation in ScenarioCard like that :

Class ScenarioCard
  @package App\ShidoCardBundle\Entity
  @ORM\Entity
  @ApiResource(itemOperations={
      "get",
      "group_card_info_card_scenario_info"={
          "swagger_context" = {
            "summary" = "Retrieve a card object with ScenarioCard info",
            "parameters" = {
              {
                 "name" = "scenario_id",
                 "in" = "path",
                 "required" = "true",
                 "type" = "string"
              },
              {
                 "name" = "card_id",
                 "in" = "path",
                 "required" = "true",
                 "type" = "string"
              }
           }
          },
         "method"="GET",
          "path"="/scenario/{scenario_id}/card/{card_id}",
          "controller"=RetrieveScenarioCard::class,
      }
  })

Then I created the following handler (as specified in the documentation)

<?php
namespace App\ShidoCardBundle\Controller;

use App\ShidoCardBundle\Entity\ScenarioCard;

class RetrieveScenarioCard
{
    private $retrieveScenarioCardHandler;

    public function __construct(RetrieveScenarioCardHandler $retrieveScenarioCardHandler)
    {
        $this->retrieveScenarioCardHandler = $retrieveScenarioCardHandler;
    }

    public function __invoke(ScenarioCard $data): ScenarioCard
    {
        $this->retrieveScenarioCardHandler->handle($data);
        return $data;
    }
}

My problem here is that Hydra send me back the error “Parameter “id” not found” when I try to request the api endpoint associated with this route. If I understood it correctly, the parameter id is mandatory. If it’s true I don’t understand how I will be able to aggregate datas from those two Entities and send back thoses data.

Are Custom operations even the good way to do what I want to do ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
GregoireHebertcommented, Dec 19, 2018

I think you’ll need to fetch the data by yourself with a dataProvider, and you’ll need to add _api_receive at false for this operation. otherwise it’ll try to get it automatically.

0reactions
soyukacommented, Dec 19, 2018

Closing this, hope that we were helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SET PARAMETER ID is not working for custom parameter id
I need parameter id for Scrap(AFRUD-XMNGA) field in CO11N transaction. But the scrap field do not have the parameter id. So I created...
Read more >
Custom operation IDs for single document, and not the other
Step 1: Set operation ids​​ Actions have no operation ids by default, so use SwaggerGenOptions. CustomOperationIds() to populate the values.
Read more >
Mysterious error in custom connector appearing aft...
I went to go in an add another action to a custom connector I have. This would the 11th one. I've been using...
Read more >
Question: Custom connector: parameter in the operation
I'm developing a custom connector and was wondering if there's a way to expose parameters that can be accepted for a specific operation....
Read more >
On a custom object I get this error on Conga Composer button
when I click the button on the parts list view, I get the error that the id parameter is missing. What am I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found