Skip to content

Commit

Permalink
Merge pull request #54 from microsoft/dev
Browse files Browse the repository at this point in the history
Release 1.0.0 🚀
  • Loading branch information
Ndiritu authored Nov 1, 2023
2 parents a4e68d8 + aad29df commit e95e41d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

## [1.0.0] - 2023-11-01

### Changed
- Return only non-null values within deserialized collections
- Bumped abstractions to 1.0.0
- Mark package as stable

## [0.7.0] - 2023-10-30

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
},
"require": {
"microsoft/kiota-abstractions": "^0.9.0",
"microsoft/kiota-abstractions": "^1.0.0",
"guzzlehttp/psr7": "^1.6 || ^2",
"php": "^7.4 || ^8",
"ext-json": "*"
Expand Down
2 changes: 1 addition & 1 deletion src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

final class Constants
{
public const VERSION = '0.7.0';
public const VERSION = '1.0.0';
}
10 changes: 6 additions & 4 deletions src/JsonParseNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,19 @@ public function getFloatValue(): ?float {
}

/**
* @return array<Parsable|null>|null
* @inheritDoc
* @throws Exception
*/
public function getCollectionOfObjectValues(array $type): ?array {
if (!is_array($this->jsonNode)) {
return null;
}
return array_map(static function ($val) use($type) {
$result = array_map(static function ($val) use($type) {
return $val->getObjectValue($type);
}, array_map(static function ($value) {
return new JsonParseNode($value);
}, $this->jsonNode));
return array_filter($result, fn ($item) => !is_null($item));
}

/**
Expand Down Expand Up @@ -162,17 +163,18 @@ public function getEnumValue(string $targetEnum): ?Enum{
}

/**
* @return array<Enum|null>|null
* @inheritDoc
*/
public function getCollectionOfEnumValues(string $targetClass): ?array {
if (!is_array($this->jsonNode)) {
return null;
}
return array_map(static function ($val) use($targetClass) {
$result = array_map(static function ($val) use($targetClass) {
return $val->getEnumValue($targetClass);
}, array_map(static function ($value) {
return new JsonParseNode($value);
}, $this->jsonNode));
return array_filter($result, fn ($item) => !is_null($item));
}

/**
Expand Down
4 changes: 1 addition & 3 deletions tests/JsonParseNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use Microsoft\Kiota\Abstractions\Types\Time;
use Microsoft\Kiota\Serialization\Json\JsonParseNode;
use Microsoft\Kiota\Serialization\Json\JsonParseNodeFactory;
use Microsoft\Kiota\Serialization\Json\JsonSerializationWriter;
use Microsoft\Kiota\Serialization\Json\JsonSerializationWriterFactory;
use Microsoft\Kiota\Serialization\Tests\Samples\Address;
use Microsoft\Kiota\Serialization\Tests\Samples\MaritalStatus;
use Microsoft\Kiota\Serialization\Tests\Samples\Person;
Expand All @@ -36,7 +34,7 @@ public function testGetIntegerValue(): void {
}

public function testGetCollectionOfObjectValues(): void {
$str = Utils::streamFor('[{"name": "Silas Kenneth", "age": 98, "height": 123.122, "maritalStatus": "complicated,single"},{"name": "James Bay", "age": 23, "height": 163.122, "maritalStatus": "married"}]');
$str = Utils::streamFor('[{"name": "Silas Kenneth", "age": 98, "height": 123.122, "maritalStatus": "complicated,single"},{"name": "James Bay", "age": 23, "height": 163.122, "maritalStatus": "married"}, null]');
$this->parseNode = (new JsonParseNodeFactory())->getRootParseNode('application/json', $str);

/** @var array<Person> $expected */
Expand Down

0 comments on commit e95e41d

Please sign in to comment.