Manweill / swagger-axios-codegen

swagger client to use axios and typescript
MIT License
306 stars 83 forks source link

Parameters not working #101

Closed axebelk closed 3 years ago

axebelk commented 4 years ago

Hello,

Parameters not working from url for example: "parameters": [{"name": "city_id", "in": "path", "required": true, "type": "int"}]}

Thanks

Manweill commented 4 years ago

Can you describe in detail

axebelk commented 4 years ago

In my Django app, I have dynamic URLs for example /city// and this is not working well with your library.

Manweill commented 4 years ago

Can you provide swagger spec and the generated code about this error

axebelk commented 4 years ago

Here is the swagger.json file content, You can try with this. I can't post the generated code as I switched to some other tools. The issue is /enquiries/{id}/ look at the dynamic {id} -> your generated code should allow to send this ID.


{
   "swagger":"2.0",
   "info":{
      "title":"Demo Api Documentation",
      "description":"Demo",
      "version":"v1"
   },
   "host":"127.0.0.1:8000",
   "schemes":[
      "http"
   ],
   "basePath":"/",
   "consumes":[
      "application/json"
   ],
   "produces":[
      "application/json"
   ],
   "securityDefinitions":{
      "basic":{
         "type":"apiKey",
         "name":"Authorization",
         "in":"header"
      }
   },
   "security":[
      {
         "basic":[

         ]
      }
   ],
   "paths":{
      "/enquiries/":{
         "get":{
            "operationId":"enquiries_list",
            "description":"",
            "parameters":[
               {
                  "name":"search",
                  "in":"query",
                  "description":"A search term.",
                  "required":false,
                  "type":"string"
               },
               {
                  "name":"page",
                  "in":"query",
                  "description":"A page number within the paginated result set.",
                  "required":false,
                  "type":"integer"
               }
            ],
            "responses":{
               "200":{
                  "description":"",
                  "schema":{
                     "required":[
                        "count",
                        "results"
                     ],
                     "type":"object",
                     "properties":{
                        "count":{
                           "type":"integer"
                        },
                        "next":{
                           "type":"string",
                           "format":"uri",
                           "x-nullable":true
                        },
                        "previous":{
                           "type":"string",
                           "format":"uri",
                           "x-nullable":true
                        },
                        "results":{
                           "type":"array",
                           "items":{
                              "$ref":"#/definitions/Enquiry"
                           }
                        }
                     }
                  }
               }
            },
            "tags":[
               "enquiries"
            ]
         },
         "parameters":[

         ]
      },
      "/enquiries/{id}/":{
         "get":{
            "operationId":"enquiries_read",
            "description":"",
            "parameters":[

            ],
            "responses":{
               "200":{
                  "description":"",
                  "schema":{
                     "$ref":"#/definitions/Enquiry"
                  }
               }
            },
            "tags":[
               "enquiries"
            ]
         },
         "parameters":[
            {
               "name":"id",
               "in":"path",
               "description":"A unique integer value identifying this enquiries.",
               "required":true,
               "type":"integer"
            }
         ]
      }
   },
   "definitions":{
      "Enquiry":{
         "type":"object",
         "properties":{
            "id":{
               "title":"ID",
               "type":"integer",
               "readOnly":true
            },
            "name":{
               "title":"Name",
               "type":"string",
               "x-nullable":true
            },
            "email":{
               "title":"Email",
               "type":"string",
               "x-nullable":true
            },
            "address":{
               "title":"Address",
               "type":"string",
               "x-nullable":true
            },
            "created_at":{
               "title":"Created at",
               "type":"string",
               "format":"date-time",
               "x-nullable":true
            },
         }
      }
   }
}
Manweill commented 4 years ago

@axebelk in your spec, the /enquiries/{id}/ request dose not definition id in params

Manweill commented 4 years ago

you can see in example