OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Bug that makes it impossible to use discriminated types consistently
Generate a type with an anyof with a discriminator
Use that type in a api call
See that the api call isn't properly done, because its None
@validate_parameters
def my_generated_api_call(x: MyGeneratedType):
print(x.input) # not properly serialized so is None, but should have been a TimeSeriesType
my_generated_api_call(x={
"input": { # < = Anyof [timeseries, audio etc]
"inputType": "time-series",
"frequencyHz": 100,
"windowLengthMs": 330,
},
}
})
# 1 `MyGeneratedType.from_dict({ dict here })` works.
# 2. But using `MyGeneratedType.parse_obj({ dict_here })` doesn't work.
# 3. `MyGeneratedType(**{ k:v})` doesn't work either
Probable cause
I've tracked it down to the way this is implemented in openapi generator:
MyGeneratedType.from_dict({ dict here }) works.
But using MyGeneratedType.parse_obj({ dict_here }) doesn't work.
MyGeneratedType(**{ k:v}) doesn't work either
Because the openapi calls are done via @validate_arguments decorater which under the hood also uses one of those 2,3, those types aren't properly serialized.
Description
Bug that makes it impossible to use discriminated types consistently
anyof
with a discriminatorNone
Probable cause
I've tracked it down to the way this is implemented in openapi generator:
MyGeneratedType.from_dict({ dict here })
works.MyGeneratedType.parse_obj({ dict_here })
doesn't work.MyGeneratedType(**{ k:v})
doesn't work eitherBecause the openapi calls are done via
@validate_arguments
decorater which under the hood also uses one of those 2,3, those types aren't properly serialized.openapi-generator version
7.5.5
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix