Bogdanp / molten

A minimal, extensible, fast and productive framework for building HTTP APIs with Python 3.6 and later.

Home Page:https://moltenframework.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A schema's field cannot be of type List[str]

nicolas-leydet opened this issue · comments

What OS are you using?

SLED 12.3

What version of molten are you using?

0.50

What did you do?

Use the following Schema as an handler return annotation

@schema
class SearchResult:
    results: List[str]

What did you expect would happen?

No error

What happened?

File "~/.virtualenvs/matching/lib/python3.7/site-packages/molten/openapi/documents.py", line 239, in generate_openapi_document
    response_schema_name = _generate_schema("response", response_annotation, schemas)
  File "~/.virtualenvs/matching/lib/python3.7/site-packages/molten/openapi/documents.py", line 319, in _generate_schema
    is_optional, field_schema = _generate_field_schema(field, context, schemas)
  File "~/.virtualenvs/matching/lib/python3.7/site-packages/molten/openapi/documents.py", line 345, in _generate_field_schema
    item_schema_name = _generate_schema(context, arguments[0], schemas)
  File "~/.virtualenvs/matching/lib/python3.7/site-packages/molten/openapi/documents.py", line 303, in _generate_schema
    for field in schema._FIELDS.values():  # noqa
AttributeError: 'function' object has no attribute '_FIELDS'

this is not valid if you use anything else than a schema as List argument

Thanks! I'll take a look at this this weekend.

Thanks again for reporting this! I've released a fix in version 0.5.1.