How to set deepObject properties type
mikaelz opened this issue · 1 comments
mikaelz commented
Hi, need to generate following OAS
- name: filters
in: query
style: deepObject
schema:
type: object
properties:
name:
type: string
nullable: true
ttl:
type: integer
nullable: true
content:
type: string
nullable: true
But with
private function describeFilters(ReflectionClass $searchClass, OA\Parameter $filters): void
{
$allRules = $searchClass->newInstanceWithoutConstructor()->rules();
foreach ($allRules as $field => $rules) {
if (str_starts_with($field, 'filters.')) {
Util::getProperty($filters->schema, str_replace('filters.', '', $field));
}
}
I get
- name: filters
in: query
style: deepObject
schema:
properties:
name: {}
type: {}
content: {}
ttl: {}
note: {}
priority: {}
port: {}
weight: {}
flags: {}
tag: {}
type: object
How can I set each properties type?
Thanks for helping out.
mikaelz commented
Finally, after days of trial&error
private function describeFilters(ReflectionClass $searchClass, OA\Parameter $filters): void
{
$allRules = $searchClass->newInstanceWithoutConstructor()->rules();
foreach ($allRules as $field => $rules) {
if (str_starts_with($field, 'filters.')) {
$property = Util::getProperty($filters->schema, str_replace('filters.', '', $field));
if ($rules[1] !== 'array') {
$property->type = $rules[1];
$property->nullable = $rules[0];
}
}
}
}
Just need to handle array type