swagger-api / swagger-api/swagger-codegen
[Python] spec 1.2 resourcePath breaks class filenames
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
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 bedefault_api.py. - Remove the
"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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided bareminimum.json and the swagger-codegen generate command using the python language target. Trace how the Swagger 1.2 resourcePath value affects the generated API filename, comparing output with and without that field. Done means the example generates default_api.py or reports a clear error instead of creating _api.py.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100