Skip to content

Commit 5954af5

Browse files
committed
Add binairy to generate client
1 parent b815067 commit 5954af5

File tree

6 files changed

+93
-8
lines changed

6 files changed

+93
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin/openapi-client-generator
2+
vendor

bin/openapi-client-generator.source

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/php
2+
<?php declare(strict_types=1);
3+
4+
use ApiClients\Tools\OpenApiClientGenerator\Generator;
5+
use Symfony\Component\Yaml\Yaml;
6+
7+
(function(): void {
8+
/**
9+
* Require Composer's autoloader
10+
*/
11+
require_once '%s';
12+
})();
13+
14+
(function(string $configuration): void {
15+
/**
16+
* Create and boot up the application
17+
*/
18+
exit((function (string $configuration): int {
19+
$yaml = Yaml::parseFile($configuration);
20+
(new Generator($yaml['spec']))->generate($yaml['namespace'] . '\\', $yaml['destination']);
21+
22+
return 0;
23+
})($configuration));
24+
})($argv[1]);

composer.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,26 @@
88
"email": "[email protected]"
99
}
1010
],
11+
"bin": [
12+
"bin/openapi-client-generator"
13+
],
14+
"extra": {
15+
"wyrihaximus": {
16+
"bin-autoload-path-update": [
17+
"bin/openapi-client-generator"
18+
]
19+
}
20+
},
1121
"require": {
1222
"php": "^7.4",
1323
"cebe/php-openapi": "^1.4",
1424
"jawira/case-converter": "^3.4",
1525
"twig/twig": "^3.0",
1626
"nikic/php-parser": "^4.8",
1727
"psr/http-message": "^1.0",
18-
"ringcentral/psr7": "^1.3"
28+
"ringcentral/psr7": "^1.3",
29+
"symfony/yaml": "^5.2",
30+
"wyrihaximus/composer-update-bin-autoload-path": "^1 || ^1.0.1"
1931
},
2032
"autoload": {
2133
"psr-4": {

composer.lock

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

openapi-client.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml
2+
namespace: ApiClients\Client\Github
3+
destination: generated

test.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)