json-schema-codegen
json-schema-codegen copied to clipboard
additionalProperties with $ref errs
schema.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/nerevu/rorschach/master/app/schemas/provider.schema.json",
"title": "Provider",
"description": "A 3rd party API provider",
"type": "object",
"additionalProperties": false,
"properties": {
"authentication": {
"description": "Authentication methods exposed by the API",
"type": "object",
"default": {},
"additionalProperties": {
"$ref": "https://raw.githubusercontent.com/nerevu/rorschach/master/app/schemas/auth.schema.json"
}
}
},
"required": [
"authentication"
]
}
$ json_codegen --language python3 --output provider.py schema.json
Traceback (most recent call last):
File "/Users/reubano/.virtualenvs/authorizer/bin/json_codegen", line 8, in <module>
sys.exit(main())
File "/Users/reubano/.virtualenvs/authorizer/lib/python3.9/site-packages/json_codegen/cli.py", line 68, in main
code = generator(schema, prefix=args.prefix).generate().as_code()
File "/Users/reubano/.virtualenvs/authorizer/lib/python3.9/site-packages/json_codegen/generators/python3.py", line 32, in generate
self._body.append(self.make_klass(root_definition))
File "/Users/reubano/.virtualenvs/authorizer/lib/python3.9/site-packages/json_codegen/generators/python3.py", line 58, in make_klass
class_body.append(self.make_klass_constructor(properties, required))
File "/Users/reubano/.virtualenvs/authorizer/lib/python3.9/site-packages/json_codegen/generators/python3.py", line 342, in make_klass_constructor
annotation = self.get_annotation_from_definition(property_, is_required=is_required)
File "/Users/reubano/.virtualenvs/authorizer/lib/python3.9/site-packages/json_codegen/generators/python3.py", line 309, in get_annotation_from_definition
annotation = self.get_partial_annotation_from_definition(property_)
File "/Users/reubano/.virtualenvs/authorizer/lib/python3.9/site-packages/json_codegen/generators/python3.py", line 268, in get_partial_annotation_from_definition
object_name = self.definitions[property_["additionalProperties"]["$ref"]]["title"]
KeyError: 'https://raw.githubusercontent.com/nerevu/rorschach/master/app/schemas/auth.schema.json'
json-schema-codegen v0.4.5 python 3.9 macOS 12.0.1
I am having the same issue with a reference to a local file. The generated code is empty just import statements. Any updates on this?