From f525954a4f854a5b373ea60cc1e9db7e50fe3a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Sat, 17 Feb 2024 19:10:58 +0000 Subject: [PATCH] [python] add inheritance discriminators test #16808 --- ...ore-with-fake-endpoints-models-for-testing.yaml | 14 ++++++++++++++ .../client/petstore/python/tests/test_model.py | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml index b77ff51d4bae..e0f1475ea83d 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1640,6 +1640,20 @@ components: required: - id - activity + DiscriminatorAllOfSuper: + type: object + required: + - elementType + discriminator: + propertyName: elementType + properties: + elementType: + type: string + DiscriminatorAllOfSub: + allOf: + - $ref: '#/components/schemas/DiscriminatorAllOfSuper' + - type: object + properties: {} Pet: type: object required: diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index e67ae8fb6538..7e284d7b19b6 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -342,6 +342,11 @@ def test_inheritance(self): self.assertEqual(dog2.breed, 'bulldog') self.assertEqual(dog2.class_name, "dog") self.assertEqual(dog2.color, 'white') + + def test_inheritance_discriminators(self): + petstore_api.DiscriminatorAllOfSuper.from_dict({"className": "dog", "color": "white", "breed": "bulldog"}) + + def test_list(self): # should throw exception as var_123_list should be string