Skip to content

Commit aed301f

Browse files
committed
[generator] fixed sorting path parameters before generating models
1 parent 5c70f10 commit aed301f

File tree

11 files changed

+39
-21
lines changed

11 files changed

+39
-21
lines changed

docs/shield-api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ $bunnyHttpClient->request(
3737
);
3838
```
3939

40-
#### [List Shield Zone Pull Zone Mapping](https://docs.bunny.net/reference/get_shield-shield-zones-pullzone-mapping)
40+
#### [List Shield Zones Pull Zone Mapping](https://docs.bunny.net/reference/get_shield-shield-zones-pullzone-mapping)
4141

4242
```php
4343
$bunnyHttpClient->request(
44-
new \ToshY\BunnyNet\Model\Api\Shield\ShieldZone\GetShieldZonesPullzoneMapping()
44+
new \ToshY\BunnyNet\Model\Api\Shield\ShieldZone\ListShieldZonesPullzoneMapping()
4545
);
4646
```
4747

@@ -513,7 +513,7 @@ $bunnyHttpClient->request(
513513
);
514514
```
515515

516-
#### [Get WAF Rules Segmentation](https://docs.bunny.net/reference/get_shield-waf-rules-plan-segmentation)
516+
#### [Get WAF Rules Plan Segmentation](https://docs.bunny.net/reference/get_shield-waf-rules-plan-segmentation)
517517

518518
```php
519519
$bunnyHttpClient->request(

docs/stream-api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,10 @@ $bunnyHttpClient->request(
548548
);
549549
```
550550

551+
??? warning
552+
553+
This endpoint will return a `400` status code if premium encoding is there are no captions are available (or transcribing has not been triggered).
554+
551555
#### [Get OEmbed](https://docs.bunny.net/reference/oembed_getoembed)
552556

553557
```php

generator/Generator/ModelGenerator.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ private function generateModel(
232232
$existingClassHeaders = $this->getExistingModelHeaders($endpointClass);
233233

234234
$newSpecsPathParameters = $this->processParametersForPath(
235+
path: $path,
235236
operation: $operation,
236237
);
237238

@@ -908,6 +909,7 @@ private function processParametersForQuery(Operation $operation): array
908909
* @return array<mixed>
909910
*/
910911
private function processParametersForPath(
912+
string $path,
911913
Operation $operation,
912914
): array {
913915
$parameters = [];
@@ -927,6 +929,18 @@ private function processParametersForPath(
927929
];
928930
}
929931

932+
// Extract the path parameters from the path
933+
$matches = [];
934+
preg_match_all('/\{([a-zA-Z0-9_]+)\}/', $path, $matches);
935+
/* @phpstan-ignore-next-line nullCoalesce.offset */
936+
$pathParameters = $matches[1] ?? [];
937+
938+
usort($parameters, function ($a, $b) use ($pathParameters) {
939+
$pos_a = array_search($a['name'], $pathParameters, true);
940+
$pos_b = array_search($b['name'], $pathParameters, true);
941+
return $pos_a <=> $pos_b;
942+
});
943+
930944
return $parameters;
931945
}
932946

generator/Map/Shield.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\CreateShieldZone;
3131
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\GetShieldZone;
3232
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\GetShieldZoneByPullZoneId;
33-
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\GetShieldZonesPullzoneMapping;
33+
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\ListShieldZonesPullzoneMapping;
3434
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\ListShieldZones;
3535
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\UpdateShieldZone;
3636
use ToshY\BunnyNet\Model\Api\Shield\UploadScanning\CreateOrUpdateShieldZoneUploadScanning;
@@ -118,7 +118,7 @@ final class Shield
118118
'get' => ListShieldZones::class,
119119
],
120120
'/shield/shield-zones/pullzone-mapping' => [
121-
'get' => GetShieldZonesPullzoneMapping::class,
121+
'get' => ListShieldZonesPullzoneMapping::class,
122122
],
123123
'/shield/shield-zone/{shieldZoneId}' => [
124124
'get' => GetShieldZone::class,

src/Enum/Validation/Map/Shield.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\CreateShieldZone;
3232
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\GetShieldZone;
3333
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\GetShieldZoneByPullZoneId;
34-
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\GetShieldZonesPullzoneMapping;
3534
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\ListShieldZones;
35+
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\ListShieldZonesPullzoneMapping;
3636
use ToshY\BunnyNet\Model\Api\Shield\ShieldZone\UpdateShieldZone;
3737
use ToshY\BunnyNet\Model\Api\Shield\UploadScanning\CreateOrUpdateShieldZoneUploadScanning;
3838
use ToshY\BunnyNet\Model\Api\Shield\UploadScanning\GetShieldZoneUploadScanning;
@@ -79,7 +79,7 @@ final class Shield
7979
UpdateRateLimit::class => ModelValidationStrategy::STRICT_BODY,
8080
CreateRateLimit::class => ModelValidationStrategy::STRICT_BODY,
8181
ListShieldZones::class => ModelValidationStrategy::STRICT_QUERY,
82-
GetShieldZonesPullzoneMapping::class => ModelValidationStrategy::NONE,
82+
ListShieldZonesPullzoneMapping::class => ModelValidationStrategy::NONE,
8383
GetShieldZone::class => ModelValidationStrategy::NONE,
8484
GetShieldZoneByPullZoneId::class => ModelValidationStrategy::NONE,
8585
CreateShieldZone::class => ModelValidationStrategy::STRICT_BODY,

src/Enum/Validation/Map/Stream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\ReEncodeVideo;
2727
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\RepackageVideo;
2828
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\SetThumbnail;
29-
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\TriggerSmartActions;
3029
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\TranscribeVideo;
30+
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\TriggerSmartActions;
3131
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\UpdateVideo;
3232
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\UploadVideo;
3333
use ToshY\BunnyNet\Model\Api\Stream\ManageVideos\VideoResolutionsInfo;

src/Model/Api/Shield/AccessLists/DeleteShieldZoneAccessList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
class DeleteShieldZoneAccessList implements ModelInterface
1313
{
1414
/**
15-
* @param int $id
1615
* @param int $shieldZoneId
16+
* @param int $id
1717
*/
1818
public function __construct(
19-
#[PathProperty]
20-
public readonly int $id,
2119
#[PathProperty]
2220
public readonly int $shieldZoneId,
21+
#[PathProperty]
22+
public readonly int $id,
2323
) {
2424
}
2525

src/Model/Api/Shield/AccessLists/GetShieldZoneAccessList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
class GetShieldZoneAccessList implements ModelInterface
1313
{
1414
/**
15-
* @param int $id
1615
* @param int $shieldZoneId
16+
* @param int $id
1717
*/
1818
public function __construct(
19-
#[PathProperty]
20-
public readonly int $id,
2119
#[PathProperty]
2220
public readonly int $shieldZoneId,
21+
#[PathProperty]
22+
public readonly int $id,
2323
) {
2424
}
2525

src/Model/Api/Shield/AccessLists/UpdateShieldZoneAccessList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
class UpdateShieldZoneAccessList implements ModelInterface, BodyModelInterface
1717
{
1818
/**
19-
* @param int $id
2019
* @param int $shieldZoneId
20+
* @param int $id
2121
* @param array<string,mixed> $body
2222
*/
2323
public function __construct(
24-
#[PathProperty]
25-
public readonly int $id,
2624
#[PathProperty]
2725
public readonly int $shieldZoneId,
26+
#[PathProperty]
27+
public readonly int $id,
2828
#[BodyProperty]
2929
public readonly array $body = [],
3030
) {

src/Model/Api/Shield/AccessLists/UpdateShieldZoneCuratedThreatList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
class UpdateShieldZoneCuratedThreatList implements ModelInterface, BodyModelInterface
1717
{
1818
/**
19-
* @param int $id
2019
* @param int $shieldZoneId
20+
* @param int $id
2121
* @param array<string,mixed> $body
2222
*/
2323
public function __construct(
24-
#[PathProperty]
25-
public readonly int $id,
2624
#[PathProperty]
2725
public readonly int $shieldZoneId,
26+
#[PathProperty]
27+
public readonly int $id,
2828
#[BodyProperty]
2929
public readonly array $body = [],
3030
) {

0 commit comments

Comments
 (0)