PHP code example of og-soft / laravel-openapi-value-object
1. Go to this page and download the library: Download og-soft/laravel-openapi-value-object library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
og-soft / laravel-openapi-value-object example snippets
class UserCreateRequestBody extends RequestBodyFactory
{
public function build(): RequestBody
{
return RequestBody::create('UserCreate')
->description('User data')
->content(
MediaType::json()->schema(UserSchema::ref())
);
}
}
class CarRequest
{
/**
* Car name <-- auto parsed title
*
* This is a car name description... <-- auto parsed description
*
* @var string
*/
protected string $name;
/**
* Engine power in kW
*
* More is better
*
* @var int
*/
protected int $enginePower;
/**
* Wheels of car
*
* It is necessary to move
* @var WheelValueObject[]
*/
protected array $wheels;
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return CarValueObject
*/
public function setName(string $name): CarValueObject
{
$this->name = $name;
return $this;
}
/**
* @return int
*/
public function getEnginePower(): int
{
return $this->enginePower;
}
/**
* @param int $enginePower
* @return CarValueObject
*/
public function setEnginePower(int $enginePower): CarValueObject
{
$this->enginePower = $enginePower;
return $this;
}
/**
* @return WheelValueObject[]
*/
public function getWheels(): array
{
return $this->wheels;
}
/**
* @param WheelValueObject[] $wheels
* @return CarValueObject
*/
public function setWheels(WheelValueObject ...$wheels): CarValueObject
{
$this->wheels = $wheels;
return $this;
}
}