generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 187
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
The generated JSON specification for enum arrays is potentially incorrect.
How to reproduce the bug
Take the following code:
class AnalyticsDataRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'metrics' => ['nullable', 'array', Rule::in(MetricsEnum::values())],
// ...
];
}
}
It generates the following OpenAPI json:
{
"name": "metrics",
"in": "query",
"required": true,
"schema": {
"type": "array",
"enum": [
"product_requirements_mandatory_completed",
"product_requirements_optional_completed",
"product_requirements_total_completed"
],
"items": {
"type": "string"
},
"minItems": 1
}
},
In Stoplight it generates an enum array, as expected.
In openapi-typescript on the other hand it generates a union instead.
An openapi-typescript developer believes that the JSON specification is incorrect and should be the following instead:
{
"name": "metrics",
"in": "query",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string",
"enum": [
"product_requirements_mandatory_completed",
"product_requirements_optional_completed",
"product_requirements_total_completed"
]
},
"minItems": 1
}
}
This syntax works in both openapi-typescript and Stoplight.
Package Version
0.12.19
PHP Version
Will fill out later
Laravel Version
Will fill out later
Which operating systems does with happen with?
Linux
Notes
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working