Description
For a swagger 1.2 spec file, if the element resourcePath exists, swagger-codegen does not properly create api class files.
Swagger-codegen version
[x] 2.2.2
Swagger declaration file content or url
{
"apiVersion": "0.1",
"apis": [
{
"description": "Testing auth.",
"operations": [
{
"method": "get",
"nickname": "authtest_get",
"notes": null,
"parameters": [],
"summary": "Get auth.",
"type": "object"
}
],
"path": "/authtest"
}
],
"description": "anything",
"resourcePath": "/",
"swaggerVersion": "1.2",
"x-api-prefix": "/api/v1"
}
Command line used for generation
swagger-codegen generate -i bareminimum.json -l python -o bm1
Steps to reproduce
- Create a file bareminimum.json as shown.
- Run the swagger-codegen command.
- The
bm1/swagger_client/apis/ directory will have a file called _api.py. This file should be default_api.py.
- Remove the
"resourcePath": "/", from the json and re-run the command. bm1/swagger_client/apis/default_api.py will be generated.
There is no difference in logging output, no additional errors produced when resourcePath is present.
Suggest a Fix
I am new to swagger, and I'm using flask-restful-swagger to generate documentation from our flask application. This module only produces spec 1.2 files, though they are working on a 2.0 version. I have no option to control what gets placed in resourcePath other than to modify their code. If this is a bug with their module, I can open an issue with them.
I don't know how many people are using swagger-codegen with 1.2 spec files (I see resourcePath goes away in 2.0), but for those users, either catching this error and correcting it to generate the correct files, or failing with an obvious error message would be a suggested fix.
Description
For a swagger 1.2 spec file, if the element resourcePath exists, swagger-codegen does not properly create api class files.
Swagger-codegen version
[x] 2.2.2
Swagger declaration file content or url
{ "apiVersion": "0.1", "apis": [ { "description": "Testing auth.", "operations": [ { "method": "get", "nickname": "authtest_get", "notes": null, "parameters": [], "summary": "Get auth.", "type": "object" } ], "path": "/authtest" } ], "description": "anything", "resourcePath": "/", "swaggerVersion": "1.2", "x-api-prefix": "/api/v1" }Command line used for generation
swagger-codegen generate -i bareminimum.json -l python -o bm1Steps to reproduce
bm1/swagger_client/apis/directory will have a file called_api.py. This file should bedefault_api.py."resourcePath": "/",from the json and re-run the command.bm1/swagger_client/apis/default_api.pywill be generated.There is no difference in logging output, no additional errors produced when resourcePath is present.
Suggest a Fix
I am new to swagger, and I'm using flask-restful-swagger to generate documentation from our flask application. This module only produces spec 1.2 files, though they are working on a 2.0 version. I have no option to control what gets placed in resourcePath other than to modify their code. If this is a bug with their module, I can open an issue with them.
I don't know how many people are using swagger-codegen with 1.2 spec files (I see resourcePath goes away in 2.0), but for those users, either catching this error and correcting it to generate the correct files, or failing with an obvious error message would be a suggested fix.