Releases: butschster/LumenMicroservice
Releases · butschster/LumenMicroservice
1.22.1: Added events when route dispatched
Fixed unit tests
1.21.2
Removed console logger. Use stderr instead.
1.20
reduced version of zircote/swagger-php
Fixed problem with laravel queued jobs
1.19 Fixed return type
1.17
Fixed replyTo type for consumer
1.16: Merge pull request #9 from butschster/feature/2
Specification
- paths (subjects)
- responses
- components schema
issue #2
Example
class TestRequestPayload implements Payload
{
/**
* Ip Address
* @JMS\Type("string")
*/
public ?string $ip = null;
/**
* API Version
* @JMS\Type("string")
*/
public ?string $version = null;
/**
* Error object
* @JMS\Type("Butschster\Exchanger\Payloads\Error")
*/
public Error $error;
/**
* API Version
* @JMS\Type("DateTime<'Y-m-d', '', ['Y-m-d', 'Y/m/d']>")
*/
public DateTime $dateTime;
/**
* Array without element types
* @JMS\Type("array")
*/
public array $array = [];
/**
* Array with string element types
* @JMS\Type("array<string>")
*/
public array $arrayWithString = [];
/**
* Array with integer element types
* @JMS\Type("array<integer>")
*/
public array $arrayWithInteger = [];
/**
* Array with objects
* @JMS\Type("array<Butschster\Exchanger\Payloads\Response>")
*/
public array $responses = [];
/**
* @JMS\Type("DateTime")
*/
public $startAt;
/**
* @JMS\Type("DateTime<'Y-m-d'>")
*/
public $endAt;
/**
* @JMS\Type("DateTime<'Y-m-d', '', ['Y-m-d', 'Y/m/d']>")
*/
public $publishedAt;
/**
* @JMS\Type("DateTimeImmutable")
*/
public $createdAt;
/**
* @JMS\Type("DateTimeImmutable<'Y-m-d'>")
*/
public $updatedAt;
/**
* @JMS\Type("DateTimeImmutable<'Y-m-d', '', ['Y-m-d', 'Y/m/d']>")
*/
public $deletedAt;
/**
* @JMS\Type("boolean")
*/
public bool $published;
/**
* @JMS\Type("ArrayCollection<Butschster\Exchanger\Payloads\Error>")
*/
public $comments;
}
class TestPoint implements Point
{
public function getName(): string
{
return 'com.test';
}
/**
* Test description
* @subject com.test.action.name
* @requestPayload Butschster\Tests\Exchange\OpenApi\TestRequestPayload
* @responsePayload Butschster\Tests\Exchange\OpenApi\TestResponsePayload
*/
public function methodWithSubject(IncomingRequest $request, LoggerInterface $logger): void
{
}
/**
* @subject com.test.action.name1
* @responsePayload Butschster\Tests\Exchange\OpenApi\TestResponsePayload
*/
public function methodWithoutRequestPayload(IncomingRequest $request, LoggerInterface $logger): void
{
}
/**
* @subject com.test.action.name2
* @requestPayload Butschster\Tests\Exchange\OpenApi\TestRequestPayload
*/
public function methodWithoutResponsePayload(IncomingRequest $request, LoggerInterface $logger): void
{
}
/**
* @subject com.test.action.name3
*/
public function methodWithoutPayload(IncomingRequest $request, LoggerInterface $logger): void
{
}
}
Will generate
openapi: 3.0.0
info:
title: com.test
version: 1.0.0
servers: []
paths:
/com.test.action.name:
get:
summary: 'Test description'
parameters:
-
name: body
in: query
required: true
schema:
properties:
headers:
$ref: '#/components/schemas/RequestHeaders'
payload:
$ref: '#/components/schemas/TestRequestPayload'
type: object
responses:
default:
description: 'Something went wrong'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'200':
description: Success
content:
application/json:
schema:
properties:
success: { description: 'Response state', type: boolean }
headers: { $ref: '#/components/schemas/ResponseHeaders' }
payload: { $ref: '#/components/schemas/TestResponsePayload' }
type: object
/com.test.action.name1:
get:
summary: ''
parameters:
-
name: body
in: query
required: true
schema:
properties:
headers:
$ref: '#/components/schemas/RequestHeaders'
type: object
responses:
default:
description: 'Something went wrong'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'200':
description: Success
content:
application/json:
schema:
properties:
success: { description: 'Response state', type: boolean }
headers: { $ref: '#/components/schemas/ResponseHeaders' }
payload: { $ref: '#/components/schemas/TestResponsePayload' }
type: object
/com.test.action.name2:
get:
summary: ''
parameters:
-
name: body
in: query
required: true
schema:
properties:
headers:
$ref: '#/components/schemas/RequestHeaders'
payload:
$ref: '#/components/schemas/TestRequestPayload'
type: object
responses:
default:
description: 'Something went wrong'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/com.test.action.name3:
get:
summary: ''
parameters:
-
name: body
in: query
required: true
schema:
properties:
headers:
$ref: '#/components/schemas/RequestHeaders'
type: object
responses:
default:
description: 'Something went wrong'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Pagination:
properties:
total:
description: ''
type: integer
perPage:
description: ''
type: integer
currentPage:
description: ''
type: integer
totalPages:
description: ''
type: integer
type: object
Meta:
properties:
pagination:
$ref: '#/components/schemas/Pagination'
type: object
RequestHeaders:
properties:
ip:
description: ''
type: string
version:
description: ''
type: string
requester:
description: 'Service name that sent this request'
type: string
timestamp:
description: ''
type: string
format: date-time
meta:
$ref: '#/components/schemas/Meta'
token:
description: ''
type: string
tokenInfo:
description: ''
type: string
type: object
ResponseHeaders:
properties:
meta:
$ref: '#/components/schemas/Meta'
type: object
Trace:
properties:
file:
description: ''
type: string
line:
description: ''
type: integer
function:
description: ''
type: string
class:
description: ''
type: string
type: object
Error:
properties:
code:
description: ''
type: integer
message:
description: ''
type: string
data:
description: ''
type: array
items:
type: string
trace:
description: ''
type: array
items:
$ref: '#/components/schemas/Trace'
type: object
Headers:
properties:
meta:
$ref: '#/components/schemas/Meta'
type: object
Payload:
properties: { }
type: object
Response:
properties:
success:
description: ''
type: boolean
headers:
$ref: '#/components/schemas/Headers'
payload:
$ref: '#/components/schemas/Payload'
errors:
description: ''
type: array
items:
$ref: '#/components/schemas/Error'
type: object
TestRequestPayload:
properties:
ip:
description: 'Ip Address'
type: string
version:
description: 'API Version'
type: string
error:
$ref: '#/components/schemas/Error'
dateTime:
description: 'API Version'
type: string
format: date-time
array:
description: 'Array without element types'
type: array
items:
type: string
arrayWithString:
description: 'Array with string element types'
type: array
items:
type: string
arrayWithInteger:
description: 'Array with integer element types'
type: array
items:
type: integer
responses:
description: 'Array with objects'
type: array
items:
$ref: '#/components/schemas/Response'
startAt:
description: ''
type: string
format: date-time
endAt:
description: ''
type: string
format: date-time
publishedAt:
des...
1.15
- Added ability to acknowledge incoming request
/**
* @subject com.test.action.test
*/
public function testSubject(IncomingRequest $request)
{
...
$request->acknowledge();
}
- Improved DependencyResolver. It was moved to separate class and added ability to resolve payload parts.
/**
* @subject com.test.action.test
*/
public function testSubject(IncomingRequest $request, GetUserById $payload)
{
$user = $this->userRepository->getById($payload->userId)';
...
$request->sendResponse($userPayload);
}
- Added ability to extends attribute map
//config/serializer.php
'mapping' => [
Domain\User\Entities\User::class => [
'to' => Payloads\User::class,
'attributes' => [
'id' => ['type' => 'string'],
'username' => ['type' => 'string'],
'email' => ['type' => 'string'],
'createdAt' => ['type' => \Carbon\Carbon::class]
]
],
Domain\Model\Entities\Model::class => [
'to' => Payloads\Model::class,
'extends' => Domain\User\Entities\User::class, // Here we extend attributes from User
'attributes' => [
'studio' => ['type' => Domain\Model\Entities\Model::class,]
]
],
],
- Added missed container resolving for IncomingRequest
- Added ability to set persistent mode for outgoing messages
- Registered console command for Laravel
- Added missed phpdoc
- Added unittests
v1.7
- Added ServiceProvider for Laravel
- Fixed carbon handler format
- Fixed Request payload prop type
- Removed exchange point prefix from subjects, cause we can use subjects to subscribe on broadcasts
v1.4
- Added ability to convert objects to payloads. Now you can easily describe how to convert objects to payloads in serializer config and then just use converter.
// config/serializer.phpreturn [
'handlers' => [
// ...
],
'mapping' => [
Money\Token::class => [
'to' => Microservice\Payloads\Billing\Token::class,
'attributes' => [
'amount' => [
'type' => \Brick\Math\BigDecimal::class
],
]
],
],
],
// Example
$token = new Money\Token(100);
$this->app[\Butschster\Exchanger\Contracts\Serializer\ObjectsMapper::class]->toPayload($token)
- Added ability manage custom serializer handlers
// config/serializer.php
return [
'handlers' => [
\Butschster\Exchanger\Jms\Handlers\CarbonHandler::class,
\Microservice\Jms\Handlers\BigDecimalHandler::class
],
'mapping' => [
// ...
]
];
- Fixed couple of problems in serializer
v1.2
- Added JWT token
- Added unit tests