How to put multiple methods/functions having same path value under same tag?

7,074 views
Skip to first unread message

void

unread,
Oct 26, 2014, 8:50:17 AM10/26/14
to swagger-sw...@googlegroups.com
I tried to put multiple methods having same path value (e.g /api-comment) under same tag, but swagger 2.0 failed to display these methods. It only displays one method.
e.g
"/api-comment": {
"post": {
"tags": ["Comment"],
"summary": "Add a top level comment",
"description": "call this to add a top level comment",
"operationId": "comment",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{


"in": "query",
"name": "domain",
"description": "value SHOULD BE 'add-new'",
"type": "string",
"required": true,
"default": "add-new"
}, {


"in": "query",
"name": "wuid",
"description": "enter the wuid of widget",
"type": "string",
"required": true
}, {


"in": "formData",
"name": "body",
"description": "enter the comment",
"type": "string",
"required": true
}
],
"responses": {
"200": {
"description": "'Ok', Life is good"
},
"404": {
"description": "'Not Found', File Not Found"
},
"500": {
"description": "'Error', Internal Error"
}
}
}
},
"/api-comment": {
"post": {
"tags": ["Comment"],
"summary": "Add a top level comment with attachment",
"description": "call this to add a top level comment with attachment",
"operationId": "commentWithAttachment",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{

"in": "query",
"name": "action",
"type": "string",
"description": "value SHOULD BE 'add-new'",
                        "required": true,
                        "default":"add-new"
}, {
   "in": "query",
   "name": "wuid",
"type": "string",
"description": "enter the wuid",
"required": true
}, {
"in": "formData",
"name": "body",
"type": "string",
"description": "enter the comment",
"required": true
}, {
"in": "formData",
"type": "string",
"description": "Json array",
"name": "attachment",
"required": true
}
],
"responses": {
"200": {
"description": "'Ok', Life is good"
},
"404": {
"description": "'Not Found', File Not Found"
},
"500": {
"description": "'Error', Internal Error"
}
}
}

Ron

unread,
Oct 26, 2014, 9:16:49 AM10/26/14
to swagger-sw...@googlegroups.com
You can't declare the same path more than once. It has nothing to do with the tags.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

void

unread,
Oct 26, 2014, 9:44:11 AM10/26/14
to swagger-sw...@googlegroups.com
yes correct, but the issue is that the swagger ui i'm creating for the a restful webservice have 3-4 same methods but the parameters are different for all these, means they share same path but the arguments supplied are different.
See how it has been implemented in 1.1:
api-docs.json
{
    "apiVersion": "0.2",
    "swaggerVersion": "1.1",
    "apis": [
        {
            "path": "/Authentication",
            "description": "login, logout of the dashboard, ping the server, error codes"
        },
        
{
            "path": "/Comment",
            "description": "User Message APIs"
        },
{
            "path": "/Depricated",
            "description": "depricated apis that noby is using"
        }
    ]
}
 then

Comment.json:

{
    "apiVersion": "0.2",
    "swaggerVersion": "1.1",
    "basePath": "/",
    "apis": [
        {
            "path": "/api-comment",
            "description": "",
            "operations": [
                {
                    "httpMethod": "POST",
                    "responseClass": "String",
                    "summary": "Add a top level comment",
                    "nickname": "add-new",
                    "notes": "",
                    "parameters": [
                        {
                            "allowableValues": {
                                "valueType": "LIST",
                                "values": [
                                    "add-new"
                                ]
                            },
                            "dataType": "string",
                            "description": "",
                            "name": "action",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "String",
                            "description": "wuid",
                            "name": "wuid",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "paramType": "form",
                            "dataType": "String",
                            "description": "",
                            "name": "body",
                            "required": true
                        }
                    ]
                },
                {
                    "httpMethod": "POST",
                    "responseClass": "String",
                    "summary": "Add a top level comment with attachment",
                    "nickname": "add-new",
                    "notes": "",
                    "parameters": [
                        {
                            "allowableValues": {
                                "valueType": "LIST",
                                "values": [
                                    "add-new"
                                ]
                            },
                            "dataType": "string",
                            "description": "",
                            "name": "action",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "String",
                            "description": "wuid",
                            "name": "wuid",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "paramType": "form",
                            "dataType": "String",
                            "description": "",
                            "name": "body",
                            "required": true
                        },
                        {
                            "paramType": "form",
                            "dataType": "String",
                            "description": "Json array",
                            "name": "attachment",
                            "required": true
                        }
                    ]
                },
                {
                    "httpMethod": "POST",
                    "responseClass": "String",
                    "summary": "Add sub comment",
                    "nickname": "add-new",
                    "notes": "",
                    "parameters": [
                        {
                            "allowableValues": {
                                "valueType": "LIST",
                                "values": [
                                    "add-new"
                                ]
                            },
                            "dataType": "string",
                            "description": "",
                            "name": "action",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "String",
                            "description": "wuid",
                            "name": "wuid",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "String",
                            "description": "Parent's muid",
                            "name": "muid",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "paramType": "form",
                            "dataType": "String",
                            "description": "",
                            "name": "body",
                            "required": true
                        }
                    ]
                },
                {
                    "httpMethod": "GET",
                    "responseClass": "String",
                    "summary": "Get comments",
                    "nickname": "get",
                    "notes": "",
                    "parameters": [
                        {
                            "allowableValues": {
                                "valueType": "LIST",
                                "values": [
                                    "get"
                                ]
                            },
                            "dataType": "String",
                            "description": "",
                            "name": "action",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "String",
                            "description": "",
                            "name": "wuid",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "Integer",
                            "description": "",
                            "name": "since",
                            "paramType": "query",
                            "required": false
                        },
                        {
                            "dataType": "Integer",
                            "description": "",
                            "name": "till",
                            "paramType": "query",
                            "required": false
                        },
                        {
                            "dataType": "Integer",
                            "description": "",
                            "name": "limit",
                            "paramType": "query",
                            "required": false
                        }
                    ]
                },
                {
                    "httpMethod": "GET",
                    "responseClass": "String",
                    "summary": "Get comment properties",
                    "nickname": "get-properties",
                    "notes": "",
                    "parameters": [
                        {
                            "allowableValues": {
                                "valueType": "LIST",
                                "values": [
                                    "get-properties"
                                ]
                            },
                            "dataType": "String",
                            "description": "",
                            "name": "action",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "String",
                            "description": "",
                            "name": "wuid",
                            "paramType": "query",
                            "required": true
                        }
                    ]
                },
                {
                    "httpMethod": "POST",
                    "responseClass": "String",
                    "summary": "Set comment properties",
                    "nickname": "set-properties",
                    "notes": "",
                    "parameters": [
                        {
                            "allowableValues": {
                                "valueType": "LIST",
                                "values": [
                                    "set-properties"
                                ]
                            },
                            "dataType": "String",
                            "description": "",
                            "name": "action",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "String",
                            "description": "",
                            "name": "wuid",
                            "paramType": "query",
                            "required": true
                        },
                        {
                            "dataType": "String",
                            "description": "",
                            "name": "properties",
                            "paramType": "form",
                            "required": true
                        }
                    ]
                }
            ]
        }
    ]
}

Hope im clear..

Regards

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron

unread,
Oct 26, 2014, 9:57:32 AM10/26/14
to swagger-sw...@googlegroups.com
It's clear, but it's something that's not supported - not by Swagger 1.2 nor by 2.0.
We do not allow for operation overloading declarations.

For now, a unique operation is a combination of an http method and a path.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

void

unread,
Oct 26, 2014, 2:38:17 PM10/26/14
to swagger-sw...@googlegroups.com
You mentioned swagger 1.2, but this code uses 1.1 specification.
Was operation overloading supported in 1.1? 
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsubscri...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ron

unread,
Oct 26, 2014, 2:39:22 PM10/26/14
to swagger-sw...@googlegroups.com

I can't say as it was before my time, but I would assume it was not officially supported.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Omid amini

unread,
Oct 27, 2014, 11:18:30 AM10/27/14
to swagger-sw...@googlegroups.com
Can you please help with this case: In a rest call different parameters showing depends on users choice of first parameter. For example if I have a api-ping which has three parameters param1 and param2 and param3. param1 is required and choices are "enum":["first","second"] if user chooses "first" then param2 shows and if chooses "second" param3 shows.
note: in swagger 1.1 I was using operations the way  void <mrana...@gmail.com> wrote.

Ron

unread,
Oct 27, 2014, 11:32:00 AM10/27/14
to swagger-sw...@googlegroups.com
You can't technically describe the parameter dependencies. You can describe them all together and explain the dependency in the general documentation of the operation.

I assume that the sample you gave is just a sample because in that specific use case, param1 has no actual meaning, but I can understand the general use case.

You are more than welcome to open an issue on https://github.com/swagger-api/swagger-spec requesting support for it in the future (no guarantees though). Since this is a specification issue, it's important to have as many details as possible to help us analyze and understand the goals here.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.

Omid amini

unread,
Oct 27, 2014, 4:05:43 PM10/27/14
to swagger-sw...@googlegroups.com
yes it is a general use case. In actual api param1 is actions like add, edit or delete. So according to what action user chooses he should pass different params
Reply all
Reply to author
Forward
0 new messages