OpenAPITools / OpenAPITools/openapi-generator

[BUG] Generated Python unit tests hard code 200 response for POST actions

Open
#2,064 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: Python
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.