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

Swagger output is missing method specific input filters #40

Open
Jakovitz opened this issue Nov 28, 2018 · 1 comment
Open

Swagger output is missing method specific input filters #40

Jakovitz opened this issue Nov 28, 2018 · 1 comment

Comments

@Jakovitz
Copy link

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
Copy link
Member

This repository has been closed and moved to laminas-api-tools/api-tools-documentation-swagger; a new issue has been opened at laminas-api-tools/api-tools-documentation-swagger#2.

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