OpenAPITools / OpenAPITools/openapi-generator
[BUG] Generated Python unit tests hard code 200 response for POST actions
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Using OpenAPI3 to generate our Python based service. We are attempting to use HTTP response code 201 for POST operations. However, the OpenAPI generated unit tests hard code expect a 200 response. So, the unit test fails. See https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/python-flask/controller_test.mustache#L50.
OpenAPI generated Unit Tests should not hardcode 200 response values. Generated unit tests should either look for the response values defined in the OpenAPI document.
openapi-generator version
4.0.0-SNAPSHOT
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 at modules/openapi-generator/src/main/resources/python-flask/controller_test.mustache around line 50 and inspect how the expected POST response is selected. Compare the generated test with the response codes defined in the OpenAPI document. Done means generated Python unit tests no longer assume 200 when the operation defines another response code, with the relevant tests passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- api, testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100