Skip to content

Commit ab2500f

Browse files
author
Mikhail Bakulin
authored
Merge pull request #26 from DoclerLabs/add-generate-example-test
Add petstore3 API request examples
2 parents 03687eb + 413464a commit ab2500f

File tree

105 files changed

+9325
-940
lines changed

Some content is hidden

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

105 files changed

+9325
-940
lines changed

CHANGELOG.md

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

7+
## [4.2.0] - 2021-01-24
8+
### Added
9+
- Acceptance test to generate example from canonical pet store OpenApi specification
10+
- Content-type argument if multiple specified for request
11+
### Fixed
12+
- Literal type JSON response body
13+
### Changed
14+
- Multiple content-type per request and response with the same schema allowed
15+
- Changed non-existing successful response error to a warning
16+
717
## [4.1.0] - 2020-12-28
818
### Fixed
919
- Nullable mandatory DateTime properties in schema now work correctly without doing `new DateTimeImmutable(null)`

README.md

+42-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,47 @@ API client generator is a console application capable of auto-generating a [PSR1
66
[![Coverage Status](https://coveralls.io/repos/github/DoclerLabs/api-client-generator/badge.svg?branch=master)](https://coveralls.io/github/DoclerLabs/api-client-generator?branch=master)
77
[![PHPStan Level](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat)](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat)
88

9+
## Requirements
10+
- OpenAPI >= 3.0
11+
- PHP >= 7.0
12+
- [PSR-18 base client](https://packagist.org/providers/psr/http-client-implementation)
13+
14+
## Why using it?
15+
- With generated client you are always sure that your OpenAPI specification is up-to-date.
16+
- Work with objects instead of raw data, it is OOP friendly.
17+
- Saves your time. You don't need to write data mappers youself to populate those objects with the data from the response.
18+
- All the basic type validations in the request and the response done automatically.
19+
- Despite the fact the code is generated it's clear and readable, simple to debug and to reason about.
20+
- Highly configurable and extensible.
21+
- Reliable and well tested.
22+
- Simply, **if something can be automated it should be automated.** Focus on important stuff.
23+
24+
## Features
25+
- Supports yaml or json specification file formats.
26+
- Validates your OpenAPI specification.
27+
- Supports multiple content types:
28+
* application/json
29+
* application/x-www-form-urlencoded
30+
* application/xml
31+
- Supports new PHP versions synthax features.
32+
- It is base client independent, you are free to choose any [existing PSR-18 compliant client](https://packagist.org/providers/psr/http-client-implementation). Just choose the one which you already use, so generated client would not cause conflicts in your dependencies.
33+
- Applies code style rules to generated code, you can specify your own.
34+
- Generates README and composer.json files with possibility to use your own template.
35+
- Supports `allOf` OpenAPI parameter.
36+
37+
## Example
38+
Check out [example](https://github.com/DoclerLabs/api-client-generator/tree/master/example) directory to see the code generated by api-client-generator.
39+
40+
Try it out:
41+
```bash
42+
cd example && \
43+
composer install && \
44+
php test-example.php
45+
```
46+
947
## Usage
1048
### With Docker
11-
```
49+
```bash
1250
$ docker run -it \
1351
-v {path-to-specification}/openapi.yaml:/openapi.yaml:ro \
1452
-v {path-to-client}/some-api-client:/client \
@@ -23,7 +61,9 @@ dhlabs/api-client-generator
2361
Preconditions: PHP 7.4
2462

2563
Clone the repository and run:
26-
```OPENAPI={path-to-specification}/openapi.yaml NAMESPACE=Group\SomeApiClient PACKAGE=group/some-api-client OUTPUT_DIR={path-to-client}/generated ./bin/api-client-generator generate```
64+
```bash
65+
OPENAPI={path-to-specification}/openapi.yaml NAMESPACE=Group\SomeApiClient PACKAGE=group/some-api-client OUTPUT_DIR={path-to-client}/generated ./bin/api-client-generator generate
66+
```
2767

2868
## Configuration
2969
The following environment variables are available:

composer.json

+52-47
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
11
{
2-
"name": "docler-labs/api-client-generator",
3-
"version": "3.0.0",
4-
"description": "SDK Generator - API Client Generator",
5-
"type": "library",
6-
"license": "MIT",
7-
"keywords": [
8-
"rest",
9-
"api",
10-
"api-client",
11-
"openapi",
12-
"sdk",
13-
"generator",
14-
"api-client-generator"
15-
],
16-
"require": {
17-
"php": ">=7.4",
18-
"ext-json": "*",
19-
"ext-dom": "*",
20-
"cebe/php-openapi": "^1.4",
21-
"docler-labs/api-client-exception": "^1.0.1",
22-
"friendsofphp/php-cs-fixer": "^2.16",
23-
"guzzlehttp/psr7": "^1.6",
24-
"nikic/php-parser": "^4.10",
25-
"nyholm/psr7": "^1.3",
26-
"pimple/pimple": "^3.3",
27-
"psr/http-client": "^1.0",
28-
"psr/http-message": "^1.0",
29-
"psr/container": "^1.0",
30-
"symfony/console": "^5.1",
31-
"symfony/yaml": "^5.1",
32-
"twig/twig": "^3.0"
33-
},
34-
"require-dev": {
35-
"php-coveralls/php-coveralls": "^2.2",
36-
"phpstan/phpstan": "^0.12.32",
37-
"phpunit/phpunit": "^9.2",
38-
"roave/security-advisories": "dev-latest"
39-
},
40-
"autoload": {
41-
"psr-4": {
42-
"DoclerLabs\\ApiClientGenerator\\Test\\Unit\\": "test/suite/unit",
43-
"DoclerLabs\\ApiClientGenerator\\Test\\Functional\\": "test/suite/functional",
44-
"DoclerLabs\\ApiClientGenerator\\": "src/"
45-
}
46-
},
47-
"config": {
48-
"sort-packages": true
2+
"name": "docler-labs/api-client-generator",
3+
"version": "3.0.0",
4+
"description": "SDK Generator - API Client Generator",
5+
"type": "library",
6+
"license": "MIT",
7+
"keywords": [
8+
"rest",
9+
"api",
10+
"api-client",
11+
"openapi",
12+
"sdk",
13+
"generator",
14+
"api-client-generator"
15+
],
16+
"require": {
17+
"php": ">=7.4",
18+
"ext-dom": "*",
19+
"ext-json": "*",
20+
"ext-xml": "*",
21+
"cebe/php-openapi": "^1.4",
22+
"docler-labs/api-client-exception": "^1.0.1",
23+
"friendsofphp/php-cs-fixer": "^2.16",
24+
"guzzlehttp/psr7": "^1.6",
25+
"icecave/parity": "^3.0",
26+
"nikic/php-parser": "^4.10",
27+
"nyholm/psr7": "^1.3",
28+
"pimple/pimple": "^3.3",
29+
"psr/container": "^1.0",
30+
"psr/http-client": "^1.0",
31+
"psr/http-message": "^1.0",
32+
"symfony/console": "^5.1",
33+
"symfony/yaml": "^5.1",
34+
"twig/twig": "^3.0"
35+
},
36+
"require-dev": {
37+
"composer/composer": "^2.0",
38+
"php-coveralls/php-coveralls": "^2.2",
39+
"phpstan/phpstan": "^0.12.32",
40+
"phpunit/phpunit": "^9.2",
41+
"roave/security-advisories": "dev-latest",
42+
"symfony/filesystem": "^5.1"
43+
},
44+
"autoload": {
45+
"psr-4": {
46+
"DoclerLabs\\ApiClientGenerator\\Test\\Unit\\": "test/suite/unit",
47+
"DoclerLabs\\ApiClientGenerator\\Test\\Functional\\": "test/suite/functional",
48+
"DoclerLabs\\ApiClientGenerator\\Test\\Acceptance\\": "test/suite/acceptance",
49+
"DoclerLabs\\ApiClientGenerator\\": "src/"
4950
}
51+
},
52+
"config": {
53+
"sort-packages": true
54+
}
5055
}

0 commit comments

Comments
 (0)