service->generatePreview($modelId, $request->validated()); }, __('message.bom.preview_generated')); } /** * @OA\Post( * path="/v1/design/models/{modelId}/validate-parameters", * summary="Validate model parameters", * description="Validate input parameters against model constraints before BOM resolution", * security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}}, * tags={"BOM Resolver"}, * @OA\Parameter( * name="modelId", * description="Model ID", * in="path", * required=true, * @OA\Schema(type="integer", example=1) * ), * @OA\RequestBody( * required=true, * @OA\JsonContent( * @OA\Property( * property="input_parameters", * description="Input parameter values to validate", * type="object", * additionalProperties=@OA\Property(oneOf={ * @OA\Schema(type="number"), * @OA\Schema(type="string"), * @OA\Schema(type="boolean") * }), * example={"W0": 1000, "H0": 800, "installation_type": "A"} * ) * ) * ), * @OA\Response( * response=200, * description="Parameter validation result", * @OA\JsonContent( * allOf={ * @OA\Schema(ref="#/components/schemas/ApiResponse"), * @OA\Schema( * @OA\Property( * property="data", * @OA\Property(property="is_valid", type="boolean", example=true), * @OA\Property( * property="validation_errors", * type="array", * @OA\Items( * @OA\Property(property="parameter", type="string", example="W0"), * @OA\Property(property="error", type="string", example="Value must be between 500 and 2000") * ) * ), * @OA\Property( * property="warnings", * type="array", * @OA\Items( * @OA\Property(property="parameter", type="string", example="H0"), * @OA\Property(property="warning", type="string", example="Recommended range is 600-1500") * ) * ) * ) * ) * } * ) * ), * @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422), * @OA\Response(ref="#/components/responses/ErrorResponse", response=400), * @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401), * @OA\Response(ref="#/components/responses/NotFoundResponse", response=404) * ) */ public function validateParameters(int $modelId) { return ApiResponse::handle(function () use ($modelId) { $inputParameters = request()->input('input_parameters', []); return $this->service->validateParameters($modelId, $inputParameters); }, __('message.parameters.validated')); } /** * @OA\Get( * path="/v1/design/models/{modelId}/parameter-schema", * summary="Get model parameter schema", * description="Retrieve the input parameter schema for a specific model", * security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}}, * tags={"BOM Resolver"}, * @OA\Parameter( * name="modelId", * description="Model ID", * in="path", * required=true, * @OA\Schema(type="integer", example=1) * ), * @OA\Response( * response=200, * description="Model parameter schema retrieved successfully", * @OA\JsonContent( * allOf={ * @OA\Schema(ref="#/components/schemas/ApiResponse"), * @OA\Schema( * @OA\Property( * property="data", * @OA\Property( * property="input_parameters", * type="array", * @OA\Items( * @OA\Property(property="name", type="string", example="W0"), * @OA\Property(property="label", type="string", example="Width"), * @OA\Property(property="data_type", type="string", example="INTEGER"), * @OA\Property(property="unit", type="string", example="mm"), * @OA\Property(property="min_value", type="number", example=500), * @OA\Property(property="max_value", type="number", example=3000), * @OA\Property(property="default_value", type="string", example="1000"), * @OA\Property(property="is_required", type="boolean", example=true), * @OA\Property(property="description", type="string", example="Product width in millimeters") * ) * ), * @OA\Property( * property="output_parameters", * type="array", * @OA\Items( * @OA\Property(property="name", type="string", example="W1"), * @OA\Property(property="label", type="string", example="Actual Width"), * @OA\Property(property="data_type", type="string", example="INTEGER"), * @OA\Property(property="unit", type="string", example="mm"), * @OA\Property(property="description", type="string", example="Calculated actual width") * ) * ) * ) * ) * } * ) * ), * @OA\Response(ref="#/components/responses/ErrorResponse", response=400), * @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401), * @OA\Response(ref="#/components/responses/NotFoundResponse", response=404) * ) */ public function getParameterSchema(int $modelId) { return ApiResponse::handle(function () use ($modelId) { return $this->service->getParameterSchema($modelId); }, __('message.fetched')); } /** * @OA\Post( * path="/v1/design/models/{modelId}/calculate-preview", * summary="Calculate output values preview", * description="Calculate output parameter values based on input parameters using formulas", * security={{"ApiKeyAuth": {}}, {"BearerAuth": {}}}, * tags={"BOM Resolver"}, * @OA\Parameter( * name="modelId", * description="Model ID", * in="path", * required=true, * @OA\Schema(type="integer", example=1) * ), * @OA\RequestBody( * required=true, * @OA\JsonContent( * @OA\Property( * property="input_parameters", * description="Input parameter values", * type="object", * additionalProperties=@OA\Property(oneOf={ * @OA\Schema(type="number"), * @OA\Schema(type="string"), * @OA\Schema(type="boolean") * }), * example={"W0": 1000, "H0": 800, "installation_type": "A"} * ) * ) * ), * @OA\Response( * response=200, * description="Output values calculated successfully", * @OA\JsonContent( * allOf={ * @OA\Schema(ref="#/components/schemas/ApiResponse"), * @OA\Schema( * @OA\Property( * property="data", * @OA\Property( * property="calculated_values", * type="object", * additionalProperties=@OA\Property(oneOf={ * @OA\Schema(type="number"), * @OA\Schema(type="string") * }), * example={"W1": 1050, "H1": 850, "area": 892500, "weight": 45.5} * ), * @OA\Property( * property="calculation_steps", * type="array", * @OA\Items( * @OA\Property(property="parameter", type="string", example="W1"), * @OA\Property(property="formula", type="string", example="W0 + 50"), * @OA\Property(property="result", oneOf={ * @OA\Schema(type="number"), * @OA\Schema(type="string") * }, example=1050) * ) * ) * ) * ) * } * ) * ), * @OA\Response(ref="#/components/responses/ValidationErrorResponse", response=422), * @OA\Response(ref="#/components/responses/ErrorResponse", response=400), * @OA\Response(ref="#/components/responses/UnauthorizedResponse", response=401), * @OA\Response(ref="#/components/responses/NotFoundResponse", response=404) * ) */ public function calculatePreview(int $modelId) { return ApiResponse::handle(function () use ($modelId) { $inputParameters = request()->input('input_parameters', []); return $this->service->calculatePreview($modelId, $inputParameters); }, __('message.calculated')); } }