Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing support for prefixItems #118

Open
dionhaefner opened this issue Jun 7, 2024 · 1 comment
Open

Missing support for prefixItems #118

dionhaefner opened this issue Jun 7, 2024 · 1 comment

Comments

@dionhaefner
Copy link

Reproducer:

from typing import Tuple
import pydantic
import jsf

class MyModel(pydantic.BaseModel):
    some_attr: Tuple[int, int]

schema = MyModel.model_json_schema()
print(schema)
faker = jsf.JSF(schema)
print(faker.generate())

Output:

{'properties': {'some_attr': {'maxItems': 2, 'minItems': 2, 'prefixItems': [{'type': 'integer'}, {'type': 'integer'}], 'title': 'Some Attr', 'type': 'array'}}, 'required': ['some_attr'], 'title': 'MyModel', 'type': 'object'}
Traceback (most recent call last):
  File "/Users/dion/.virtualenvs/science/lib/python3.10/site-packages/jsf/schema_types/object.py", line 45, in generate
    return super().generate(context)
  File "/Users/dion/.virtualenvs/science/lib/python3.10/site-packages/jsf/schema_types/base.py", line 66, in generate
    raise ProviderNotSetException()
jsf.schema_types.base.ProviderNotSetException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dion/codes/tesseract/jsf_bug.py", line 12, in <module>
    print(faker.generate())
  File "/Users/dion/.virtualenvs/science/lib/python3.10/site-packages/jsf/parser.py", line 355, in generate
    return self.root.generate(context=context)
  File "/Users/dion/.virtualenvs/science/lib/python3.10/site-packages/jsf/schema_types/object.py", line 47, in generate
    explicit_properties = {
  File "/Users/dion/.virtualenvs/science/lib/python3.10/site-packages/jsf/schema_types/object.py", line 50, in <dictcomp>
    if self.should_keep(o.name, context)
AttributeError: 'NoneType' object has no attribute 'name'
@dionhaefner
Copy link
Author

Actually, this is triggered whenever an array is encountered that doesn't have a defined type via items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant