Skip to content

Commit 9a6d5c7

Browse files
authored
feat: add OpenAPI support (#368)
1 parent 29df094 commit 9a6d5c7

File tree

92 files changed

+7426
-1555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7426
-1555
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
`schema` is a command line tool part of [the API Platform framework](https://api-platform.com) that instantly generates a set
44
of PHP classes from vocabularies such as (but not limited to) [Schema.org](https://schema.org)
5-
or [ActivityStreams](https://www.w3.org/TR/activitystreams-core/).
5+
or [ActivityStreams](https://www.w3.org/TR/activitystreams-core/) or from an [OpenAPI](https://www.openapis.org/) documentation.
66

7-
[![GitHub Actions](https://github.com/api-platform/schema-generator/workflows/CI/badge.svg?branch=master)](https://github.com/api-platform/schema-generator/actions?query=workflow%3ACI+branch%3Amaster)
8-
[![Coverage Status](https://coveralls.io/repos/github/api-platform/schema-generator/badge.svg?branch=master)](https://coveralls.io/github/api-platform/schema-generator?branch=master)
7+
[![GitHub Actions](https://github.com/api-platform/schema-generator/workflows/CI/badge.svg?branch=main)](https://github.com/api-platform/schema-generator/actions?query=workflow%3ACI+branch%3Amain)
8+
[![Coverage Status](https://coveralls.io/repos/github/api-platform/schema-generator/badge.svg?branch=main)](https://coveralls.io/github/api-platform/schema-generator?branch=main)
99

1010
## Documentation
1111

bin/compile

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,33 @@ rm -rf tmp/original
88

99
php schema.phar generate tmp/original tests/e2e/schema.yml -n -vv --ansi;
1010

11-
diff tests/e2e/original/App/Entity/Brand.php tmp/original/App/Entity/Brand.php;
12-
diff tests/e2e/original/App/Entity/Person.php tmp/original/App/Entity/Person.php;
13-
diff tests/e2e/original/App/Entity/PostalAddress.php tmp/original/App/Entity/PostalAddress.php;
14-
diff tests/e2e/original/App/Entity/Thing.php tmp/original/App/Entity/Thing.php;
15-
diff tests/e2e/original/App/Enum/GenderType.php tmp/original/App/Enum/GenderType.php;
11+
diff tests/e2e/original/App/Schema/Entity/Brand.php tmp/original/App/Schema/Entity/Brand.php;
12+
diff tests/e2e/original/App/Schema/Entity/Person.php tmp/original/App/Schema/Entity/Person.php;
13+
diff tests/e2e/original/App/Schema/Entity/PostalAddress.php tmp/original/App/Schema/Entity/PostalAddress.php;
14+
diff tests/e2e/original/App/Schema/Entity/Thing.php tmp/original/App/Schema/Entity/Thing.php;
15+
diff tests/e2e/original/App/Schema/Enum/GenderType.php tmp/original/App/Schema/Enum/GenderType.php;
1616

1717
# Already generated files
1818

1919
cp -r tests/e2e/customized tmp/
2020

2121
php schema.phar generate tmp/customized tests/e2e/schema.yml -n -vv --ansi;
2222

23-
diff tests/e2e/customized/App/Entity/Brand.php tmp/customized/App/Entity/Brand.php;
24-
diff tests/e2e/customized/App/Entity/Person.php tmp/customized/App/Entity/Person.php;
25-
diff tests/e2e/customized/App/Entity/PostalAddress.php tmp/customized/App/Entity/PostalAddress.php;
26-
diff tests/e2e/customized/App/Entity/Thing.php tmp/customized/App/Entity/Thing.php;
27-
diff tests/e2e/customized/App/Enum/GenderType.php tmp/customized/App/Enum/GenderType.php;
23+
diff tests/e2e/customized/App/Schema/Entity/Brand.php tmp/customized/App/Schema/Entity/Brand.php;
24+
diff tests/e2e/customized/App/Schema/Entity/Person.php tmp/customized/App/Schema/Entity/Person.php;
25+
diff tests/e2e/customized/App/Schema/Entity/PostalAddress.php tmp/customized/App/Schema/Entity/PostalAddress.php;
26+
diff tests/e2e/customized/App/Schema/Entity/Thing.php tmp/customized/App/Schema/Entity/Thing.php;
27+
diff tests/e2e/customized/App/Schema/Enum/GenderType.php tmp/customized/App/Schema/Enum/GenderType.php;
28+
29+
php schema.phar generate tmp/original tests/e2e/schema_openapi.yml -n -vv --ansi;
30+
31+
diff tests/e2e/original/App/OpenApi/Entity/Book.php tmp/original/App/OpenApi/Entity/Book.php;
32+
diff tests/e2e/original/App/OpenApi/Entity/Parchment.php tmp/original/App/OpenApi/Entity/Parchment.php;
33+
diff tests/e2e/original/App/OpenApi/Entity/Review.php tmp/original/App/OpenApi/Entity/Review.php;
34+
diff tests/e2e/original/App/OpenApi/Entity/TopBook.php tmp/original/App/OpenApi/Entity/TopBook.php;
35+
36+
php schema.phar generate tmp/original tests/e2e/schema_openapi_ref.yml -n -vv --ansi;
37+
38+
diff tests/e2e/original/App/OpenApi/Entity/Order.php tmp/original/App/OpenApi/Entity/Order.php;
39+
diff tests/e2e/original/App/OpenApi/Entity/Pet.php tmp/original/App/OpenApi/Entity/Pet.php;
40+
diff tests/e2e/original/App/OpenApi/Entity/User.php tmp/original/App/OpenApi/Entity/User.php;

box.json.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"files": [
1515
"vendor/twig/twig/src/TwigTest.php"
1616
],
17+
"directories": [
18+
"vendor/cebe/php-openapi/src/spec"
19+
],
1720
"force-autodiscovery": true,
1821

1922
"compression": "GZ",

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
"twig/twig": "^3.0",
4747
"nette/php-generator": "^3.6 || ^4.0-dev",
4848
"nette/utils": "^3.1 || ^4.0-dev",
49-
"nikic/php-parser": "^4.13"
49+
"nikic/php-parser": "^4.13",
50+
"cebe/php-openapi": "^1.6",
51+
"symfony/string": "^5.2 || ^6.0"
5052
},
5153
"require-dev": {
5254
"api-platform/core": "^2.5",

0 commit comments

Comments
 (0)