zfcampus / zf-apigility-documentation-swagger

BSD 3-Clause "New" or "Revised" License
11 stars 27 forks source link

Swagger output is missing method specific input filters #40

Open Jakovitz opened 5 years ago

Jakovitz commented 5 years ago

The Swagger output only contains the default input filter from the config, but not the method specific ones. My api in this example is called OrdersApi, and below are excerpts from /apigility/documentation/OrdersApi-v1 that whows the difference:

Accept: application/json

{
    "name": "OrdersApi",
    "version": "1",
    "services": [
        {
            "name": "OrderListener",
            "route": "/api/order/listener[/:id]",
            "fields": {
                "input_filter": {
                    "worker": {
                        "description": "The worker name",
                        "required": true,
                        "type": "",
                        "example": null
                    },
                    "revision": {
                        "description": "Current revision number",
                        "required": true,
                        "type": "",
                        "example": null
                    }
                },
                "POST": {
                    "worker": {
                        "description": "The worker name",
                        "required": true,
                        "type": "",
                        "example": null
                    }
                }
            }
        }
    ]
}

Accept: application/vnd.swagger+json

{
    "swagger": "2.0",
    "info": {
        "title": "OrdersApi",
        "version": "1"
    },
    "tags": [
        {
            "name": "OrderListener"
        }
    ],
    "paths": {
        "/api/order/listener": {
            "post": {
                "tags": [
                    "OrderListener"
                ],
                "parameters": [
                    {
                        "in": "body",
                        "name": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/OrderListener"
                        }
                    }
                ]
            }
        },
        "/api/order/listener/{id}": {
            "put": {
                "tags": [
                    "OrderListener"
                ],
                "parameters": [
                    {
                        "in": "path",
                        "name": "id",
                        "description": "URL parameter id",
                        "type": "string",
                        "required": true,
                        "minimum": 0,
                        "maximum": 1
                    },
                    {
                        "in": "body",
                        "name": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/OrderListener"
                        }
                    }
                ]
            }
        }
    },
    "definitions": {
        "OrderListener": {
            "type": "object",
            "properties": {
                "worker": {
                    "type": "string",
                    "description": "The worker name"
                },
                "revision": {
                    "type": "string",
                    "description": "Current revision number"
                }
            },
            "required": [
                "worker",
                "revision"
            ]
        }
    }
}

Config

'zf-content-validation' => [
    'OrdersApi\\V1\\Rest\\Order\\Listener\\Controller' => [
        'input_filter' => 'OrdersApi\\V1\\Rest\\Order\\Listener\\Validator',
        'POST' => 'OrdersApi\\V1\\Rest\\Order\\Listener\\ValidatorCreate',
    ],
],
'input_filter_specs' => [
    'OrdersApi\\V1\\Rest\\Order\\Listener\\Validator' => [
        [
            'required' => true,
            'validators' => [
                [
                    'name' => \Zend\Validator\NotEmpty::class,
                    'options' => [],
                ],
                [
                    'name' => \Zend\Validator\StringLength::class,
                    'options' => [],
                ],
            ],
            'filters' => [],
            'name' => 'worker',
            'description' => 'The worker name',
        ],
        [
            'required' => true,
            'validators' => [
                [
                    'name' => \Zend\Validator\NotEmpty::class,
                    'options' => [],
                ],
                [
                    'name' => \Zend\Validator\Digits::class,
                    'options' => [],
                ],
            ],
            'filters' => [],
            'name' => 'revision',
            'description' => 'Current revision number',
        ],
    ],
    'OrdersApi\\V1\\Rest\\Order\\Listener\\ValidatorCreate' => [
        [
            'required' => true,
            'validators' => [
                [
                    'name' => \Zend\Validator\NotEmpty::class,
                    'options' => [],
                ],
                [
                    'name' => \Zend\Validator\StringLength::class,
                    'options' => [],
                ],
            ],
            'filters' => [],
            'name' => 'worker',
            'description' => 'The worker name',
        ],
    ],
],
weierophinney commented 4 years ago

This repository has been closed and moved to laminas-api-tools/api-tools-documentation-swagger; a new issue has been opened at https://github.com/laminas-api-tools/api-tools-documentation-swagger/issues/2.