Skip to content

Commit 5f9af53

Browse files
authored
Merge pull request #45 from php-api-clients/support-nullable
Support nullable
2 parents ba6d597 + 18061ba commit 5f9af53

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

openapi-client.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
spec: https://raw.githubusercontent.com/octokit/webhooks/openapi/payload-schemas/openapi-schema.yml
2-
#spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml
1+
#spec: https://raw.githubusercontent.com/octokit/webhooks/openapi/payload-schemas/openapi-schema.yml
2+
spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml
33
namespace: ApiClients\Client\Github
44
destination: generated

src/Generator/Schema.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public static function generate(string $name, string $namespace, string $classNa
8181
);
8282
$setDefaylt = true;
8383
$nullable = '';
84+
if ($property->nullable) {
85+
$nullable = '?';
86+
$propertyStmt->setDefault(null);
87+
}
8488
if (is_string($property->type)) {
8589
if (is_array($schema->required) && !in_array($propertyName, $schema->required, false)) {
8690
$nullable = '?';

0 commit comments

Comments
 (0)