From 68dbf226340b75f5b6fecf2afb25009c0e16a58f Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 13 Jan 2020 14:21:57 +0100 Subject: [PATCH 1/2] Docblocks for references to other entities --- api/src/Entity/Accommodation.php | 2 ++ api/src/Entity/Place.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/api/src/Entity/Accommodation.php b/api/src/Entity/Accommodation.php index 8ec8667..461ecd6 100644 --- a/api/src/Entity/Accommodation.php +++ b/api/src/Entity/Accommodation.php @@ -166,6 +166,8 @@ class Accommodation private $resources = []; /** + * @var Place The location this accommodation belongs to + * * @Groups({"read","write"}) * @ORM\ManyToOne(targetEntity="App\Entity\Place", inversedBy="accommodations") * @ORM\JoinColumn(nullable=false) diff --git a/api/src/Entity/Place.php b/api/src/Entity/Place.php index 3a762e5..2ee67ed 100644 --- a/api/src/Entity/Place.php +++ b/api/src/Entity/Place.php @@ -185,6 +185,8 @@ class Place private $closingTime; /** + * @var Accommodation[]|ArrayCollection The accommodations in this location + * @Groups({"read", "write"}) * @ORM\OneToMany(targetEntity="App\Entity\Accommodation", mappedBy="place", orphanRemoval=true) */ private $accommodations; From 4d6f8dc4b5fb8e667cce963c587975087f442e33 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 13 Jan 2020 14:22:17 +0100 Subject: [PATCH 2/2] New SwaggerDecorator --- api/helm/values.yaml | 2 +- api/public/schema/openapi.yaml | 48 ++++++++++++++++++------- api/public/schema/publiccode.yaml | 4 +-- api/src/Swagger/SwaggerDecorator.php | 53 ++++++++++++++++++++++------ 4 files changed, 82 insertions(+), 25 deletions(-) diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 36b5528..dd6978d 100644 --- a/api/helm/values.yaml +++ b/api/helm/values.yaml @@ -10,7 +10,7 @@ settings: version: V.0.1 description: ''Naast deze JSON rest API is er ook een [graphql](/graphql) interface beschikbaar.'' repro: 'https://github.com/ConductionNL/locatiecatalogus' - subdomain: lc + subdomain: pc domains: - conduction.nl - zaakonline.nl diff --git a/api/public/schema/openapi.yaml b/api/public/schema/openapi.yaml index 3c210cf..67ae148 100644 --- a/api/public/schema/openapi.yaml +++ b/api/public/schema/openapi.yaml @@ -1175,12 +1175,10 @@ components: schemas: Accommodation-read: type: object - description: '' + description: 'A room or other accommodation that can facilitate people.' properties: id: readOnly: true - externalDocs: - url: 'http://schema.org/identifier' type: string name: description: 'The name of this accommodation is displayed as a title to end users' @@ -1218,6 +1216,7 @@ components: items: type: string place: + description: 'The location this accommodation belongs to' $ref: '#/components/schemas/Place-read' required: - name @@ -1232,7 +1231,7 @@ components: - resources Accommodation-write: type: object - description: '' + description: 'A room or other accommodation that can facilitate people.' required: - name - accommodationCategory @@ -1281,10 +1280,11 @@ components: items: type: string place: + description: 'The location this accommodation belongs to' $ref: '#/components/schemas/Place-write' 'Accommodation:jsonld-read': type: object - description: '' + description: 'A room or other accommodation that can facilitate people.' properties: '@context': readOnly: true @@ -1334,6 +1334,7 @@ components: items: type: string place: + description: 'The location this accommodation belongs to' $ref: '#/components/schemas/Place:jsonld-read' required: - name @@ -1348,7 +1349,7 @@ components: - resources 'Accommodation:jsonld-write': type: object - description: '' + description: 'A room or other accommodation that can facilitate people.' required: - name - accommodationCategory @@ -1406,10 +1407,11 @@ components: items: type: string place: + description: 'The location this accommodation belongs to' $ref: '#/components/schemas/Place:jsonld-write' Place-read: type: object - description: '' + description: 'A building or terrain with an address that can host accommodations.' properties: id: readOnly: true @@ -1456,6 +1458,11 @@ components: url: 'http://schema.org/DateTime' type: string format: date-time + accommodations: + description: 'The accommodations in this location' + type: array + items: + $ref: '#/components/schemas/Accommodation-read' required: - name - publicAccess @@ -1464,7 +1471,7 @@ components: - closingTime Place-write: type: object - description: '' + description: 'A building or terrain with an address that can host accommodations.' required: - name - publicAccess @@ -1514,9 +1521,14 @@ components: url: 'http://schema.org/DateTime' type: string format: date-time + accommodations: + description: 'The accommodations in this location' + type: array + items: + $ref: '#/components/schemas/Accommodation-write' 'Place:jsonld-read': type: object - description: '' + description: 'A building or terrain with an address that can host accommodations.' properties: '@context': readOnly: true @@ -1572,6 +1584,11 @@ components: url: 'http://schema.org/DateTime' type: string format: date-time + accommodations: + description: 'The accommodations in this location' + type: array + items: + $ref: '#/components/schemas/Accommodation:jsonld-read' required: - name - publicAccess @@ -1580,7 +1597,7 @@ components: - closingTime 'Place:jsonld-write': type: object - description: '' + description: 'A building or terrain with an address that can host accommodations.' required: - name - publicAccess @@ -1639,6 +1656,11 @@ components: url: 'http://schema.org/DateTime' type: string format: date-time + accommodations: + description: 'The accommodations in this location' + type: array + items: + $ref: '#/components/schemas/Accommodation:jsonld-write' definitions: Accommodation-read: properties: @@ -1758,6 +1780,7 @@ definitions: example: '08:00' closingTime: example: '18:00' + accommodations: [] required: - name - publicAccess @@ -1798,6 +1821,7 @@ definitions: example: '08:00' closingTime: example: '18:00' + accommodations: [] required: - name - publicAccess @@ -1808,13 +1832,13 @@ tags: - name: Accommodation description: | - + A room or other accommodation that can facilitate people. - name: Place description: | - + A building or terrain with an address that can host accommodations. securityDefinitions: diff --git a/api/public/schema/publiccode.yaml b/api/public/schema/publiccode.yaml index d6f32c4..50e38ee 100644 --- a/api/public/schema/publiccode.yaml +++ b/api/public/schema/publiccode.yaml @@ -6,8 +6,8 @@ url: "https://github.com/ConductionNL/locatiecatalogus" landingURL: "lc.zaakonline.nl" isBasedOn: "https://github.com/ConductionNL/Proto-component-commonground.git" softwareVersion: "V.0.1" -releaseDate: "2020-09-01" -logo: +releaseDate: "2020-13-01" +logo: lc.zaakonline.nl monochromeLogo: img/logo-mono.svg inputTypes: diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index 6d9b5de..acb8988 100644 --- a/api/src/Swagger/SwaggerDecorator.php +++ b/api/src/Swagger/SwaggerDecorator.php @@ -23,13 +23,13 @@ final class SwaggerDecorator implements NormalizerInterface private $camelCaseToSnakeCaseNameConverter; public function __construct( - NormalizerInterface $decorated, - ParameterBagInterface $params, - CacheInterface $cache, - EntityManagerInterface $em, - AnnotationReader $annotationReader, - CamelCaseToSnakeCaseNameConverter $camelCaseToSnakeCaseNameConverter - ) { + NormalizerInterface $decorated, + ParameterBagInterface $params, + CacheInterface $cache, + EntityManagerInterface $em, + AnnotationReader $annotationReader, + CamelCaseToSnakeCaseNameConverter $camelCaseToSnakeCaseNameConverter + ) { $this->decorated = $decorated; $this->params = $params; $this->cash = $cache; @@ -114,7 +114,7 @@ public function normalize($object, $format = null, array $context = []) //$additionalEntityDocs = $this->getAdditionalEntityDocs($entity); $entityDocs = $this->getAdditionalEntityDocs($entity); // Only run if we have aditional docs - if (array_key_exists('properties', $entityDocs)) { + if(array_key_exists('properties',$entityDocs)){ $additionalDocs = array_merge($additionalDocs, $entityDocs['properties']); } @@ -418,13 +418,20 @@ private function getAdditionalEntityDocs($entity) $atributes = []; $groups = []; + foreach ($tags as $tag) { $name = $tag->getName(); $description = $tag->getDescription(); - // - //$description = (string) $description; switch ($name) { + + // Description + case 'var': + $atributes['description'] = (string) $description; + $atributes['type'] = (string) $tag->getType(); + + break; + // Docblocks case 'example': $atributes['example'] = (string) $description; @@ -437,22 +444,48 @@ private function getAdditionalEntityDocs($entity) break; // 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":