Skip to content

Commit a888581

Browse files
committed
Merge branch 'feature/59' into develop
Close #59 Fixes #57 Fixes #58 Fixes #67
2 parents 208630c + e988d79 commit a888581

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file, in reverse
66

77
### Added
88

9-
- Nothing.
9+
- [#59](https://github.com/zfcampus/zf-apigility-documentation/pull/59) adds the ability to specify examples for fields.
1010

1111
### Changed
1212

@@ -24,7 +24,11 @@ All notable changes to this project will be documented in this file, in reverse
2424

2525
### Fixed
2626

27-
- Nothing.
27+
- [#59](https://github.com/zfcampus/zf-apigility-documentation/pull/59) provides a fix to configuration detection that removes an emitted
28+
notice when no zf-rpc and/or no zf-rest configuration is present.
29+
30+
- [#59](https://github.com/zfcampus/zf-apigility-documentation/pull/59) fixes the "api" route parameter constraint to accept `%` characters, which
31+
are often present when multi-segment namespaces are used for a given API name.
2832

2933
## 1.2.3 - 2016-10-11
3034

config/module.config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'options' => [
2020
'route' => '/documentation[/:api[-v:version][/:service]]',
2121
'constraints' => [
22-
'api' => '[a-zA-Z][a-zA-Z0-9_.]+',
22+
'api' => '[a-zA-Z][a-zA-Z0-9_.%]+',
2323
],
2424
'defaults' => [
2525
'controller' => Controller::class,

src/ApiFactory.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ public function createApi($apiName, $apiVersion = 1)
102102
$api->setName($apiName);
103103

104104
$serviceConfigs = [];
105-
if ($this->config['zf-rest']) {
105+
if (!empty($this->config['zf-rest'])) {
106106
$serviceConfigs = array_merge($serviceConfigs, $this->config['zf-rest']);
107107
}
108-
if ($this->config['zf-rpc']) {
108+
if (!empty($this->config['zf-rpc'])) {
109109
$serviceConfigs = array_merge($serviceConfigs, $this->config['zf-rpc']);
110110
}
111111

@@ -407,6 +407,10 @@ private function getField(array $fieldData)
407407
$field->setFieldType($fieldData['field_type']);
408408
}
409409

410+
if (isset($fieldData['example'])) {
411+
$field->setExample($fieldData['example']);
412+
}
413+
410414
$required = isset($fieldData['required']) ? (bool) $fieldData['required'] : false;
411415
$field->setRequired($required);
412416

src/Field.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ class Field implements IteratorAggregate
3636
*/
3737
protected $fieldType = '';
3838

39+
/**
40+
* @var string
41+
*/
42+
protected $example;
43+
3944
/**
4045
* @param string $name
4146
*/
@@ -116,6 +121,18 @@ public function setFieldType($fieldType)
116121
$this->fieldType = $fieldType;
117122
}
118123

124+
public function getExample()
125+
{
126+
return $this->example;
127+
}
128+
129+
public function setExample($example)
130+
{
131+
$this->example = $example;
132+
133+
return $this;
134+
}
135+
119136
/**
120137
* Cast object to array
121138
*
@@ -127,6 +144,7 @@ public function toArray()
127144
'description' => $this->description,
128145
'required' => $this->required,
129146
'type' => $this->fieldType,
147+
'example' => $this->example,
130148
];
131149
}
132150

src/View/AgAcceptHeaders.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ class AgAcceptHeaders extends AbstractHelper
1919
*/
2020
public function __invoke(Service $service)
2121
{
22+
$requestAcceptTypes = $service->getRequestAcceptTypes();
23+
if (empty($requestAcceptTypes)) {
24+
$requestAcceptTypes = [];
25+
}
26+
2227
$view = $this->getView();
2328
$types = array_map(function ($type) use ($view) {
2429
return sprintf('<div class="list-group-item">%s</div>', $view->escapeHtml($type));
25-
}, $service->getRequestAcceptTypes());
30+
}, $requestAcceptTypes);
2631
return implode("\n", $types);
2732
}
2833
}

src/View/AgContentTypeHeaders.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ class AgContentTypeHeaders extends AbstractHelper
1919
*/
2020
public function __invoke(Service $service)
2121
{
22+
$requestContentTypes = [];
23+
if (!empty($service->getRequestContentTypes())) {
24+
$requestContentTypes = $service->getRequestContentTypes();
25+
}
26+
2227
$view = $this->getView();
2328
$types = array_map(function ($type) use ($view) {
2429
return sprintf('<div class="list-group-item">%s</div>', $view->escapeHtml($type));
25-
}, $service->getRequestContentTypes());
30+
}, $requestContentTypes);
2631
return implode("\n", $types);
2732
}
2833
}

0 commit comments

Comments
 (0)