Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not resolved items type for array if classess in different namespaces #1293

Closed
Volonda opened this issue Jul 27, 2022 · 1 comment · Fixed by #1294
Closed

Not resolved items type for array if classess in different namespaces #1293

Volonda opened this issue Jul 27, 2022 · 1 comment · Fixed by #1294
Labels

Comments

@Volonda
Copy link

Volonda commented Jul 27, 2022

 namespace App\NS1;

use App\NS2\Item;
use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;
 
#[Schema(schema: 'Collection')]
class Collection
{
    /**
     * @var Item[]|null
     */
    #[Property]
    public ?array $collection = null;
}
namespace App\NS2;

use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;

#[Schema(schema: 'Item')]
class Item
{
    /**
     * @var string|null
     */
    #[Property]
    public ?string $propery = null;
}

This will generate schema

{
    "openapi": "3.0.0",
    "components": {
        "schemas": {
            "Collection": {
                "description": "Collection",
                "properties": {
                    "collection": {
                        "type": "array",
                        "items": {},
                        "nullable": true
                    }
                },
                "type": "object"
            },
            "Item": {
                "description": "Item",
                "properties": {
                    "propery": {
                        "type": "string",
                        "nullable": true
                    }
                },
                "type": "object"
            }
        }
    }
}

There is no "ref" in "items", but it work fine in legacy mode with annotations (openapi -l)

Here will be invalid $refKey value

$refKey = $this->toRefKey($context, $type);

Also it is work fine if i specify fully qualified namespace

class Collection
{
    /**
     * @var \App\NS2\Item[]|null
     */
    #[Property]
    public ?array $collection = null;
}
@DerManoMann
Copy link
Collaborator

Closed via #1294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants