OpenAPITools / OpenAPITools/openapi-generator
[BUG] python-flask controller test uses true instead of True
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Boolean values get parsed badly in flask.
openapi: 3.0.0
info:
title: Bar
description: Foo
version: 0.1.0
paths:
/foo:
post:
summary: Bar
description: desc
requestBody:
description: Optional description in *Markdown*
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ScenarioParameters'
responses:
'200': # status code
description: A JSON object containing the result data
content:
application/json:
schema:
type: string
components:
schemas:
ScenarioParameters:
type: object
properties:
foo:
type: boolean
leads to
class TestDefaultController(BaseTestCase):
"""DefaultController integration test stubs"""
def test_foo_post(self):
"""Test case for foo_post
Bar
"""
scenario_parameters = {
"foo" : true
}
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
response = self.client.open(
'/foo',
method='POST',
headers=headers,
data=json.dumps(scenario_parameters),
content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
in the test_default_controller.py. Note the true instead of True
I believe a fix is to wrap this line the {{{example}}} which is a JSON document into a
"""
{{{example}}}
"""
multi line python string and then set data=json.dumps(...) to the value directly
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 with modules/openapi-generator/src/main/resources/python-flask/controller_test.mustache around the linked line, then compare its output with the generated test_default_controller.py shown in the issue. Regenerate a Python Flask controller test and verify that the boolean example is valid Python and the resulting test runs successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100