Can't define "type" in JSON
kacperpaczos opened this issue · 4 comments
Describe the bug
I need:
"repository": {
"type": "object",
"properties": {
"url": { "type": "string", "default": "https://example.com/your-username/my-new-project" },
"type": { "type": "string", "default": "git" }
}
},
Like:
{
"name": "my-new-project",
"version": "1.0.0",
"description": "My New Project description.",
"main": "index.js",
"repository": {
"url": "https://example.com/your-username/my-new-project",
"type": "git"
},
"author": "Your Name <you@example.com>",
"license": "MIT"
}
But i have an error:
raise error
jsonschema.exceptions.ValidationError: {'type': 'string'} is not valid under any of the given schemas
Failed validating 'anyOf' in schema['properties']['type']:
{'anyOf': [{'$ref': '#/definitions/simpleTypes'},
{'items': {'$ref': '#/definitions/simpleTypes'},
'minItems': 1,
'type': 'array',
'uniqueItems': True}]}
On instance['type']:
{'type': 'string'}
The library expects the syntax of this to be the following:
{
...
"type": "string",
"default": "git",
...
. Can you point to a reference showing that "type": {"type": "string", "default": "git"}
is valid syntax?
Can you point to a reference showing that "type": {"type": "string", "default": "git"} is valid syntax?
I need the key name 'type' in the properties. How can I achieve this?
Okay, I took your example and made a test out of it, and it works fine. See the example in the changes at https://github.com/cwacek/python-jsonschema-objects/pull/277/files.
Can you provide a specific example that doesn't work? Everything seems fine to me?
This issue exist in this project:
https://github.com/kacperpaczos/Bennet
You need change vcs to type name in anvil_base_schema.json file:
"repository": {
"title": "repository",
"type": "object",
"properties": {
"url": { "type": "string", "default": "https://example.com/your-username/my-new-project" },
"vcs": { "type": "string", "default": "git" }
}
},