Skip to content

Commit 97423a4

Browse files
authored
Merge pull request #131 from php-api-clients/client-subsplit
Client SubSplit
2 parents d799fc3 + 3867a56 commit 97423a4

31 files changed

+1549
-54
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
bin/openapi-client-generator
2+
example/generated
3+
example/generated-subsplit
24
vendor

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ help: ## Show this help ###
7070
@printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
7171
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#'
7272

73-
generate-client:
74-
$(DOCKER_RUN) php ./bin/openapi-client-generator ./openapi-client.yaml
73+
generate-example-client:
74+
$(DOCKER_RUN) php ./bin/openapi-client-generator ./example/openapi-client.yaml

bin/openapi-client-generator.source

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ use Symfony\Component\Yaml\Yaml;
1919
*/
2020
exit((function (string $configurationFile): int {
2121
$configuration = (new ObjectMapperUsingReflection())->hydrateObject(Configuration::class, Yaml::parseFile($configurationFile));
22-
(new Generator($configuration->spec))->generate($configuration->namespace . '\\', dirname($configurationFile) . DIRECTORY_SEPARATOR . $configuration->destination, $configuration);
22+
(new Generator(
23+
$configuration->spec
24+
))->generate(
25+
$configuration->namespace . '\\',
26+
dirname($configurationFile) . DIRECTORY_SEPARATOR . $configuration->destination->root . DIRECTORY_SEPARATOR,
27+
$configuration,
28+
);
2329

2430
return 0;
2531
})($configuration));
26-
})($argv[1]);
32+
})($argv[1]);

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
"react/async": "^4.0",
3737
"wyrihaximus/react-awaitable-observable": "^1.0",
3838
"ckr/arraymerger": "^3.0",
39-
"ramsey/uuid": "^4.7"
39+
"ramsey/uuid": "^4.7",
40+
"wyrihaximus/subsplit-tools": "dev-main",
41+
"wyrihaximus/simple-twig": "^2.1"
4042
},
4143
"autoload": {
4244
"psr-4": {
43-
"ApiClients\\Tools\\OpenApiClientGenerator\\": "src/"
45+
"ApiClients\\Tools\\OpenApiClientGenerator\\": "src/",
46+
"ApiClients\\Client\\Github\\": "generated/"
4447
},
4548
"files": [
4649
"external_files/cebe/JsonReference.php",

composer.lock

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

example/openapi-client.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#spec: https://raw.githubusercontent.com/github/rest-api-description/main/descriptions-next/api.github.com/api.github.com.yaml
2+
spec: file:///home/wyrihaximus/Projects/PHPAPIClients/openapi-client-generator/example/api.github.com.yaml
3+
namespace: ApiClients\Client\Github
4+
destination:
5+
root: generated-subsplit
6+
source: src
7+
schemas:
8+
allowDuplication: true
9+
useAliasesForDuplication: true
10+
voter:
11+
listOperation:
12+
- ApiClients\Tools\OpenApiClientGenerator\Voter\ListOperation\PageAndPerPageInQuery
13+
streamOperation:
14+
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId
15+
subSplit:
16+
templatesDir: templates
17+
branch: v0.3.x
18+
subSplitConfiguration: etc/config.subsplit-publish.json
19+
fullName: GitHub {{ section }}
20+
vendor: api-clients
21+
sectionGenerator:
22+
- ApiClients\Tools\OpenApiClientGenerator\SectionGenerator\OperationIdSlash
23+
- ApiClients\Tools\OpenApiClientGenerator\SectionGenerator\WebHooks
24+
rootPackage:
25+
name: github
26+
repository: [email protected]:php-api-clients/github.git
27+
sectionPackage:
28+
name: github-{{ section }}
29+
repository: [email protected]:php-api-clients/github-{{ section }}.git

example/templates/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# [READONLY-SUBSPLIT] {{ packageName }}
2+
3+
4+
![Continuous Integration](https://github.com/php-api-clients/{{ packageName }}/workflows/Continuous%20Integration/badge.svg)
5+
[![Latest Stable Version](https://poser.pugx.org/api-clients/{{ packageName }}/v/stable.png)](https://packagist.org/packages/api-clients/{{ packageName }})
6+
[![Total Downloads](https://poser.pugx.org/api-clients/{{ packageName }}/downloads.png)](https://packagist.org/packages/api-clients/{{ packageName }})
7+
[![Code Coverage](https://scrutinizer-ci.com/g/php-api-clients/{{ packageName }}/badges/coverage.png?b=={{ branch }})](https://scrutinizer-ci.com/g/php-api-clients/{{ packageName }}/?branch={{ branch }})
8+
[![License](https://poser.pugx.org/api-clients/{{ packageName }}/license.png)](https://packagist.org/packages/api-clients/{{ packageName }})
9+
10+
Non-Blocking first {{ fullName }} client, this is a read only sub split, see [`github-root`](https://github.com/php-api-clients/github-root).

example/templates/composer.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "api-clients/{{ packageName }}",
3+
"description": "Non-Blocking first {{ fullName }} client",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Cees-Jan Kiewiet",
8+
"email": "[email protected]"
9+
}
10+
],
11+
"require": {
12+
"php": "^8.2",
13+
{% for require in requires %}
14+
"{{ require.name }}": "{{ require.version }}",
15+
{% endfor %}
16+
"api-clients/contracts": "^0.1",
17+
"cebe/php-openapi": "dev-openapi-31 as 1.6.0",
18+
"eventsauce/object-hydrator": "^1.1",
19+
"league/openapi-psr7-validator": "^0.18",
20+
"react/async": "^4.0",
21+
"wyrihaximus/react-awaitable-observable": "^1.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"{{ namespace|trim('\\', 'left')|replace({'\\': '\\\\'}) }}": "src/"
26+
}
27+
},
28+
"config": {
29+
"sort-packages": true,
30+
"platform": {
31+
"php": "8.2.13"
32+
},
33+
"allow-plugins": {
34+
"dealerdirect/phpcodesniffer-composer-installer": true,
35+
"composer/package-versions-deprecated": true,
36+
"ergebnis/composer-normalize": true,
37+
"icanhazstring/composer-unused": true,
38+
"wyrihaximus/composer-update-bin-autoload-path": true,
39+
"infection/extension-installer": true
40+
}
41+
},
42+
{% if suggests|length > 0 %}
43+
"sugest": {
44+
{% for suggest in suggests %}
45+
"api-clients/{{ suggest.name }}": "{{ suggest.reason }}"{% if not loop.last %},{% endif %}
46+
{% endfor %}
47+
},
48+
{% endif %}
49+
"require-dev": {
50+
"wyrihaximus/async-test-utilities": "^5.0"
51+
}
52+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
spec: {{ specUrl }}
2+
namespace: ApiClients\Client\{{ namespace }}
3+
destination: ../src
4+
voter:
5+
listOperation:
6+
- ApiClients\Tools\OpenApiClientGenerator\Voter\ListOperation\PageAndPerPageInQuery
7+
streamOperation:
8+
- ApiClients\Tools\OpenApiClientGenerator\Voter\StreamOperation\DownloadInOperationId

openapi-client.yaml

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

0 commit comments

Comments
 (0)