swagger-api / swagger-api/swagger-codegen
[PYTHON] Can the Swagger Client SDK generate code along with examples (Request Body for POST API Call)?
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
[PYTHON] Can the Swagger Client SDK generate code along with examples (Request Body for POST API Call)?
Description
Currently, the generated Client SDK will not include examples in the code; however, if examples can be exported into the code, they may be useful for reference when creating POST API calls, which reduces the manual efforts and makes it easier for the engineers during the development and troubleshooting to use the generated Client SDK effectively.
Swagger-codegen version
home@swapnil-mac ~ % swagger-codegen version
3.0.34
Command line used for generation
swagger-codegen generate -i /path/specs.yaml -l python
Steps to reproduce
To reproduce, you can use any sample YAML or JSON file that has examples and see if those examples get exported into the code base.
Related issues/PRs
I don't see any open issues with this change or enhancement.
Suggest a fix/enhancement
I believe it will be beneficial for the engineers during development and troubleshooting to be able to use the newly created client SDK efficiently if we can incorporate examples into the code base once we export the client SDK. To ensure that existing functionality is not impacted, I was considering creating SDK client code with commented examples. Hopefully, this would be a useful enhancement.
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 running swagger-codegen generate -i /path/specs.yaml -l python against a YAML or JSON specification containing request-body examples, then inspect the generated Python SDK. Done means the generated code includes useful commented examples for POST request bodies without affecting existing functionality.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100