forked from loafle/openapi-generator-original
Update model_generic.mustache, tuple notation breaks when there is only one element in the tuple (#17749)
* Update model_generic.mustache, tuple notation breaks when there is only one element in the tuple
In this excerpt of the mustache template, the matching behaviour is bugged when there is only one element in the tuple notation. A single string with the tuple notation, e.g., `("string")`, will result in a string, and when values are compared with the string, it will do a `contains` match instead of an exact match, which is unintended behaviour.
* Update with samples, step 3
* Add test spec and regenerate samples
* Update samples
* Update spec and samples
* update samples
---------
Co-authored-by: Edmund Loo <edmundloo@users.noreply.github.com>
Co-authored-by: Edmund Loo <github.yn0u9@simplelogin.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.bathing import Bathing
|
||||
|
||||
class TestBathing(unittest.TestCase):
|
||||
"""Bathing unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> Bathing:
|
||||
"""Test Bathing
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `Bathing`
|
||||
"""
|
||||
model = Bathing()
|
||||
if include_optional:
|
||||
return Bathing(
|
||||
task_name = 'cleaning_deep',
|
||||
function_name = 'care_nourish',
|
||||
content = ''
|
||||
)
|
||||
else:
|
||||
return Bathing(
|
||||
task_name = 'cleaning_deep',
|
||||
function_name = 'care_nourish',
|
||||
content = '',
|
||||
)
|
||||
"""
|
||||
|
||||
def testBathing(self):
|
||||
"""Test Bathing"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,57 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.feeding import Feeding
|
||||
|
||||
class TestFeeding(unittest.TestCase):
|
||||
"""Feeding unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> Feeding:
|
||||
"""Test Feeding
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `Feeding`
|
||||
"""
|
||||
model = Feeding()
|
||||
if include_optional:
|
||||
return Feeding(
|
||||
task_name = 'cleaning',
|
||||
function_name = 'care_nourish',
|
||||
content = ''
|
||||
)
|
||||
else:
|
||||
return Feeding(
|
||||
task_name = 'cleaning',
|
||||
function_name = 'care_nourish',
|
||||
content = '',
|
||||
)
|
||||
"""
|
||||
|
||||
def testFeeding(self):
|
||||
"""Test Feeding"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,57 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.poop_cleaning import PoopCleaning
|
||||
|
||||
class TestPoopCleaning(unittest.TestCase):
|
||||
"""PoopCleaning unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> PoopCleaning:
|
||||
"""Test PoopCleaning
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `PoopCleaning`
|
||||
"""
|
||||
model = PoopCleaning()
|
||||
if include_optional:
|
||||
return PoopCleaning(
|
||||
task_name = 'cleaning',
|
||||
function_name = 'care',
|
||||
content = ''
|
||||
)
|
||||
else:
|
||||
return PoopCleaning(
|
||||
task_name = 'cleaning',
|
||||
function_name = 'care',
|
||||
content = '',
|
||||
)
|
||||
"""
|
||||
|
||||
def testPoopCleaning(self):
|
||||
"""Test PoopCleaning"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,55 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.task import Task
|
||||
|
||||
class TestTask(unittest.TestCase):
|
||||
"""Task unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> Task:
|
||||
"""Test Task
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `Task`
|
||||
"""
|
||||
model = Task()
|
||||
if include_optional:
|
||||
return Task(
|
||||
id = '',
|
||||
activity = None
|
||||
)
|
||||
else:
|
||||
return Task(
|
||||
id = '',
|
||||
activity = None,
|
||||
)
|
||||
"""
|
||||
|
||||
def testTask(self):
|
||||
"""Test Task"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,57 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
|
||||
from petstore_api.models.task_activity import TaskActivity
|
||||
|
||||
class TestTaskActivity(unittest.TestCase):
|
||||
"""TaskActivity unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def make_instance(self, include_optional) -> TaskActivity:
|
||||
"""Test TaskActivity
|
||||
include_option is a boolean, when False only required
|
||||
params are included, when True both required and
|
||||
optional params are included """
|
||||
# uncomment below to create an instance of `TaskActivity`
|
||||
"""
|
||||
model = TaskActivity()
|
||||
if include_optional:
|
||||
return TaskActivity(
|
||||
task_name = 'cleaning_deep',
|
||||
function_name = 'care_nourish',
|
||||
content = ''
|
||||
)
|
||||
else:
|
||||
return TaskActivity(
|
||||
task_name = 'cleaning_deep',
|
||||
function_name = 'care_nourish',
|
||||
content = '',
|
||||
)
|
||||
"""
|
||||
|
||||
def testTaskActivity(self):
|
||||
"""Test TaskActivity"""
|
||||
# inst_req_only = self.make_instance(include_optional=False)
|
||||
# inst_req_and_optional = self.make_instance(include_optional=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user