API Platform Documentation Issue: Incorrectly Treating Route Parameter as Required ID

I’m encountering an issue with API Platform where it seems to treat a route parameter as a required idBadge, even though it’s not specified as such in my route configuration. Here’s the setup:

I have a Symfony controller method that retrieves a badge by its matricule (a specific identifier):

php

/**
 * @Route("/badges_search/{matricule}", name="app_search_badge_matricule", methods={"GET"})
 */
public function searchBadgeByMatricule(SerializerInterface $serializer, BadgeRepository $badgeRepository, string $matricule): Response
{
    $badge = $badgeRepository->findOneBy(['matricule' => $matricule]);
    if (!$badge) {
        return new Response(null, 404);
    }

    $badgeSerialize = $serializer->serialize($badge, 'json');
    return new Response($badgeSerialize, 200, ['content-type' => 'application/json']);
}

However, when I view the generated API documentation, it incorrectly lists idBadge as a required parameter, even though idBadge is not part of my route parameters or specified anywhere in my annotations.

Here is my Badge class

<?php

namespace AppEntity;

use ApiPlatformMetadataApiResource;
use AppRepositoryBadgeRepository;
use DoctrineORMMapping as ORM;
use ApiPlatformMetadataGet;
use ApiPlatformMetadataGetCollection;

#[ORMEntity(repositoryClass: BadgeRepository::class)]
#[ORMTable(name : "badge")]
#[ApiResource(
    operations: [
        new Get(),
        new GetCollection(),
        new Get(name: "recherche_badge_matricule",
        routeName: "app_search_badge_matricule",
        openapiContext: [
            "parameters" => [
                [
                    "name" => "matricule",
                    "in" => "path",
                    "required" => true,
                    "type" => "string",
                    "description" => "Matricule du badge"
                ]
                ],
                "responses" => [
                    "200" => [
                        "description" => "Badge trouvé",
                        "content" => [
                            "application/json" => [
                                "schema" => [
                                    "type" => "object",
                                    "properties" => [
                                        "idBadge" => [
                                            "type" => "integer"
                                        ],
                                        "matricule" => [
                                            "type" => "integer"
                                        ],
                                        "numeroBadge" => [
                                            "type" => "integer"
                                        ],
                                        "soldeBadge" => [
                                            "type" => "number"
                                        ]
                                    ]
                                ]
                            ]
                        ]
                    ],
                    "404" => [
                        "description" => "Badge non trouvé"
                    ]
                ],
                "summary" => "Recherche d'un badge par matricule",
                "description" => "Recherche d'un badge par matricule"
                
        ])
    ]
)]
class Badge
{
    #[ORMId]
    #[ORMGeneratedValue]
    #[ORMColumn(name: "idBadge")]
    private ?int $idBadge = null;

    #[ORMColumn(name: "matricule")]
    private ?int $matricule = null;

    #[ORMColumn(name: "numeroBadge")]
    private ?int $numeroBadge = null;

    #[ORMColumn(name: "soldeBadge")]
    private ?float $soldeBadge = null;

I’m on this problem since yesterday but the documentation continues to show idBadge as a required parameter.

A screen of my API Platform Documentation

I’ve tried several annotations but can’t seem to figure out where the issue is coming from. I’ve reviewed my entity and controller annotations multiple times, but the documentation still incorrectly lists idBadge as a required parameter. I’m not sure if the problem lies within the class definition or the controller configuration. Despite clearing caches and checking for any misconfigurations, I can’t find the source of the issue. Being new to API Platform, it’s likely a simple mistake in my annotations that I’m overlooking. Any guidance on how to correctly set up the documentation to reflect matricule as a path parameter without mistakenly identifying it as an idBadge would be greatly appreciated.

Could anyone advise on how to clarify to API Platform that matricule is not an idBadge and ensure it’s correctly documented as a path parameter without confusing it with other entity identifiers?

Thank you!

New contributor

Esteban RACINE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật