Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger output is missing method specific input filters #2

Open
weierophinney opened this issue Dec 31, 2019 · 0 comments
Open

Swagger output is missing method specific input filters #2

weierophinney opened this issue Dec 31, 2019 · 0 comments

Comments

@weierophinney
Copy link
Contributor

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',
        ],
    ],
],

Originally posted by @Jakovitz at zfcampus/zf-apigility-documentation-swagger#40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant