Description
Description
in java:
class Tag{
Map<String, Object> attributes;
}
to openapi spec:
{"attributes": { "type": "object",
"additionalProperties": {
"type": "object"
} }
after generated python client, most of the types can't handle
openapi-generator version
6.6.0
OpenAPI declaration file content or url
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost:8059",
"description": "Generated server url"
}
],
"paths": {},
"components": {
"schemas": {
"Tag": {
"type": "object",
"properties": {
"attributes": {
"type": "object",
"additionalProperties": {
"type": "object"
}
}
}
}
}
}
}
Generation Details
java -jar ./openapi-generator-cli.jar generate -i ./nrpservice/nrp/lop/bcommon/openapi.json -g python-nextgen -o ./nrpservice/nrp/pylop1
openapi.json is exactly the content i have pasted above.
Steps to reproduce
import unittest
from openapi_client.models.tag import Tag
class MyTestCase(unittest.TestCase):
def test_tag(self):
tag = Tag();
print(Tag.to_json(tag))
json = '{"attributes":{"height":1}}'
tag1 = Tag.from_json(json)
print("data_class_instance=", tag1)
if name == "main":
unittest.main()
above case will fail by reporting:
File "pydantic/main.py", line 526, in pydantic.main.BaseModel.parse_obj
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for Tag
attributes -> height
value is not a valid dict (type=type_error.dict)