Skip to content

Commit 0da6c4f

Browse files
authored
Merge pull request #33 from DoclerLabs/support-openapi-license
feat: use openapi license name in generated composer.json file
2 parents b0a7de1 + 4853c76 commit 0da6c4f

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ 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

77

8+
## [5.4.0] - 2021-04-22
9+
### Added
10+
- Support for `license` info. Use it in the default composer.json tpl.
11+
812
## [5.3.0] - 2021-04-13
913
### Added
1014
- Support for `mixed` parameter type

example/gen/composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "openapi/pet-store-client",
33
"description": "Client library for Swagger Petstore - OpenAPI 3.0",
4+
"license": "Apache 2.0",
45
"keywords": [
56
"api-client"
67
],

src/Input/Specification.php

+12
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ public function getTitle(): string
3434
return $this->openApi->info->title;
3535
}
3636

37+
public function hasLicense(): bool
38+
{
39+
$license = $this->openApi->info->license;
40+
41+
return $license && $license->name;
42+
}
43+
44+
public function getLicenseName(): string
45+
{
46+
return $this->openApi->info->license->name;
47+
}
48+
3749
public function getServerUrls(): array
3850
{
3951
$serverUrls = [];

template/composer.json.twig

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"name": "{{ packageName }}",
33
"description": "Client library for {{ specification.getTitle() }}",
4-
"keywords": [
4+
{% if specification.hasLicense %}
5+
"license": "{{ specification.getLicenseName }}",
6+
{% endif %}
7+
"keywords": [
58
"api-client"
69
],
710
"config": {

0 commit comments

Comments
 (0)