From 1f454becb44ecbbac1f7f4d793f1d349a4d1d39a Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Mon, 13 Jan 2020 14:09:25 +0100 Subject: [PATCH] Update to the swagger decorator --- .env | 1 - api/helm/values.yaml | 2 +- api/public/schema/publiccode.yaml | 2 +- api/src/Entity/ExampleEntity.php | 2 +- api/src/Swagger/SwaggerDecorator.php | 43 ++++++++++++++++++++++++---- 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/.env b/.env index dfe3cdd5..11c5b8a5 100644 --- a/.env +++ b/.env @@ -23,7 +23,6 @@ APP_BUILD=dev # The description for this api APP_DESCRIPTION='Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.' - APP_LOGO=pc.zaakonline.nl APP_HOME=pc.zaakonline.nl diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 4ebf495f..36ca75cf 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -28,7 +28,7 @@ settings: debug: 1 replicaCount: 1 corsAllowOrigin: ['*'] - trustedHosts: '^(.+\.)?conduction\.nl$|^(.+\.)?vng\.cloud$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.dev$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost' + trustedHosts: '^(.+\.)?conduction\.nl$|^(.+\.)?huwelijksplanner\.online$|^(.+\.)?larping\.eu$|^(.+\.)?common-ground\.dev$|^(.+\.)?trouwplanner\.online$|^(.+\.)?zaakonline\.nl$|localhost' pullPolicy: Always # You will need these proxies on kubernetes trustedProxies: diff --git a/api/public/schema/publiccode.yaml b/api/public/schema/publiccode.yaml index 66f44a92..a1bd7f55 100644 --- a/api/public/schema/publiccode.yaml +++ b/api/public/schema/publiccode.yaml @@ -6,7 +6,7 @@ url: "https://github.com/ConductionNL/Proto-component-commonground" landingURL: "pc.zaakonline.nl" isBasedOn: "https://github.com/ConductionNL/Proto-component-commonground.git" softwareVersion: "V.0.1" -releaseDate: "2020-01-01" +releaseDate: "2020-13-01" logo: pc.zaakonline.nl monochromeLogo: img/logo-mono.svg diff --git a/api/src/Entity/ExampleEntity.php b/api/src/Entity/ExampleEntity.php index 2e65a2ba..c44245cd 100644 --- a/api/src/Entity/ExampleEntity.php +++ b/api/src/Entity/ExampleEntity.php @@ -37,7 +37,7 @@ class ExampleEntity { /** - * @var \Ramsey\Uuid\UuidInterface + * @var \Ramsey\Uuid\UuidInterface The id of this entity * * @example e2984465-190a-4562-829e-a8cca81aa35d * diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index b0610232..9f09248e 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -416,15 +416,22 @@ private function getAdditionalEntityDocs($entity) $docblock = $factory->create($property->getDocComment()); $tags = $docblock->getTags(); $atributes = []; - $groups = []; + $groups = []; + foreach ($tags as $tag) { $name = $tag->getName(); - $description = $tag->getDescription(); - // - //$description = (string) $description; + $description = $tag->getDescription(); switch ($name) { + + // Description + case 'var': + $atributes['description'] = (string) $description; + $atributes['type'] = (string) $tag->getType(); + + break; + // Docblocks case 'example': $atributes['example'] = (string) $description; @@ -436,23 +443,49 @@ private function getAdditionalEntityDocs($entity) $groups = $propertyAnnotation->getGroups(); break; - // Constrainds (Validation) + // Constrainds (Validation) + case "Assert\Date": + $atributes['type'] = "string"; + $atributes['format'] = 'date'; + $atributes['example'] = \date('Y-m-d'); + break; + case "Assert\DateTime": + $atributes['type'] = "string"; + $atributes['format'] = 'date-time'; + $atributes['example'] = \date('Y-m-d H:i:s'); + break; + case "Assert\Time": + $atributes['type'] = "string"; + $atributes['format'] = 'time'; + $atributes['example'] = \date('H:i:s'); + break; + case "Assert\Timezone": + $atributes['type'] = "string"; + $atributes['format'] = 'timezone'; + $atributes['example'] = 'America/New_York'; + break; case "Assert\Uuid": + $atributes['type'] = "string"; $atributes['format'] = 'uuid'; break; case "Assert\Email": + $atributes['type'] = "string"; $atributes['format'] = 'email'; break; case "Assert\Url": + $atributes['type'] = "string"; $atributes['format'] = 'url'; break; case "Assert\Regex": + $atributes['type'] = "string"; $atributes['format'] = 'regex'; break; case "Assert\Ip": + $atributes['type'] = "string"; $atributes['format'] = 'ip'; break; case "Assert\Json": + $atributes['type'] = "string"; $atributes['format'] = 'json'; break; case "Assert\Choice":