diff --git a/composer.lock b/composer.lock index 02d84f4..d36b192 100644 --- a/composer.lock +++ b/composer.lock @@ -154,16 +154,16 @@ }, { "name": "swaggest/json-diff", - "version": "v3.10.4", + "version": "v3.10.5", "source": { "type": "git", "url": "https://github.com/swaggest/json-diff.git", - "reference": "f4e511708060ff7511a3743fab4aa484a062bcfb" + "reference": "17bfc66b330f46e12a7e574133497a290cd79ba5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swaggest/json-diff/zipball/f4e511708060ff7511a3743fab4aa484a062bcfb", - "reference": "f4e511708060ff7511a3743fab4aa484a062bcfb", + "url": "https://api.github.com/repos/swaggest/json-diff/zipball/17bfc66b330f46e12a7e574133497a290cd79ba5", + "reference": "17bfc66b330f46e12a7e574133497a290cd79ba5", "shasum": "" }, "require": { @@ -191,22 +191,22 @@ "description": "JSON diff/rearrange/patch/pointer library for PHP", "support": { "issues": "https://github.com/swaggest/json-diff/issues", - "source": "https://github.com/swaggest/json-diff/tree/v3.10.4" + "source": "https://github.com/swaggest/json-diff/tree/v3.10.5" }, - "time": "2022-11-09T13:21:05+00:00" + "time": "2023-11-17T11:12:46+00:00" }, { "name": "swaggest/json-schema", - "version": "v0.12.41", + "version": "v0.12.42", "source": { "type": "git", "url": "https://github.com/swaggest/php-json-schema.git", - "reference": "1bb97901314f828774dd8c5b21bff889ce0b34bb" + "reference": "d23adb53808b8e2da36f75bc0188546e4cbe3b45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swaggest/php-json-schema/zipball/1bb97901314f828774dd8c5b21bff889ce0b34bb", - "reference": "1bb97901314f828774dd8c5b21bff889ce0b34bb", + "url": "https://api.github.com/repos/swaggest/php-json-schema/zipball/d23adb53808b8e2da36f75bc0188546e4cbe3b45", + "reference": "d23adb53808b8e2da36f75bc0188546e4cbe3b45", "shasum": "" }, "require": { @@ -242,9 +242,9 @@ "support": { "email": "vearutop@gmail.com", "issues": "https://github.com/swaggest/php-json-schema/issues", - "source": "https://github.com/swaggest/php-json-schema/tree/v0.12.41" + "source": "https://github.com/swaggest/php-json-schema/tree/v0.12.42" }, - "time": "2022-08-17T11:21:43+00:00" + "time": "2023-09-12T14:43:42+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -1656,5 +1656,5 @@ "platform-overrides": { "php": "5.6.10" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/JSDoc/TypeBuilder.php b/src/JSDoc/TypeBuilder.php index 3d2bbad..b3bebf0 100644 --- a/src/JSDoc/TypeBuilder.php +++ b/src/JSDoc/TypeBuilder.php @@ -288,7 +288,14 @@ private function makeObjectTypeDef(Schema $schema, $path) private function description(Schema $schema) { - $res = str_replace("\n", " ", $schema->title . $schema->description); + $res = str_replace("\n", " ", trim($schema->title)); + if (trim($schema->description)) { + if ($res) { + $res .= ". "; + } + + $res .= str_replace("\n", " ", trim($schema->description)); + } if ($res) { return ' - ' . rtrim($res, '.') . '.'; } diff --git a/tests/src/PHPUnit/JSDoc/JSDocTest.php b/tests/src/PHPUnit/JSDoc/JSDocTest.php index c38eab4..3601576 100644 --- a/tests/src/PHPUnit/JSDoc/JSDocTest.php +++ b/tests/src/PHPUnit/JSDoc/JSDocTest.php @@ -16,7 +16,7 @@ public function testJsonSchema() "Person": { "type": "object", "properties": { - "name": {"type": "string", "description": "Person name."}, + "name": {"type": "string", "title":" Name ", "description": "The name of the person."}, "age": {"type": "integer"}, "isMale": {"type": "boolean"}, "partner": {"$ref": "#/definitions/Person"}, @@ -37,7 +37,7 @@ public function testJsonSchema() /** * @typedef Person * @type {Object} - * @property {String} name - Person name. + * @property {String} name - Name. The name of the person. * @property {Number} age * @property {Boolean} isMale * @property {Person} partner