Repository navigation
Closed
Labels
🐞bugSomething isn't workingSomething isn't working
Description
Describe the bug
The wrong data type is generated on the client.
To Reproduce
I have this model:
{
"SearchQuery":{
"title":"SearchQuery",
"type":"object",
"properties":{
"folder_ids":{
"title":"Folder Ids",
"type":"array",
"items":{
"type":"integer"
}
},
"filters":{
"title":"Filters",
"type":"object",
"additionalProperties":{
"$ref":"#/components/schemas/SearchFilter"
},
"default":{
}
},
"keywords":{
"title":"Keywords",
"type":"array",
"items":{
"type":"string"
},
"default":[
]
},
"keyword_op":{
"allOf":[
{
"$ref":"#/components/schemas/KeywordOperator"
}
],
"default":"and"
},
"file_ids":{
"title":"File Ids",
"type":"array",
"items":{
"type":"integer"
}
},
"query":{
"title":"Query",
"type":"string"
},
"keywords_only_query":{
"title":"Keywords Only Query",
"type":"boolean",
"default":false
}
},
"description":"Schema for string query search queries."
}On the client, this is generated:
class SearchQuery:
""" Schema for string query search queries. """
folder_ids: Union[Unset, List[int]] = UNSET
filters: Union[SearchQueryFilters, Unset] = UNSET
keywords: Union[Unset, List[str]] = UNSET
keyword_op: Union[Unset, None] = UNSET
file_ids: Union[Unset, List[int]] = UNSET
query: Union[Unset, str] = UNSET
keywords_only_query: Union[Unset, bool] = False
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)On FastAPI that's an (str, Enum), fwiw 🤔
Expected behavior
Well, it should be this:
keyword_op: Union[Unset, str] = UNSETThere are follow up problems, but I believe it starts here.
OpenAPI Spec File
openapi.json.txt
Desktop (please complete the following information):
- OS: Ubuntu 20.04
- Python Version: 3.8.5
- openapi-python-client version: 0.8.0
Metadata
Metadata
Assignees
Labels
🐞bugSomething isn't workingSomething isn't working
Activity
dbanty commentedon Mar 26, 2021
Hey @Kludex 👋. Trouble is actually that
allOfsupport is on main but not released yet, so the generator doesn't know what type that property is. I'm not positive that the first round ofallOfsupported anything other than objects though, can you give it a try with what's currently on main and see what it does?If my suspicions are correct, what we need to do is add support for non-object types in allOf.
dbanty commentedon Mar 27, 2021
Actually I think #361 might solve this issue. It makes it so a single allOf will just pass through rather than attempting to generate a new type. I'll try this once that gets merged to confirm.
dbanty commentedon Dec 16, 2021
Just doing a loop looking at older bugs, looks like this was fixed in 0.9.0. I tried generating with the spec and
keyword_opsnow correctly contains aUnion[Unset, KeywordOperator]which I think is correct, so I'm gonna close this issue.