joolfe / postman-to-openapi

🛸 Convert postman collection to OpenAPI
MIT License
577 stars 99 forks source link

postman to openapi partial conversion success, lose a lot of item #229

Closed hellorayza closed 1 year ago

hellorayza commented 1 year ago

Similar question #215 . I exported a collection which several object in the item. However, after execute below command only one get request and one post request in result file(yml or json). I guess the reason is that the same path. I‘m not sure this form of request weather it will cause problems, but it works well in postman.

p2o D:\\data\\app.postman_collection.json -f D:\\data\\result.json -o D:\\data\\options.json

options.json

{
   "outputFormat":"json"
}

app.postman_collection.json

{
    "info": {
        "_postman_id": "id_serial",
        "name": "appName",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "item": [
            {
            "name": "request1",
            "request": {
                "method": "GET",
                "header": [],
                "url": {
                    "raw": "http://www.demo.com/api/index.php?m=gate_data_r_list&login_user_name=tom&name=&token=xx",
                    "host": [
                        "192",
                        "168",
                        "0",
                        "1"
                    ],
                    "port": "8080",
                    "path": [
                        "api",
                        "index.php"
                    ],
                    "query": [
                        {
                            "key": "m",
                            "value": "gate_data_r_list"
                        },
                        {
                            "key": "login_user_name",
                            "value": "tom"
                        },
                        {
                            "key": "name",
                            "value": ""
                        },
                        {
                            "key": "token",
                            "value": "xx"
                        }
                    ]
                }
            },
            "response": []
        },
        {
            "name": "request2",
            "request": {
                "method": "GET",
                "header": [],
                "url": {
                    "raw": "http://www.demo.com/api/index.php?m=wsc_wscljc&login_user_name=tom&name=&token=xx",
                    "host": [
                        "192",
                        "168",
                        "0",
                        "1"
                    ],
                    "port": "8080",
                    "path": [
                        "api",
                        "index.php"
                    ],
                    "query": [
                        {
                            "key": "m",
                            "value": "wsc_wscljc"
                        },
                        {
                            "key": "login_user_name",
                            "value": "tom"
                        },
                        {
                            "key": "name",
                            "value": ""
                        },
                        {
                            "key": "token",
                            "value": "xx"
                        }
                    ]
                }
            },
            "response": []
        }
    ]
}

result.json

{

    "paths": {
        "/": {
            "get": {
                "tags": [
                    "default"
                ],
                "summary": "request1",
                "parameters": [
                    {
                        "name": "m",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "example": "wsc_wscljc"
                    },
                    {
                        "name": "login_user_name",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "example": "tom"
                    },
                    {
                        "name": "name",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "token",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        },
                        "example": "xx"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {}
                        }
                    }
                }
            }
        }
    }
}
joolfe commented 1 year ago

Hi @hellorayza,

Yes that's because both requests have the same path, in OpenAPI you document/describe Restful API operations and don´t have sense to describe two times the same path, a path + verb should be an operation in your API so in your documentation you only describe once...

Best Regards.