Bug Report Checklist
Description
Generated python code for schema with discriminator doesn't populate discriminator_value_class_map in generated code. The generated code from the minimal example below is missing the discriminator_value_class_map.
Generated code:
class Distribution(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'class_name': 'str',
'list': 'str'
}
attribute_map = {
'class_name': 'class_name',
'list': 'list'
}
discriminator_value_class_map = {
}
When a ListDistribution or GridDistribution is received from the server, it is not deserialized into it's correct class.
openapi-generator version
Built from most recent master 963c002
OpenAPI declaration file content or url
openapi: "3.0.0"
info:
version: 1.0.0
title: Batch Simulator
servers:
- url: /foo/
paths:
/foo/:
get:
summary: Dummy
description: dummy
responses:
'200':
description: dummy
content:
application/json:
schema:
$ref: '#/components/schemas/distribution'
components:
schemas:
distribution:
description: An abstract distribution
type: object
additionalProperties: false
properties:
dummy:
type: string # Without this "Distribution" isn't generatred because "it's a free-form object"
discriminator:
propertyName: class_name
oneOf:
- $ref: '#/components/schemas/list-distribution'
- $ref: '#/components/schemas/grid-distribution'
list-distribution:
description: version 1
type: object
properties:
class_name:
type: string
list:
type: string
required:
- list # This gets applied to distribution, when it should only be applied to list-distribution
grid-distribution:
description: version 2
properties:
class_name:
type: string
Command line used for generation
java -jar ~/Repos/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g python -i test.yaml -o test_client
Steps to reproduce
- Build from most recent master (or grab appropriate snapshot)
- Run CLI generator on the provided minimal example
- Inspect
openapi_client.models.distribution and look at the value of discriminator_value_class_map.
Related issues/PRs
#1662
Suggest a fix
I think the lines in this example should be:
discriminator_value_class_map = {
'GridDistribution': 'GridDistribution'
'ListDistribution': 'ListDistribution'
}
I'm happy to do some work to try to fix this, but would need to be pointed in the right direction.
Bug Report Checklist
Description
Generated python code for schema with discriminator doesn't populate
discriminator_value_class_mapin generated code. The generated code from the minimal example below is missing thediscriminator_value_class_map.Generated code:
When a
ListDistributionorGridDistributionis received from the server, it is not deserialized into it's correct class.openapi-generator version
Built from most recent master 963c002
OpenAPI declaration file content or url
Command line used for generation
java -jar ~/Repos/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g python -i test.yaml -o test_clientSteps to reproduce
openapi_client.models.distributionand look at the value ofdiscriminator_value_class_map.Related issues/PRs
#1662
Suggest a fix
I think the lines in this example should be:
I'm happy to do some work to try to fix this, but would need to be pointed in the right direction.