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

[OpenAPI] Typing Issue with openapiContext in #[ApiProperty] Leading to any in Documentation #6893

Open
SebLevDev opened this issue Jan 7, 2025 · 0 comments

Comments

@SebLevDev
Copy link
Contributor

API Platform version(s) affected: 4.x

Description
When I specify an openapiContext in my #[ApiProperty], the typing of the same property is no longer used, and I am forced to explicitly specify it within the openapiContext array.

As a result, both Swagger and ReDoc documentation display the field as any.

We have observed this issue with several strictly typed fields in PHP, such as bool, DateTimeImmutable, and others.

How to reproduce
this configuration provide a any type in the documentation

#[ApiProperty(
    openapiContext: [
        'description' => 'The date on which the Article was created or the item was added to a feed.'
    ],
    types: ['https://schema.org/datePublished']
)]
#[Groups(['Article:Read:List'])]
public ?\DateTimeImmutable $publishedAt = null,

Additional Context
Here is the dump of $propertySchema in ApiPlatform\JsonSchema\SchemaFactory

array:2 [▼
  "externalDocs" => array:1 [▼
    "url" => "https://schema.org/datePublished"
  ]
  "description" => "The date on which the News was created or the item was added to a feed."
]

if i remove the openapiContext in my ApiProperty attribute

#[ApiProperty]
#[Groups(['Article:Read:List'])]
public ?\DateTimeImmutable $publishedAt = null,

The dump returned is good

array:2 [▼
  "type" => array:2 [▼
    0 => "string"
    1 => "null"
  ]
  "format" => "date-time"
]
@SebLevDev SebLevDev changed the title [OpenAPI] Typing Issue with openapiContext in `#[ApiProperty] Leading to *any* in Documentation [OpenAPI] Typing Issue with openapiContext in #[ApiProperty] Leading to *any* in Documentation Jan 7, 2025
@SebLevDev SebLevDev changed the title [OpenAPI] Typing Issue with openapiContext in #[ApiProperty] Leading to *any* in Documentation [OpenAPI] Typing Issue with openapiContext in #[ApiProperty] Leading to **any** in Documentation Jan 7, 2025
@SebLevDev SebLevDev changed the title [OpenAPI] Typing Issue with openapiContext in #[ApiProperty] Leading to **any** in Documentation [OpenAPI] Typing Issue with openapiContext in #[ApiProperty] Leading to any in Documentation Jan 7, 2025
SebLevDev added a commit to SebLevDev/api-platform-core that referenced this issue Jan 10, 2025
…ing to any in Documentation

Cfr api-platform#6893
When specify an openapiContext in #[ApiProperty], the typing of the same property is no longer used, and force to explicitly specify it within the openapiContext array.
SebLevDev added a commit to SebLevDev/api-platform-core that referenced this issue Jan 10, 2025
…Leading to `any` in Documentation

When specify an `openapiContext` in #`[ApiProperty]`, the typing of the same property is no longer used, and force to explicitly specify it within the openapiContext array.

Cfr: api-platform#6893
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant