Skip to content

Commit 1c52109

Browse files
committed
Update to use php-json-schema-model-generator-production
1 parent 7d768df commit 1c52109

31 files changed

+66
-48
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ Simple example from a PHP application: you define and document an API with swagg
3636
The recommended way to install php-json-schema-model-generator is through [Composer](http://getcomposer.org):
3737
```
3838
$ composer require --dev wol-soft/php-json-schema-model-generator
39-
$ composer require wol-soft/php-json-schema-model-generator-exception
39+
$ composer require wol-soft/php-json-schema-model-generator-production
4040
```
41-
To avoid adding all dependencies of the php-json-schema-model-generator to your production dependencies it's recommended to add the library as a dev-dependency and include the php-json-schema-model-generator-exception library. The exception library provides all classes to run the generated code. Generating the classes should either be a step done in the development environment (if you decide to commit the models) or as a build step of your application.
41+
To avoid adding all dependencies of the php-json-schema-model-generator to your production dependencies it's recommended to add the library as a dev-dependency and include the php-json-schema-model-generator-production library. The exception library provides all classes to run the generated code. Generating the classes should either be a step done in the development environment (if you decide to commit the models) or as a build step of your application.
4242

4343
## Basic usage ##
4444

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
],
1313
"require": {
1414
"symplify/easy-coding-standard": "^6.0.4",
15-
"wol-soft/php-json-schema-model-generator-exception": "^0.1.0",
15+
"wol-soft/php-json-schema-model-generator-production": "^0.4.0",
1616
"wol-soft/php-micro-template": "^1.3.1",
17+
1718
"php": ">=7.2",
1819
"ext-json": "*",
1920
"ext-mbstring": "*"

docs/source/gettingStarted.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The recommended way to install php-json-model-generator is through `Composer <ht
99
.. code-block:: rconsole
1010
1111
composer require --dev wol-soft/php-json-schema-model-generator
12-
composer require wol-soft/php-json-schema-model-generator-exception
12+
composer require wol-soft/php-json-schema-model-generator-production
1313
1414
To avoid adding all dependencies of the php-json-model-generator to your production dependencies it's recommended to add the library as a dev-dependency and include the php-json-model-generator-exception library. The exception library provides all classes to run the generated code. Generating the classes should either be a step done in the development environment (if you decide to commit the models) or as a build step of your application.
1515

@@ -150,10 +150,10 @@ Collect errors vs. early return
150150
151151
By default the complete input is validated and in case of failing validations all error messages will be thrown in a single exception implementing the ErrorRegistryExceptionInterface interface. If set to false the first failing validation will throw an exception.
152152

153-
The exceptions are implemented in the php-json-schema-model-generator-exception repository. Default exceptions:
153+
The exceptions are implemented in the php-json-schema-model-generator-production repository. Default exceptions:
154154

155-
* Error collection enabled: **PHPModelGeneratorException\ErrorRegistryException**
156-
* Error collection disabled: **PHPModelGeneratorException\ValidationException**
155+
* Error collection enabled: **PHPModelGenerator\\Exception\\ErrorRegistryException**
156+
* Error collection disabled: **PHPModelGenerator\\Exception\\ValidationException**
157157

158158
.. code-block:: php
159159
@@ -210,6 +210,8 @@ Generated interface:
210210
public function toArray(): array;
211211
public function toJSON(): string;
212212
213+
The generated class will implement the interface **PHPModelGenerator\\Interfaces\\SerializationInterface** implemented in the php-json-schema-model-generator-production repository. This interface can be used to write additional generic modules to handle the generated models.
214+
213215
Output generation process
214216
^^^^^^^^^^^^^^^^^^^^^^^^^
215217

src/Exception/PHPModelGeneratorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Exception;
88

99
/**
10-
* Class PHPModelGeneratorException
10+
* Class PHPModelGenerator\Exception
1111
*
1212
* @package PHPModelGenerator\Exception
1313
*/

src/Model/GeneratorConfiguration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use PHPModelGenerator\Utils\ClassNameGenerator;
88
use PHPModelGenerator\Utils\ClassNameGeneratorInterface;
9-
use PHPModelGeneratorException\ErrorRegistryException;
10-
use PHPModelGeneratorException\ValidationException;
9+
use PHPModelGenerator\Exception\ErrorRegistryException;
10+
use PHPModelGenerator\Exception\ValidationException;
1111

1212
/**
1313
* Class GeneratorConfiguration

src/Model/Schema.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ public function addProperty(PropertyInterface $property): self
8181
{
8282
if (!isset($this->properties[$property->getName()])) {
8383
$this->properties[$property->getName()] = $property;
84+
} else {
85+
// TODO tests:
86+
// testConditionalObjectProperty
87+
// testInvalidConditionalObjectPropertyThrowsAnException
88+
// testInvalidValuesForMultipleValuesInCompositionThrowsAnException
89+
// throw new SchemaException("Duplicate attribute name {$property->getName()}");
8490
}
8591

8692
return $this;

src/Model/SchemaDefinition/SchemaDefinition.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace PHPModelGenerator\Model\SchemaDefinition;
66

7-
use PHPModelGenerator\Exception\PHPModelGeneratorException;
7+
use PHPModelGenerator\Exception\PHPModelGenerator\Exception;
88
use PHPModelGenerator\Exception\SchemaException;
99
use PHPModelGenerator\Model\Property\PropertyInterface;
1010
use PHPModelGenerator\Model\Property\PropertyProxy;
@@ -65,7 +65,7 @@ public function getSchema(): Schema
6565
*
6666
* @return PropertyInterface
6767
*
68-
* @throws PHPModelGeneratorException
68+
* @throws PHPModelGenerator\Exception
6969
* @throws SchemaException
7070
*/
7171
public function resolveReference(
@@ -100,7 +100,7 @@ public function resolveReference(
100100
$structure
101101
)
102102
);
103-
} catch (PHPModelGeneratorException $exception) {
103+
} catch (PHPModelGenerator\Exception $exception) {
104104
$this->resolvedPaths->offsetUnset($key);
105105
throw $exception;
106106
}

src/Templates/Exception/ComposedValueException.phptpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Invalid value for {{ propertyName }} declined by composition constraint.\n"
22
. sprintf(' {{ composedErrorMessage }}', $succeededCompositionElements)
33
. array_reduce(
44
$compositionErrorCollection,
5-
function (string $carry, \PHPModelGeneratorException\ErrorRegistryExceptionInterface $exception) use (&$i) {
5+
function (string $carry, \PHPModelGenerator\Exception\ErrorRegistryExceptionInterface $exception) use (&$i) {
66
return "$carry\n - Composition element #" . ++$i . (
77
$exception->getErrors()
88
? ": Failed\n * " . implode("\n * ", $exception->getErrors())

src/Templates/Model.phptpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ declare(strict_types = 1);
1717
{% if namespace %} * @package {{ namespace }} {% endif %}
1818
*/
1919
class {{ class }}
20+
{% if generatorConfiguration.hasSerializationEnabled() %}implements PHPModelGenerator\Interfaces\SerializationInterface{% endif %}
2021
{
2122
{% foreach properties as property %}
2223
/** @var {{ property.getTypeHint() }}{% if property.getDescription() %} {{ property.getDescription() }}{% endif %} */

tests/AbstractPHPModelGeneratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use FilesystemIterator;
66
use PHPModelGenerator\Utils\ClassNameGenerator;
7-
use PHPModelGeneratorException\ErrorRegistryException;
7+
use PHPModelGenerator\Exception\ErrorRegistryException;
88
use PHPModelGenerator\Exception\FileSystemException;
99
use PHPModelGenerator\Exception\RenderException;
1010
use PHPModelGenerator\Exception\SchemaException;
11-
use PHPModelGeneratorException\ValidationException;
11+
use PHPModelGenerator\Exception\ValidationException;
1212
use PHPModelGenerator\ModelGenerator;
1313
use PHPModelGenerator\Model\GeneratorConfiguration;
1414
use PHPUnit\Framework\TestCase;

0 commit comments

Comments
 (0)