From a1440c45ebf3a026a619fbe667dd4725e1b22e85 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Fri, 3 Mar 2023 22:40:56 +0100 Subject: [PATCH] Fix example generated type detection --- Makefile | 4 ++-- src/Gatherer/Property.php | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 992f1c5..a257ebc 100644 --- a/Makefile +++ b/Makefile @@ -70,5 +70,5 @@ help: ## Show this help ### @printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n" @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#' -generate-clients: - ls ./etc/clients | xargs -I % ./vendor/bin/openapi-client-generator ./etc/clients/% +generate-client: + $(DOCKER_RUN) php ./bin/openapi-client-generator ./openapi-client.yaml diff --git a/src/Gatherer/Property.php b/src/Gatherer/Property.php index e67e7a4..df2dbc7 100644 --- a/src/Gatherer/Property.php +++ b/src/Gatherer/Property.php @@ -46,15 +46,13 @@ public static function gather( ); if ($type->type=== 'object') { $exampleData = ($exampleData ?? []) + $type->payload->example; - } else { - if ($exampleData === null) { - if ($type->type === 'int') { - $exampleData = 13; - } elseif ($type->type === 'bool') { - $exampleData = false; - } else { - $exampleData = 'generated_' . $propertyName; - } + } else if ($exampleData === null && $type->type=== 'scalar') { + if ($type->payload === 'int') { + $exampleData = 13; + } elseif ($type->payload === 'bool') { + $exampleData = false; + } else { + $exampleData = 'generated_' . $propertyName; } }