Skip to content

Wrong data type generated #362

Closed
Closed
@Kludex

Description

@Kludex

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] = UNSET

There 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

No one assigned

    Labels

    🐞bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions