Describe the bug
error when generating citation-style-language/schema
To Reproduce
Example schema:
https://raw.githubusercontent.com/citation-style-language/schema/v1.0.1/csl-data.json
Used commandline:
โฏ datamodel-codegen --input ~/Documents/csl-data.json --output model.py
Traceback (most recent call last):
File "/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/datamodel_code_generator/__main__.py", line 258, in main
generate(
File "/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/datamodel_code_generator/__init__.py", line 213, in generate
results = parser.parse()
File "/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/datamodel_code_generator/parser/base.py", line 253, in parse
self.parse_raw()
File "/usr/local/Caskroom/miniconda/base/lib/python3.8/site-packages/datamodel_code_generator/parser/jsonschema.py", line 834, in parse_raw
root_obj = JsonSchemaObject.parse_obj(self.raw_obj)
File "pydantic/main.py", line 515, in pydantic.main.BaseModel.parse_obj
File "pydantic/main.py", line 362, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 10 validation errors for JsonSchemaObject
items
value is not a valid list (type=type_error.list)
items -> properties -> type -> required
value is not a valid list (type=type_error.list)
items -> properties -> id -> required
value is not a valid list (type=type_error.list)
items -> properties -> author -> items
value is not a valid list (type=type_error.list)
items -> properties -> author -> items -> type
str type expected (type=type_error.str)
items -> properties -> author -> items -> type -> 0
str type expected (type=type_error.str)
items -> properties -> author -> items -> type -> 1
str type expected (type=type_error.str)
items -> properties -> accessed -> type
str type expected (type=type_error.str)
items -> properties -> accessed -> type -> 0
str type expected (type=type_error.str)
items -> properties -> accessed -> type -> 1
str type expected (type=type_error.str)
Expected behavior
no exceptions reported.
Version:
Additional context
Add any other context about the problem here.
Thank you for creating this issue.
I have reproduced the problem. I will fix it.
@elonzh
I have checked the schema.
I think this schema is invalid.
type: [{...}] is not valid. I guess items: [{...}] is correct. "author": {
"type": "array",
"items": {
"id": "name-variable",
"type": [
{
"properties": {
"family" : {
"type": "string"
"description": "JSON schema (draft 3) for CSL input data"
Also, this schema version may be draft 3 . but, I didn't check about the version.
The schema is valid with the draft 3 version, maybe we need to document the minimum supported version.
You can validate the schema at https://www.jsonschemavalidator.net/.
Still, I will report this issue to the CSL project.
I agree. I add the minimum supported version in the document.