From 553f060448176e286602521ea7631a1f40d10044 Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 13 Jan 2020 16:49:59 +0100 Subject: [PATCH 1/3] New SwaggerDecorator --- api/src/Swagger/SwaggerDecorator.php | 169 ++++++++++++++++----------- 1 file changed, 101 insertions(+), 68 deletions(-) diff --git a/api/src/Swagger/SwaggerDecorator.php b/api/src/Swagger/SwaggerDecorator.php index b0610232..acb8988e 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; @@ -63,17 +63,17 @@ public function normalize($object, $format = null, array $context = []) // Lets add JWT-Oauth $docs['securityDefinitions']['JWT-Oauth'] = [ - 'type' => 'oauth2', - 'authorizationUrl'=> 'http://petstore.swagger.io/api/oauth/dialog', - 'flow' => 'implicit', - 'scopes' => [], //scopes will be filled later autmaticly + 'type' => 'oauth2', + 'authorizationUrl'=> 'http://petstore.swagger.io/api/oauth/dialog', + 'flow' => 'implicit', + 'scopes' => [], //scopes will be filled later autmaticly ]; $docs['securityDefinitions']['JWT-Token'] = [ - 'type' => 'apiKey', - 'in' => 'header', // can be "header", "query" or "cookie" - 'name' => 'Authorization', // name of the header, query parameter or cookie - 'scopes'=> [], //scopes will be filled later autmaticly + 'type' => 'apiKey', + 'in' => 'header', // can be "header", "query" or "cookie" + 'name' => 'Authorization', // name of the header, query parameter or cookie + 'scopes'=> [], //scopes will be filled later autmaticly ]; // Lets get al the entities known to doctrine @@ -115,7 +115,7 @@ public function normalize($object, $format = null, array $context = []) $entityDocs = $this->getAdditionalEntityDocs($entity); // Only run if we have aditional docs if(array_key_exists('properties',$entityDocs)){ - $additionalDocs = array_merge($additionalDocs, $entityDocs['properties']); + $additionalDocs = array_merge($additionalDocs, $entityDocs['properties']); } // Security @@ -196,16 +196,16 @@ public function normalize($object, $format = null, array $context = []) // NLX loging headers $call['parameters'][] = [ - 'name' => 'Authorization', - 'description' => 'The JWT of the entity performing the request', - 'in' => 'header', + 'name' => 'Authorization', + 'description' => 'The JWT of the entity performing the request', + 'in' => 'header', ]; // NLX loging headers $call['parameters'][] = [ - 'name' => 'API-Version', - 'description' => 'The version of the API conform [Landelijke API-strategie.](https://geonovum.github.io/KP-APIs/#versioning)', - 'example' => '1.0.1', - 'in' => 'header', + 'name' => 'API-Version', + 'description' => 'The version of the API conform [Landelijke API-strategie.](https://geonovum.github.io/KP-APIs/#versioning)', + 'example' => '1.0.1', + 'in' => 'header', ]; /* // NLX loging headers @@ -223,33 +223,33 @@ public function normalize($object, $format = null, array $context = []) */ // NLX loging headers $call['parameters'][] = [ - 'name' => 'X-NLX-Logrecord-ID', - 'description' => 'A globally unique id of the request, which makes a request traceable throughout the network.', - 'in' => 'header', + 'name' => 'X-NLX-Logrecord-ID', + 'description' => 'A globally unique id of the request, which makes a request traceable throughout the network.', + 'in' => 'header', ]; // NLX loging headers $call['parameters'][] = [ - 'name' => 'X-NLX-Request-Process-Id', - 'description' => 'A process id for purpose registration (doelbinding)', - 'in' => 'header', + 'name' => 'X-NLX-Request-Process-Id', + 'description' => 'A process id for purpose registration (doelbinding)', + 'in' => 'header', ]; // NLX loging headers $call['parameters'][] = [ - 'name' => 'X-NLX-Request-Data-Elements', - 'description' => 'A list of requested data elements', - 'in' => 'header', + 'name' => 'X-NLX-Request-Data-Elements', + 'description' => 'A list of requested data elements', + 'in' => 'header', ]; // NLX loging headers $call['parameters'][] = [ - 'name' => 'X-NLX-Request-Data-Subject', - 'description' => 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`', - 'in' => 'header', + 'name' => 'X-NLX-Request-Data-Subject', + 'description' => 'A key-value list of data subjects related to this request. e.g. `bsn=12345678, kenteken=ab-12-fg`', + 'in' => 'header', ]; // NLX loging headers $call['parameters'][] = [ - 'name' => 'X-NLX-Audit-Clarification', - 'description' => 'A clarification as to why a request has been made (doelbinding)', - 'in' => 'header', + 'name' => 'X-NLX-Audit-Clarification', + 'description' => 'A clarification as to why a request has been made (doelbinding)', + 'in' => 'header', ]; if ($method == 'get') { @@ -259,48 +259,48 @@ public function normalize($object, $format = null, array $context = []) // WEBSUB header $call['parameters'][] = [ - 'name' => 'Link', - 'description' => 'A [websub](https://www.w3.org/TR/websub/#discovery) header like ; rel="hub"', - 'in' => 'header', + 'name' => 'Link', + 'description' => 'A [websub](https://www.w3.org/TR/websub/#discovery) header like ; rel="hub"', + 'in' => 'header', ]; // Lets add the extend functionality $call['parameters'][] = [ - 'name' => 'extend[]', - 'required' => false, - 'description' => 'An array of nested objects to include in the return object', - 'in' => 'query', - 'schema' => ['type'=>'array'], + 'name' => 'extend[]', + 'required' => false, + 'description' => 'An array of nested objects to include in the return object', + 'in' => 'query', + 'schema' => ['type'=>'array'], ]; // Lets add the fields functionality $call['parameters'][] = [ - 'name' => 'fields[]', - 'required' => false, - 'description' => 'An array of fields to return in output, wil return all fields is not supplied', - 'in' => 'query', - 'schema' => ['type'=>'array'], + 'name' => 'fields[]', + 'required' => false, + 'description' => 'An array of fields to return in output, wil return all fields is not supplied', + 'in' => 'query', + 'schema' => ['type'=>'array'], ]; // Lets add some time travel $call['parameters'][] = [ - 'name' => 'validOn', - 'required' => false, - 'description' => 'Returns object as valid on a given date time', - 'schema' => ['type'=>'string', 'format' => 'date-time'], - 'in' => 'query', + 'name' => 'validOn', + 'required' => false, + 'description' => 'Returns object as valid on a given date time', + 'schema' => ['type'=>'string', 'format' => 'date-time'], + 'in' => 'query', ]; $call['parameters'][] = [ - 'name' => 'validFrom', - 'required' => false, - 'description' => 'Returns objects valid from a given date time', - 'schema' => ['type'=>'string', 'format' => 'date-time'], - 'in' => 'query', + 'name' => 'validFrom', + 'required' => false, + 'description' => 'Returns objects valid from a given date time', + 'schema' => ['type'=>'string', 'format' => 'date-time'], + 'in' => 'query', ]; $call['parameters'][] = [ - 'name' => 'validUntil', - 'required' => false, - 'description' => 'Returns objects valid until a given date time', - 'schema' => ['type'=>'string', 'format' => 'date-time'], - 'in' => 'query', + 'name' => 'validUntil', + 'required' => false, + 'description' => 'Returns objects valid until a given date time', + 'schema' => ['type'=>'string', 'format' => 'date-time'], + 'in' => 'query', ]; } } @@ -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": From e1fc914740010011f166899386d15cae3e8f898f Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 13 Jan 2020 21:13:48 +0100 Subject: [PATCH 2/3] Value update --- api/helm/values.yaml | 6 +- api/public/schema/openapi.yaml | 180 ++++++++++++++++++++++++++++-- api/public/schema/publiccode.yaml | 2 +- 3 files changed, 175 insertions(+), 13 deletions(-) diff --git a/api/helm/values.yaml b/api/helm/values.yaml index 88bdaaaa..ccae99f3 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/verzoektypecatalogus' - subdomain: + subdomain: vtc domains: - conduction.nl - zaakonline.nl @@ -48,7 +48,7 @@ settings: php: - repository: docker.io/conduction/vtc-php + repository: docker.io/conduction/protocomponent-php tag: latest mercure: jwtSecret: "" @@ -64,7 +64,7 @@ nginx: varnish: enabled: true #url: https://example.com - repository: docker.io/conduction/vtc-varnish + repository: docker.io/conduction/protocomponent-varnish tag: latest pullPolicy: Always replicaCount: 1 diff --git a/api/public/schema/openapi.yaml b/api/public/schema/openapi.yaml index 9b83cb55..1f603897 100644 --- a/api/public/schema/openapi.yaml +++ b/api/public/schema/openapi.yaml @@ -1818,199 +1818,357 @@ definitions: Property-read: properties: id: + description: 'The UUID identifier of this object' + type: string example: e2984465-190a-4562-829e-a8cca81aa35d format: uuid title: + description: 'The title of this property' + type: string example: 'My Property' maxLength: 255 minLength: 15 type: + description: 'The type of this property' + type: string example: string maxLength: 255 format: + description: 'The swagger type of the property as used in api calls' + type: string example: string maxLength: 255 multipleOf: + description: '*Can only be used in combination with type integer* Specifies a number where the value should be a multiple of, e.g. a multiple of 2 would validate 2,4 and 6 but would prevent 5' + type: string example: '2' maximum: + description: '*Can only be used in combination with type integer* The maximum allowed value' + type: string example: '2' exclusiveMaximum: + description: '*Can only be used in combination with type integer* Defines if the maximum is exclusive, e.g. a exclusive maximum of 5 would invalidate 5 but validate 4' + type: string example: 'true' minimum: + description: '*Can only be used in combination with type integer* The minimum allowed value' + type: string example: '2' exclusiveMinimum: + description: '*Can only be used in combination with type integer* Defines if the minimum is exclusive, e.g. a exclusive minimum of 5 would invalidate 5 but validate 6' + type: string example: 'true' maxLength: + description: 'The maximum amount of characters in the value' + type: string example: '2' minLength: + description: 'The minimal amount of characters in the value' + type: int example: '2' pattern: + description: 'A [regular expression](https://en.wikipedia.org/wiki/Regular_expression) that the value should comply to' + type: string example: regex maxLength: 255 additionalItems: [] maxItems: + description: '*Can only be used in combination with type array* The maximum array length' + type: string example: '2' minItems: + description: '*Can only be used in combination with type array* The minimum allowed value' + type: string example: '2' uniqueItems: + description: '*Can only be used in combination with type array* Define whether or not values in an array should be unique' + type: bool example: 'false' maxProperties: + description: '*Can only be used in combination with type integer* The maximum amount of properties an object should contain' + type: string example: '2' minProperties: + description: '*Can only be used in combination with type object* The minimum amount of properties an object should contain' + type: int example: '2' required: + description: 'Only whether or not this property is required' + type: bool example: 'false' properties: [] additionalProperties: [] object: [] - enum: [] + enum: + description: 'An array of possible values, input is limited to this array]' + type: array description: + description: 'An description of the value asked, supports markdown syntax as described by [CommonMark 0.27.](https://spec.commonmark.org/0.27/)' + type: string example: 'My value' defaultValue: + description: 'An default value for this value that will be used if a user doesn''t supply a value' + type: string example: 'My value' maxLength: 255 nullable: + description: 'Whether or not this property can be left empty' + type: bool example: 'false' discriminator: + description: 'To help API consumers detect the object type, you can add the discriminator/propertyName keyword to model definitions. This keyword points to the property that specifies the data type name' + type: string example: name maxLength: 255 readOnly: + description: 'Whether or not this property is read only' + type: bool example: 'false' writeOnly: + description: 'Whether or not this property is write only' + type: bool example: 'false' xml: + description: 'An XML representation of the swagger docs' + type: string example: '''''' externalDoc: + description: 'An link to any external documentation for the value' + type: string example: 'https://www.w3.org/TR/NOTE-datetime' maxLength: 255 example: + description: 'An example of the value that should be supplied' + type: string example: 'My value' maxLength: 255 deprecated: + description: 'Whether or not this property has been deprecated and wil be removed in the future' + type: bool example: 'false' availableFrom: - example: '2019-09-16T14:26:51+00:00' + description: 'The moment from which this value is available' + type: string + example: '2020-01-13 20:12:33' + format: date-time availableUntil: - example: '2019-09-16T14:26:51+00:00' + description: '*should be used in combination with deprecated* The moment where until this value is available' + type: string + example: '2020-01-13 20:12:33' + format: date-time minDate: + description: 'The minimal date for value, either a date, datetime or duration (ISO_8601)' + type: string example: '2019-09-16T14:26:51+00:00' maxDate: + description: 'The maximum date for value, either a date, datetime or duration (ISO_8601)' + type: string example: '2019-09-16T14:26:51+00:00' icon: + description: 'The icon of this property' + type: string example: 'My Property' maxLength: 255 minLength: 15 slug: + description: 'The slug of this property' + type: string example: my-slug maxLength: 255 minLength: 15 start: + description: 'Whether or not this proerty is the starting oint of a process' + type: string example: 'true' - requestType: [] + requestType: + description: 'The requestType that this property belongs to' + type: object required: [] Property-write: properties: title: + description: 'The title of this property' + type: string example: 'My Property' maxLength: 255 minLength: 15 type: + description: 'The type of this property' + type: string example: string maxLength: 255 format: + description: 'The swagger type of the property as used in api calls' + type: string example: string maxLength: 255 multipleOf: + description: '*Can only be used in combination with type integer* Specifies a number where the value should be a multiple of, e.g. a multiple of 2 would validate 2,4 and 6 but would prevent 5' + type: string example: '2' maximum: + description: '*Can only be used in combination with type integer* The maximum allowed value' + type: string example: '2' exclusiveMaximum: + description: '*Can only be used in combination with type integer* Defines if the maximum is exclusive, e.g. a exclusive maximum of 5 would invalidate 5 but validate 4' + type: string example: 'true' minimum: + description: '*Can only be used in combination with type integer* The minimum allowed value' + type: string example: '2' exclusiveMinimum: + description: '*Can only be used in combination with type integer* Defines if the minimum is exclusive, e.g. a exclusive minimum of 5 would invalidate 5 but validate 6' + type: string example: 'true' maxLength: + description: 'The maximum amount of characters in the value' + type: string example: '2' minLength: + description: 'The minimal amount of characters in the value' + type: int example: '2' pattern: + description: 'A [regular expression](https://en.wikipedia.org/wiki/Regular_expression) that the value should comply to' + type: string example: regex maxLength: 255 additionalItems: [] maxItems: + description: '*Can only be used in combination with type array* The maximum array length' + type: string example: '2' minItems: + description: '*Can only be used in combination with type array* The minimum allowed value' + type: string example: '2' uniqueItems: + description: '*Can only be used in combination with type array* Define whether or not values in an array should be unique' + type: bool example: 'false' maxProperties: + description: '*Can only be used in combination with type integer* The maximum amount of properties an object should contain' + type: string example: '2' minProperties: + description: '*Can only be used in combination with type object* The minimum amount of properties an object should contain' + type: int example: '2' required: + description: 'Only whether or not this property is required' + type: bool example: 'false' properties: [] additionalProperties: [] object: [] - enum: [] + enum: + description: 'An array of possible values, input is limited to this array]' + type: array description: + description: 'An description of the value asked, supports markdown syntax as described by [CommonMark 0.27.](https://spec.commonmark.org/0.27/)' + type: string example: 'My value' defaultValue: + description: 'An default value for this value that will be used if a user doesn''t supply a value' + type: string example: 'My value' maxLength: 255 nullable: + description: 'Whether or not this property can be left empty' + type: bool example: 'false' discriminator: + description: 'To help API consumers detect the object type, you can add the discriminator/propertyName keyword to model definitions. This keyword points to the property that specifies the data type name' + type: string example: name maxLength: 255 readOnly: + description: 'Whether or not this property is read only' + type: bool example: 'false' writeOnly: + description: 'Whether or not this property is write only' + type: bool example: 'false' xml: + description: 'An XML representation of the swagger docs' + type: string example: '''''' externalDoc: + description: 'An link to any external documentation for the value' + type: string example: 'https://www.w3.org/TR/NOTE-datetime' maxLength: 255 example: + description: 'An example of the value that should be supplied' + type: string example: 'My value' maxLength: 255 deprecated: + description: 'Whether or not this property has been deprecated and wil be removed in the future' + type: bool example: 'false' availableFrom: - example: '2019-09-16T14:26:51+00:00' + description: 'The moment from which this value is available' + type: string + example: '2020-01-13 20:12:33' + format: date-time availableUntil: - example: '2019-09-16T14:26:51+00:00' + description: '*should be used in combination with deprecated* The moment where until this value is available' + type: string + example: '2020-01-13 20:12:33' + format: date-time minDate: + description: 'The minimal date for value, either a date, datetime or duration (ISO_8601)' + type: string example: '2019-09-16T14:26:51+00:00' maxDate: + description: 'The maximum date for value, either a date, datetime or duration (ISO_8601)' + type: string example: '2019-09-16T14:26:51+00:00' icon: + description: 'The icon of this property' + type: string example: 'My Property' maxLength: 255 minLength: 15 slug: + description: 'The slug of this property' + type: string example: my-slug maxLength: 255 minLength: 15 start: + description: 'Whether or not this proerty is the starting oint of a process' + type: string example: 'true' - requestType: [] + requestType: + description: 'The requestType that this property belongs to' + type: object required: [] RequestType-read: properties: id: + description: 'The UUID identifier of this object' + type: string example: e2984465-190a-4562-829e-a8cca81aa35d format: uuid sourceOrganization: + description: 'The RSIN of the organization that owns this process' + type: string example: '002851234' maxLength: 11 minLength: 8 name: + description: 'The name of this RequestType' + type: string example: 'My RequestType' maxLength: 255 description: + description: 'An short description of this RequestType' + type: string example: 'This is the best request ever' maxLength: 2550 properties: [] @@ -2020,6 +2178,8 @@ definitions: RequestType-write: properties: sourceOrganization: + description: 'The RSIN of the organization that owns this process' + type: string example: '002851234' maxLength: 11 minLength: 8 @@ -2029,7 +2189,9 @@ definitions: - name RequestType-write-requesttype: properties: - extends: [] + extends: + description: 'The requestType that this requestType extends' + type: object required: - sourceOrganization - name diff --git a/api/public/schema/publiccode.yaml b/api/public/schema/publiccode.yaml index 22556a84..f60afa33 100644 --- a/api/public/schema/publiccode.yaml +++ b/api/public/schema/publiccode.yaml @@ -6,7 +6,7 @@ url: "https://github.com/ConductionNL/verzoektypecatalogus" landingURL: "vtc.zaakonline.nl" isBasedOn: "https://github.com/ConductionNL/Proto-component-commonground.git" softwareVersion: "V.0.1" -releaseDate: "2020-09-01" +releaseDate: "2020-13-01" logo: pc.zaakonline.nl monochromeLogo: img/logo-mono.svg From ae8b399d0b4e000bf02fea5aad8433995124f91b Mon Sep 17 00:00:00 2001 From: Robert Zondervan Date: Mon, 13 Jan 2020 21:30:06 +0100 Subject: [PATCH 3/3] Fix last any types --- api/public/schema/openapi.yaml | 62 +++++++++++++++++++++++----------- api/src/Entity/Property.php | 16 ++++----- api/src/Entity/RequestType.php | 38 +++++++++++---------- 3 files changed, 72 insertions(+), 44 deletions(-) diff --git a/api/public/schema/openapi.yaml b/api/public/schema/openapi.yaml index 1f603897..1095b37b 100644 --- a/api/public/schema/openapi.yaml +++ b/api/public/schema/openapi.yaml @@ -1714,7 +1714,7 @@ components: type: boolean RequestType-read: type: object - description: '' + description: 'All properties contained in the RequestType type' properties: id: readOnly: true @@ -1734,6 +1734,7 @@ components: description: 'An short description of this RequestType' type: string properties: + description: 'The properties for this request type' type: array items: $ref: '#/components/schemas/Property-read' @@ -1743,7 +1744,7 @@ components: - source_organization RequestType-write: type: object - description: '' + description: 'All properties contained in the RequestType type' required: - source_organization properties: @@ -1751,12 +1752,13 @@ components: description: 'The RSIN of the organization that owns this process' type: string properties: + description: 'The properties for this request type' type: array items: $ref: '#/components/schemas/Property-write' 'RequestType:jsonld-read': type: object - description: '' + description: 'All properties contained in the RequestType type' properties: '@context': readOnly: true @@ -1785,6 +1787,7 @@ components: description: 'An short description of this RequestType' type: string properties: + description: 'The properties for this request type' type: array items: $ref: '#/components/schemas/Property:jsonld-read' @@ -1794,7 +1797,7 @@ components: - source_organization 'RequestType:jsonld-write': type: object - description: '' + description: 'All properties contained in the RequestType type' required: - source_organization properties: @@ -1811,6 +1814,7 @@ components: description: 'The RSIN of the organization that owns this process' type: string properties: + description: 'The properties for this request type' type: array items: $ref: '#/components/schemas/Property:jsonld-write' @@ -1871,7 +1875,9 @@ definitions: type: string example: regex maxLength: 255 - additionalItems: [] + additionalItems: + description: 'Not yet supported by business logic' + type: bool maxItems: description: '*Can only be used in combination with type array* The maximum array length' type: string @@ -1896,9 +1902,15 @@ definitions: description: 'Only whether or not this property is required' type: bool example: 'false' - properties: [] - additionalProperties: [] - object: [] + properties: + description: 'Not yet supported by business logic' + type: '\Property[]|\ArrayCollection' + additionalProperties: + description: 'Not yet supported by business logic' + type: '\Property[]|\ArrayCollection' + object: + description: 'Not yet supported by business logic' + type: object enum: description: 'An array of possible values, input is limited to this array]' type: array @@ -1949,12 +1961,12 @@ definitions: availableFrom: description: 'The moment from which this value is available' type: string - example: '2020-01-13 20:12:33' + example: '2020-01-13 20:28:20' format: date-time availableUntil: description: '*should be used in combination with deprecated* The moment where until this value is available' type: string - example: '2020-01-13 20:12:33' + example: '2020-01-13 20:28:20' format: date-time minDate: description: 'The minimal date for value, either a date, datetime or duration (ISO_8601)' @@ -2035,7 +2047,9 @@ definitions: type: string example: regex maxLength: 255 - additionalItems: [] + additionalItems: + description: 'Not yet supported by business logic' + type: bool maxItems: description: '*Can only be used in combination with type array* The maximum array length' type: string @@ -2060,9 +2074,15 @@ definitions: description: 'Only whether or not this property is required' type: bool example: 'false' - properties: [] - additionalProperties: [] - object: [] + properties: + description: 'Not yet supported by business logic' + type: '\Property[]|\ArrayCollection' + additionalProperties: + description: 'Not yet supported by business logic' + type: '\Property[]|\ArrayCollection' + object: + description: 'Not yet supported by business logic' + type: object enum: description: 'An array of possible values, input is limited to this array]' type: array @@ -2113,12 +2133,12 @@ definitions: availableFrom: description: 'The moment from which this value is available' type: string - example: '2020-01-13 20:12:33' + example: '2020-01-13 20:28:20' format: date-time availableUntil: description: '*should be used in combination with deprecated* The moment where until this value is available' type: string - example: '2020-01-13 20:12:33' + example: '2020-01-13 20:28:20' format: date-time minDate: description: 'The minimal date for value, either a date, datetime or duration (ISO_8601)' @@ -2171,7 +2191,9 @@ definitions: type: string example: 'This is the best request ever' maxLength: 2550 - properties: [] + properties: + description: 'The properties for this request type' + type: '\Property[]|\ArrayCollection' required: - sourceOrganization - name @@ -2183,7 +2205,9 @@ definitions: example: '002851234' maxLength: 11 minLength: 8 - properties: [] + properties: + description: 'The properties for this request type' + type: '\Property[]|\ArrayCollection' required: - sourceOrganization - name @@ -2208,7 +2232,7 @@ tags: - name: RequestType description: | - + All properties contained in the RequestType type securityDefinitions: diff --git a/api/src/Entity/Property.php b/api/src/Entity/Property.php index 71f8fcc5..7bfcfb65 100644 --- a/api/src/Entity/Property.php +++ b/api/src/Entity/Property.php @@ -68,7 +68,7 @@ class Property private $title; - /** + /** * @var string $name The name of the property as used in api calls, extracted from title on snake_case basis * @example my_property * @Assert\Length(min = 15, max = 255) @@ -193,7 +193,7 @@ class Property private $items; /** - * Not yet supported by business logic + * @var boolean Not yet supported by business logic * * @Assert\Type("bool") * @Groups({"read", "write"}) @@ -265,7 +265,7 @@ class Property private $required; /** - * Not yet supported by business logic + * @var Property[]|ArrayCollection Not yet supported by business logic * * @Groups({"read", "write"}) * @ORM\Column(type="object", nullable=true) @@ -273,7 +273,7 @@ class Property private $properties; /** - * Not yet supported by business logic + * @var Property[]|ArrayCollection Not yet supported by business logic * * @Groups({"read", "write"}) * @ORM\Column(type="object", nullable=true) @@ -281,7 +281,7 @@ class Property private $additionalProperties; /** - * Not yet supported by business logic + * @var Object Not yet supported by business logic * * @Groups({"read", "write"}) * @ORM\Column(type="object", nullable=true) @@ -479,7 +479,7 @@ class Property /** * @var string The icon of this property * @example My Property - * + * * @Assert\Length(min = 15, max = 255) * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) @@ -489,7 +489,7 @@ class Property /** * @var string The slug of this property * @example my-slug - * + * * @Assert\Length(min = 15, max = 255) * @Groups({"read", "write"}) * @ORM\Column(type="string", length=255, nullable=true) @@ -499,7 +499,7 @@ class Property /** * @var string Whether or not this proerty is the starting oint of a process * @example true - * + * * @Groups({"read", "write"}) * @ORM\Column(type="boolean", nullable=true) */ diff --git a/api/src/Entity/RequestType.php b/api/src/Entity/RequestType.php index 176e2d48..7f5787b4 100644 --- a/api/src/Entity/RequestType.php +++ b/api/src/Entity/RequestType.php @@ -12,12 +12,15 @@ use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; +use Ramsey\Uuid\UuidInterface; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Serializer\Annotation\MaxDepth; use Ramsey\Uuid\Uuid; /** + * All properties contained in the RequestType type + * * @ApiResource( * normalizationContext={"groups"={"read"}, "enable_max_depth"=true}, * denormalizationContext={"groups"={"write"}, "enable_max_depth"=true}, @@ -48,9 +51,9 @@ class RequestType { /** - * @var \Ramsey\Uuid\UuidInterface $id The UUID identifier of this object + * @var UuidInterface $id The UUID identifier of this object * @example e2984465-190a-4562-829e-a8cca81aa35d - * + * * @Groups({"read"}) * @Assert\Uuid * @ORM\Id @@ -98,6 +101,7 @@ class RequestType private $description; /** + * @var Property[]|ArrayCollection The properties for this request type * @Groups({"read", "write"}) * @MaxDepth(1) * @ORM\OneToMany(targetEntity="App\Entity\Property", mappedBy="requestType", orphanRemoval=true, fetch="EAGER", cascade={"persist"}) @@ -105,7 +109,7 @@ class RequestType */ private $properties; - + /** * @Groups({"read"}) * @MaxDepth(1) @@ -148,7 +152,7 @@ public function getId(): Uuid { return $this->id; } - + public function setId(Uuid $id): self { $this->id = $id; @@ -302,14 +306,14 @@ public function setAvailableUntil(?\DateTimeInterface $availableUntil): self return $this; } - - + + public function getStages() { $stages = []; $stage = $this->getFirstStage(); while ($stage){ - + $array = [ "id"=>$stage->getId(), "name"=>$stage->getName(), @@ -317,28 +321,28 @@ public function getStages() "icon"=>$stage->getIcon(), "slug"=>$stage->getSlug() ]; - - if($stage->getNext()){ + + if($stage->getNext()){ $array["next"] = $stage->getNext()->getSlug(); } - + if($stage->getPrevious()->first()){ $array["previous"] = $stage->getPrevious()->first()->getSlug(); } - + $stages[] = $array; - - $stage = $stage->getNext(); + + $stage = $stage->getNext(); } - + return $stages; } - + public function getFirstStage() { $criteria = Criteria::create() ->andWhere(Criteria::expr()->eq('start', true)); - - return $this->getProperties()->matching($criteria)->first(); + + return $this->getProperties()->matching($criteria)->first(); } }