Skip to content

Commit 5a0df0f

Browse files
authored
Merge pull request #99 from php-api-clients/fix-example-generated-type-detection
Fix example generated type detection
2 parents 4dd2b04 + a1440c4 commit 5a0df0f

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ help: ## Show this help ###
7070
@printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
7171
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#'
7272

73-
generate-clients:
74-
ls ./etc/clients | xargs -I % ./vendor/bin/openapi-client-generator ./etc/clients/%
73+
generate-client:
74+
$(DOCKER_RUN) php ./bin/openapi-client-generator ./openapi-client.yaml

src/Gatherer/Property.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ public static function gather(
4646
);
4747
if ($type->type=== 'object') {
4848
$exampleData = ($exampleData ?? []) + $type->payload->example;
49-
} else {
50-
if ($exampleData === null) {
51-
if ($type->type === 'int') {
52-
$exampleData = 13;
53-
} elseif ($type->type === 'bool') {
54-
$exampleData = false;
55-
} else {
56-
$exampleData = 'generated_' . $propertyName;
57-
}
49+
} else if ($exampleData === null && $type->type=== 'scalar') {
50+
if ($type->payload === 'int') {
51+
$exampleData = 13;
52+
} elseif ($type->payload === 'bool') {
53+
$exampleData = false;
54+
} else {
55+
$exampleData = 'generated_' . $propertyName;
5856
}
5957
}
6058

0 commit comments

Comments
 (0)