Skip to content

[Bug]: Return types not generated #2682

@klkvsk

Description

@klkvsk

Version

5.9.2

Description

If a controller has a DTO return type, it is ignored. Neither native return type nor php-doc @return type are added to the schema.

    #[Route('/api/test', name: 'api_test', methods: [ 'GET' ])]
    public function index(): NameDto
    {
        return new NameDto();
    }
class NameDto
{
    public string $first = "John";
    public string $last = "Doe";
}

JSON OpenApi

JSON OpenApi
{
    "openapi": "3.0.0",
    "info": {
        "title": "My App",
        "description": "This is an awesome app!",
        "version": "1.0.0"
    },
    "paths": {
        "/api/test": {
            "get": {
                "operationId": "get_api_test",
                "responses": {
                    "default": {
                        "description": ""
                    }
                }
            }
        }
    }
}

Additional context

This is not a question of adding OA\Response attribute. While this is always an option, a leaner approach should be to get the responses described automatically, same as QueryParameters and RequestPayloads controller arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions