Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

REST: Documentation for method-specific fields is not generated #20

Closed
koodikindral opened this issue Dec 7, 2014 · 2 comments
Closed

Comments

@koodikindral
Copy link
Contributor

When I try to add some fields for POST method, then they don't appear in documentation:

'zf-content-validation' => array(
    'AlbumService\\V1\\Rest\\Album\\Controller' => array(
        'POST' => 'AlbumService\\V1\\Rest\\Album\\NewAlbumValidator',
    ),
),
'input_filter_specs' => array(
    'AlbumService\\V1\\Rest\\Album\\NewAlbumValidator' => array(
        0 => array(
            'name' => 'name',
            'required' => true,
            'filters' => array(),
            'validators' => array(),
            'description' => 'Album name',
            'allow_empty' => false,
            'continue_if_empty' => false,
        ),
    ),
),

zf-apigility-documentation\src\ApiFactory.php seems to iterate only over the input_filter array, and it doesn't look POST, PUT and other custom validation elements:

    if (isset($this->config['zf-content-validation'][$serviceClassName]['input_filter'])) {
        $validatorName = $this->config['zf-content-validation'][$serviceClassName]['input_filter'];
        $fields = array();
        if (isset($this->config['input_filter_specs'][$validatorName])) {
            foreach ($this->config['input_filter_specs'][$validatorName] as $fieldData) {
                $fields[] = $field = new Field();
                $field->setName($fieldData['name']);
                if (isset($fieldData['description'])) {
                    $field->setDescription($fieldData['description']);
                }
                $field->setRequired($fieldData['required']);
            }
            $service->setFields($fields);
            $hasFields = true;
        }
    }
@koodikindral
Copy link
Contributor Author

please see: 711f08d

@kevinpapst
Copy link
Contributor

Good idea, I worked on something very similar. But I thought about having validation fields for the default API methods instead of the HTTP methods.
Its likely that you want different validators for fetch() and fetchAll() were both would use the GET fields.

koodikindral added a commit to koodikindral/zf-apigility-documentation that referenced this issue Dec 27, 2014
…erated

Method-specific fields don't appear in documentation
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants