Skip to content

Commit a71376f

Browse files
authored
Fix handling of *Of in PHP generation (#40)
1 parent 9336e31 commit a71376f

23 files changed

+535
-33
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.11.1] - 2022-11-14
8+
9+
### Fixed
10+
- Handling of `*Of` in PHP generation.
11+
712
## [1.11.0] - 2022-09-18
813

914
### Added
@@ -218,6 +223,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
218223
### Fixed
219224
- Local file resolver in references.
220225

226+
[1.11.1]: https://github.com/swaggest/json-cli/compare/v1.10.1...v1.11.1
221227
[1.11.0]: https://github.com/swaggest/json-cli/compare/v1.10.0...v1.11.0
222228
[1.10.0]: https://github.com/swaggest/json-cli/compare/v1.9.1...v1.10.0
223229
[1.9.1]: https://github.com/swaggest/json-cli/compare/v1.9.0...v1.9.1

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"salsify/json-streaming-parser": "^7.0",
1818
"swaggest/json-schema": "^0.12.41",
1919
"swaggest/go-code-builder": "0.4.51",
20-
"swaggest/php-code-builder": "^0.2.37",
20+
"swaggest/php-code-builder": "^0.2.38",
2121
"swaggest/code-builder": "^0.3.5",
2222
"swaggest/json-schema-maker": "^0.3.7"
2323
},
2424
"require-dev": {
25-
"phperf/phpunit": "4.8.37"
25+
"phperf/phpunit": "4.8.38"
2626
},
2727
"autoload": {
2828
"psr-4": {

composer.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.php

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

88
class App extends Command\Application
99
{
10-
public static $ver = 'v1.11.0';
10+
public static $ver = 'v1.11.1';
1111

1212
public $diff;
1313
public $apply;

src/GenPhp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function setUpDefinition(Command\Definition $definition, $options)
4040
->setIsRequired();
4141

4242
$options->rootName = Command\Option::create()->setType()
43-
->setDescription('Go root struct name, default "Structure", only used for # pointer');
43+
->setDescription('Root class name, default "Structure", only used for # pointer');
4444

4545
static::setupBuilderOptions($options);
4646
Base::setupGenOptions($definition, $options);

tests/assets/issue39.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"id": "/Test",
3+
"type": "object",
4+
"properties": {
5+
"label": {
6+
"anyOf": [
7+
{
8+
"type": "integer"
9+
},
10+
{
11+
"type": "number"
12+
},
13+
{
14+
"type": "object",
15+
"properties": {
16+
"test1": {
17+
"type": "string"
18+
}
19+
}
20+
},
21+
{
22+
"type": "object",
23+
"properties": {
24+
"test2": {
25+
"type": "string"
26+
}
27+
}
28+
}
29+
]
30+
},
31+
"label2": {
32+
"oneOf": [
33+
{
34+
"type": "integer"
35+
},
36+
{
37+
"type": "number"
38+
},
39+
{
40+
"type": "object",
41+
"properties": {
42+
"test1": {
43+
"type": "string"
44+
}
45+
}
46+
},
47+
{
48+
"type": "object",
49+
"properties": {
50+
"test2": {
51+
"type": "string"
52+
}
53+
}
54+
}
55+
]
56+
}
57+
}
58+
}

tests/assets/issue39_2.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"id": "/Test",
3+
"anyOf": [
4+
{
5+
"type": "object",
6+
"properties": {
7+
"test1": {
8+
"type": "string"
9+
}
10+
}
11+
},
12+
{
13+
"type": "object",
14+
"properties": {
15+
"test2": {
16+
"type": "integer"
17+
}
18+
}
19+
}
20+
]
21+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Types
2+
3+
* [`Label2OneOf2`](#label2oneof2)
4+
* [`Label2OneOf3`](#label2oneof3)
5+
* [`LabelAnyOf2`](#labelanyof2)
6+
* [`LabelAnyOf3`](#labelanyof3)
7+
* [`Propertyb14a7b`](#propertyb14a7b)
8+
9+
10+
11+
12+
### <a id="label2oneof2"></a>Label2OneOf2
13+
14+
15+
16+
|Property|Type |
17+
|--------|--------|
18+
|`test1` |`String`|
19+
20+
21+
### <a id="label2oneof3"></a>Label2OneOf3
22+
23+
24+
25+
|Property|Type |
26+
|--------|--------|
27+
|`test2` |`String`|
28+
29+
30+
### <a id="labelanyof2"></a>LabelAnyOf2
31+
32+
33+
34+
|Property|Type |
35+
|--------|--------|
36+
|`test1` |`String`|
37+
38+
39+
### <a id="labelanyof3"></a>LabelAnyOf3
40+
41+
42+
43+
|Property|Type |
44+
|--------|--------|
45+
|`test2` |`String`|
46+
47+
48+
### <a id="propertyb14a7b"></a>Propertyb14a7b
49+
50+
51+
52+
|Property|Type |
53+
|--------|------------------------------------------------------------------------------------|
54+
|`label` |`Number`, `Number`, [`LabelAnyOf2`](#labelanyof2), [`LabelAnyOf3`](#labelanyof3) |
55+
|`label2`|`Number`, `Number`, [`Label2OneOf2`](#label2oneof2), [`Label2OneOf3`](#label2oneof3)|
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Types
2+
3+
* [`AnyOf0`](#anyof0)
4+
* [`AnyOf1`](#anyof1)
5+
6+
7+
8+
9+
### <a id="anyof0"></a>AnyOf0
10+
11+
12+
13+
|Property|Type |
14+
|--------|--------|
15+
|`test1` |`String`|
16+
17+
18+
### <a id="anyof1"></a>AnyOf1
19+
20+
21+
22+
|Property|Type |
23+
|--------|--------|
24+
|`test2` |`Number`|

tests/assets/php/AsyncAPI/Operation.php renamed to tests/assets/php/AsyncAPI/OperationOneOf1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Swaggest\JsonSchema\Structure\ClassStructure;
1515

1616

17-
class Operation extends ClassStructure
17+
class OperationOneOf1 extends ClassStructure
1818
{
1919
const X_PROPERTY_PATTERN = '^x-';
2020

0 commit comments

Comments
 (0)