Skip to content

Commit 36496bb

Browse files
authored
Merge pull request #30 from DoclerLabs/only-add-needed-content-type-serializers
only add needed content type serializers
2 parents 8da1831 + 1a436c7 commit 36496bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+187
-201
lines changed

.php_cs.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'array_syntax' => ['syntax' => 'short'],
1414
'no_multiline_whitespace_before_semicolons' => true,
1515
'no_short_echo_tag' => true,
16+
'no_unused_imports' => true,
1617
'not_operator_with_successor_space' => true,
1718
'no_useless_else' => true,
1819
'ordered_imports' => [

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77

8+
## [5.1.0] - 2021-04-02
9+
### Changed
10+
- Only content type serializers which are used are included
11+
812
## [5.0.0] - 2021-02-15
913
### Changed
1014
- By default, the PHP version used in the generated client is 7.4.

example/gen/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ docker run -it \
1111
-e OPENAPI=/openapi.yaml \
1212
-e OUTPUT_DIR=/client \
1313
-e PACKAGE=openapi/pet-store-client \
14-
-e CLIENT_PHP_VERSION=7.2 \
14+
-e CLIENT_PHP_VERSION=7.4 \
1515
dhlabs/api-client-generator
1616
```
1717

example/gen/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"sort-packages": true
99
},
1010
"require": {
11-
"php": ">=7.2",
11+
"php": ">=7.4",
1212
"docler-labs/api-client-exception": "^1.0",
1313
"guzzlehttp/psr7": "^1.6",
1414
"pimple/pimple": "^3.3",

example/gen/src/Request/AddPetRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
class AddPetRequest implements RequestInterface
1414
{
15-
/** @var Pet */
16-
private $pet;
15+
private Pet $pet;
1716

18-
/** @var string */
19-
private $contentType;
17+
private string $contentType;
2018

2119
public function __construct(Pet $pet, string $contentType)
2220
{

example/gen/src/Request/CreateUserRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
class CreateUserRequest implements RequestInterface
1414
{
15-
/** @var User */
16-
private $user;
15+
private User $user;
1716

18-
/** @var string */
19-
private $contentType;
17+
private string $contentType;
2018

2119
public function __construct(User $user, string $contentType)
2220
{

example/gen/src/Request/CreateUsersWithListInputRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
class CreateUsersWithListInputRequest implements RequestInterface
1414
{
15-
/** @var UserCollection */
16-
private $createUsersWithListInputRequestBody;
15+
private UserCollection $createUsersWithListInputRequestBody;
1716

18-
/** @var string */
19-
private $contentType = 'application/json';
17+
private string $contentType = 'application/json';
2018

2119
public function __construct(UserCollection $createUsersWithListInputRequestBody)
2220
{

example/gen/src/Request/DeleteOrderRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
class DeleteOrderRequest implements RequestInterface
1212
{
13-
/** @var int */
14-
private $orderId;
13+
private int $orderId;
1514

16-
/** @var string */
17-
private $contentType = '';
15+
private string $contentType = '';
1816

1917
public function __construct(int $orderId)
2018
{

example/gen/src/Request/DeletePetRequest.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212

1313
class DeletePetRequest implements RequestInterface
1414
{
15-
/** @var string|null */
16-
private $apiKey;
15+
private ?string $apiKey = null;
1716

18-
/** @var int */
19-
private $petId;
17+
private int $petId;
2018

21-
/** @var string */
22-
private $contentType = '';
19+
private string $contentType = '';
2320

2421
public function __construct(int $petId)
2522
{

example/gen/src/Request/DeleteUserRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
class DeleteUserRequest implements RequestInterface
1212
{
13-
/** @var string */
14-
private $username;
13+
private string $username;
1514

16-
/** @var string */
17-
private $contentType = '';
15+
private string $contentType = '';
1816

1917
public function __construct(string $username)
2018
{

example/gen/src/Request/FindPetsByStatusRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ class FindPetsByStatusRequest implements RequestInterface
2121

2222
public const ALLOWED_STATUS_LIST = [self::STATUS_AVAILABLE, self::STATUS_PENDING, self::STATUS_SOLD];
2323

24-
/** @var string|null */
25-
private $status;
24+
private ?string $status = null;
2625

27-
/** @var string */
28-
private $contentType = '';
26+
private string $contentType = '';
2927

3028
public function getContentType(): string
3129
{

example/gen/src/Request/FindPetsByTagsRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
class FindPetsByTagsRequest implements RequestInterface
1414
{
15-
/** @var string[]|null */
16-
private $tags;
15+
private ?array $tags = null;
1716

18-
/** @var string */
19-
private $contentType = '';
17+
private string $contentType = '';
2018

2119
public function getContentType(): string
2220
{

example/gen/src/Request/GetInventoryRequest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
class GetInventoryRequest implements RequestInterface
1212
{
13-
/** @var string */
14-
private $contentType = '';
13+
private string $contentType = '';
1514

1615
public function getContentType(): string
1716
{

example/gen/src/Request/GetOrderByIdRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
class GetOrderByIdRequest implements RequestInterface
1212
{
13-
/** @var int */
14-
private $orderId;
13+
private int $orderId;
1514

16-
/** @var string */
17-
private $contentType = '';
15+
private string $contentType = '';
1816

1917
public function __construct(int $orderId)
2018
{

example/gen/src/Request/GetPetByIdRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
class GetPetByIdRequest implements RequestInterface
1212
{
13-
/** @var int */
14-
private $petId;
13+
private int $petId;
1514

16-
/** @var string */
17-
private $contentType = '';
15+
private string $contentType = '';
1816

1917
public function __construct(int $petId)
2018
{

example/gen/src/Request/GetUserByNameRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010

1111
class GetUserByNameRequest implements RequestInterface
1212
{
13-
/** @var string */
14-
private $username;
13+
private string $username;
1514

16-
/** @var string */
17-
private $contentType = '';
15+
private string $contentType = '';
1816

1917
public function __construct(string $username)
2018
{

example/gen/src/Request/LoginUserRequest.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212

1313
class LoginUserRequest implements RequestInterface
1414
{
15-
/** @var string|null */
16-
private $username;
15+
private ?string $username = null;
1716

18-
/** @var string|null */
19-
private $password;
17+
private ?string $password = null;
2018

21-
/** @var string */
22-
private $contentType = '';
19+
private string $contentType = '';
2320

2421
public function getContentType(): string
2522
{

example/gen/src/Request/LogoutUserRequest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
class LogoutUserRequest implements RequestInterface
1212
{
13-
/** @var string */
14-
private $contentType = '';
13+
private string $contentType = '';
1514

1615
public function getContentType(): string
1716
{

example/gen/src/Request/Mapper/GuzzleRequestMapper.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717

1818
class GuzzleRequestMapper implements RequestMapperInterface
1919
{
20-
/** @var BodySerializer */
21-
private $bodySerializer;
20+
private BodySerializer $bodySerializer;
2221

23-
/** @var QuerySerializer */
24-
private $querySerializer;
22+
private QuerySerializer $querySerializer;
2523

2624
public function __construct(BodySerializer $bodySerializer, QuerySerializer $querySerializer)
2725
{

example/gen/src/Request/PlaceOrderRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
class PlaceOrderRequest implements RequestInterface
1414
{
15-
/** @var Order */
16-
private $order;
15+
private Order $order;
1716

18-
/** @var string */
19-
private $contentType;
17+
private string $contentType;
2018

2119
public function __construct(Order $order, string $contentType)
2220
{

example/gen/src/Request/UpdatePetRequest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
class UpdatePetRequest implements RequestInterface
1414
{
15-
/** @var Pet */
16-
private $pet;
15+
private Pet $pet;
1716

18-
/** @var string */
19-
private $contentType;
17+
private string $contentType;
2018

2119
public function __construct(Pet $pet, string $contentType)
2220
{

example/gen/src/Request/UpdatePetWithFormRequest.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@
1212

1313
class UpdatePetWithFormRequest implements RequestInterface
1414
{
15-
/** @var int */
16-
private $petId;
15+
private int $petId;
1716

18-
/** @var string|null */
19-
private $name;
17+
private ?string $name = null;
2018

21-
/** @var string|null */
22-
private $status;
19+
private ?string $status = null;
2320

24-
/** @var string */
25-
private $contentType = '';
21+
private string $contentType = '';
2622

2723
public function __construct(int $petId)
2824
{

example/gen/src/Request/UpdateUserRequest.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@
1212

1313
class UpdateUserRequest implements RequestInterface
1414
{
15-
/** @var string */
16-
private $username;
15+
private string $username;
1716

18-
/** @var User */
19-
private $user;
17+
private User $user;
2018

21-
/** @var string */
22-
private $contentType;
19+
private string $contentType;
2320

2421
public function __construct(string $username, User $user, string $contentType)
2522
{

example/gen/src/Schema/Category.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313
class Category implements SerializableInterface, JsonSerializable
1414
{
15-
/** @var int|null */
16-
private $id;
15+
private ?int $id = null;
1716

18-
/** @var string|null */
19-
private $name;
17+
private ?string $name = null;
2018

2119
public function setId(int $id): self
2220
{

example/gen/src/Schema/Mapper/PetCollectionMapper.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
class PetCollectionMapper implements SchemaMapperInterface
1414
{
15-
/** @var PetMapper */
16-
private $petMapper;
15+
private PetMapper $petMapper;
1716

1817
public function __construct(PetMapper $petMapper)
1918
{

example/gen/src/Schema/Mapper/PetMapper.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313

1414
class PetMapper implements SchemaMapperInterface
1515
{
16-
/** @var CategoryMapper */
17-
private $categoryMapper;
16+
private CategoryMapper $categoryMapper;
1817

19-
/** @var TagCollectionMapper */
20-
private $tagCollectionMapper;
18+
private TagCollectionMapper $tagCollectionMapper;
2119

2220
public function __construct(CategoryMapper $categoryMapper, TagCollectionMapper $tagCollectionMapper)
2321
{

example/gen/src/Schema/Mapper/TagCollectionMapper.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
class TagCollectionMapper implements SchemaMapperInterface
1414
{
15-
/** @var TagMapper */
16-
private $tagMapper;
15+
private TagMapper $tagMapper;
1716

1817
public function __construct(TagMapper $tagMapper)
1918
{

example/gen/src/Schema/Order.php

+6-12
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,17 @@ class Order implements SerializableInterface, JsonSerializable
2222

2323
public const ALLOWED_STATUS_LIST = [self::STATUS_PLACED, self::STATUS_APPROVED, self::STATUS_DELIVERED];
2424

25-
/** @var int|null */
26-
private $id;
25+
private ?int $id = null;
2726

28-
/** @var int|null */
29-
private $petId;
27+
private ?int $petId = null;
3028

31-
/** @var int|null */
32-
private $quantity;
29+
private ?int $quantity = null;
3330

34-
/** @var DateTimeInterface|null */
35-
private $shipDate;
31+
private ?DateTimeInterface $shipDate = null;
3632

37-
/** @var string|null */
38-
private $status;
33+
private ?string $status = null;
3934

40-
/** @var bool|null */
41-
private $complete;
35+
private ?bool $complete = null;
4236

4337
public function setId(int $id): self
4438
{

0 commit comments

Comments
 (0)