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

Handle Models where Config.extra is not set #9

Open
joe0BAB opened this issue May 11, 2021 · 0 comments
Open

Handle Models where Config.extra is not set #9

joe0BAB opened this issue May 11, 2021 · 0 comments

Comments

@joe0BAB
Copy link

joe0BAB commented May 11, 2021

Hi! First of all, many thanks for providing this useful tool!

I'm trying to get it running, but there are two issues I'm stuck with.

First is the same as #5

The second, when I pass the path of a python file directly I get:
`$pydantic2ts --module ./api/apps/folder/models.py --output test.ts --json2ts-cmd ./ui/node_modules/.bin/json2ts
2021-05-11 15:47:53,683 Finding pydantic models...
2021-05-11 15:47:53,688 Generating JSON schema from pydantic models...
Traceback (most recent call last):
File ".../venv/bin/pydantic2ts", line 8, in
sys.exit(main())
File ".../venv/lib/python3.8/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File ".../venv/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File ".../venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File ".../venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File ".../venv/lib/python3.8/site-packages/pydantic2ts/cli/script.py", line 222, in main
return generate_typescript_defs(module, output, json2ts_cmd)
File ".../venv/lib/python3.8/site-packages/pydantic2ts/cli/script.py", line 187, in generate_typescript_defs
schema = generate_json_schema(models)
File ".../venv/lib/python3.8/site-packages/pydantic2ts/cli/script.py", line 144, in generate_json_schema
model_extras = [m.Config.extra for m in models]
File ".../venv/lib/python3.8/site-packages/pydantic2ts/cli/script.py", line 144, in
model_extras = [m.Config.extra for m in models]

AttributeError: type object 'Config' has no attribute 'extra'
`
If I understand the docs correctly, the Config.extra field is optional.
However, right now pydantic-to-typescript does not handle this case.

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