remove mimes validation within edocument endpoint, because ParseEDocument handles this + minor code cleanups

This commit is contained in:
paulwer 2024-09-15 08:18:07 +02:00
parent 9ced189262
commit 3aa17bd6cd
3 changed files with 50 additions and 4 deletions

View File

@ -584,6 +584,52 @@ class ExpenseController extends BaseController
return $this->itemResponse($expense->fresh());
}
/**
* @OA\Post(
* path="/api/v1/expenses/edocument",
* operationId="edocumentExpense",
* tags={"expenses"},
* summary="Uploads an electronic document to a expense",
* description="Handles the uploading of an electronic document to a expense",
* @OA\Parameter(ref="#/components/parameters/X-API-TOKEN"),
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
* @OA\Parameter(ref="#/components/parameters/include"),
* @OA\RequestBody(
* description="User credentials",
* required=true,
* @OA\MediaType(
* mediaType="multipart/form-data",
* @OA\Schema(
* type="array",
* @OA\Items(
* type="string",
* format="binary",
* description="The files to be uploaded",
* ),
* )
* )
* ),
* @OA\Response(
* response=200,
* description="Returns a HTTP status",
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
* ),
* @OA\Response(
* response=422,
* description="Validation error",
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
*
* ),
* @OA\Response(
* response="default",
* response="default",
* description="Unexpected Error",
* @OA\JsonContent(ref="#/components/schemas/Error"),
* ),
* )
*/
public function edocument(EDocumentRequest $request)
{
$user = auth()->user();

View File

@ -25,9 +25,9 @@ class EDocumentRequest extends Request
$rules = [];
if ($this->file('documents') && is_array($this->file('documents'))) {
$rules['documents.*'] = 'required|file|max:1000000|mimes:xml';
$rules['documents.*'] = 'required|file|max:1000000';
} elseif ($this->file('documents')) {
$rules['documents'] = 'required|file|max:1000000|mimes:xml';
$rules['documents'] = 'required|file|max:1000000';
}
return $rules;
}