Skip to content

Generating Typescript interfaces requires a GET collection operation. #309

@Crovitche-1623

Description

@Crovitche-1623

API Platform version(s) affected: 2.6.6

Description
A GET collection operation (not item operation as specified in error) is required to generate Typescript interfaces. If it's missing, this error occurs:
Error: Unable to find the URL for "https://localhost:9000/docs.jsonld#Entrypoint/entity", make sure your api resource has at least one GET item operation declared.
Why is this operation required ?

How to reproduce
Create an Api Resource without a GET collection operation and run this command:
NODE_TLS_REJECT_UNAUTHORIZED=0 npx @api-platform/client-generator --generator typescript https://localhost:9000/ src/

Workaround
Make the operation accessible to administrators using a security_access:

#[ApiResource(
    collectionOperations: [
        // this collection operation is required to generate Typescript Interfaces
        'get' => ["security" => "is_granted('ROLE_ADMIN')"]
    ]
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions