Skip to content

[v0.3.2] incorrect output data type in this example #58

@weibird0917

Description

@weibird0917

Hi, @fsbahman, in this example, will generate the incorrect swagger.json file.

/**
 * @api {post} /users Request CreateUsers
 * @apiName CreateUsers
 * @apiGroup User
 *
 * @apiParam {Object[]}     users         User list.
 * @apiParam {String}       users.id      UUID of user.
 * @apiParam {String}       users.name    Name of user.
 *
 * @apiSuccess {String}     status        Status of request.
 * @apiSuccess {Object[]}   users         User list.
 * @apiSuccess {String}     users.id      UUID of user.
 * @apiSuccess {String}     users.name    Name of user.
 */
  1. it's doesn't work in "Object[]".
    because it could not find the items type "Object" ( maybe should use "$refs"?)
...
 "definitions": {
        "CreateUsers": {
            "properties": {
                "users": {
                    "type": "array",
                    "description": "User list.",
                    "items": {
                        "type": "Object"
                    }
                },
...
  1. it's doesn't work in multiple "@apiSuccess".
    in this example, the responses.schema.type should not be "String", "String" is the first @apiSuccess type
...
                "responses": {
                    "200": {
                        "description": "successful operation",
                        "schema": {
                            "type": "String",
                            "items": {
                                "$ref": "#/definitions/CreateUsers"
                            }
                        }
                    }
                }
...

Here is the complete output swagger.json file:

{
    "swagger": "2.0",
    "info": {
        "title": "test",
        "version": "1.0.0",
        "description": "Test project description"
    },
    "paths": {
        "/users": {
            "post": {
                "tags": [
                    "User"
                ],
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "in": "body",
                        "name": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/CreateUsers"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "successful operation",
                        "schema": {
                            "type": "String",
                            "items": {
                                "$ref": "#/definitions/CreateUsers"
                            }
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "CreateUsers": {
            "properties": {
                "users": {
                    "type": "array",
                    "description": "User list.",
                    "items": {
                        "type": "Object"
                    }
                },
                "status": {
                    "type": "string",
                    "description": "Status of request."
                }
            },
            "required": [
                "users",
                "status"
            ]
        },
        "users": {
            "properties": {
                "id": {
                    "type": "string",
                    "description": "UUID of user."
                },
                "name": {
                    "type": "string",
                    "description": "Name of user."
                }
            },
            "required": [
                "id",
                "name"
            ]
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions