-
Notifications
You must be signed in to change notification settings - Fork 95
NotImplementedError: anyOf is not supported as bare property #51
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
Comments
@hramasub I'm not likely to fix this in the near future. The problem is that For most uses where you would use
|
@cwacek I ran into this today and started looking at how to patch it in and submit a PR to you, before I found this ticket. I agree it's a pain for reliable serialization. Any ideas since the original note here about how it could be supported, at least with a 'dangerous' flag or something that allowed a 1-way load of it (I know, I don't like how that sounds, but trying to think how to support). |
The only thing I can think that would be reasonable is a flag like: That would not be the default behavior, and obviously wouldn’t actually match the jsonschema semantics, but would allow you to use the library for schemas with this keyword if you understood what it would do. |
Yes, that makes sense. I tried a hack outside the library to monkey-patch my schema with a similar effect for now - with plenty of warnings given. I think that behavior would be a reasonable one to at least handle the keyword. I'll try to take a look at the lib code more and see if I can figure out where to add that in the architecture when I have a chance. |
I'd be happy to look at a PR when you have one.
…On Sat, Dec 2, 2023 at 8:14 PM Ryan Speers ***@***.***> wrote:
Yes, that makes sense. I tried a hack outside the library to monkey-patch
my schema with a similar effect for now - with plenty of warnings given. I
think that behavior would be a reasonable one to at least handle the
keyword. I'll try to take a look at the lib code more and see if I can
figure out where to add that in the architecture when I have a chance.
—
Reply to this email directly, view it on GitHub
<#51 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEH5EVDXNAZBGK5YMZCFATYHPHANAVCNFSM4COGO4MKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBTG4ZDSOJYGI4A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@cwacek I can move this to a new issue if useful, but in working on this I ran into an issue in my test creation, where when I set strict=True, which I did to sanity check if that mattered, it doesn't seem to see the property in the below example:
|
Can you make a draft PR with the test setup and I can take a look at it
later?
…On Mon, Dec 4, 2023 at 10:05 AM Ryan Speers ***@***.***> wrote:
@cwacek <https://github.com/cwacek> I can move this to a new issue if
useful, but in working on this I ran into an issue in my test creation,
where:
1. when I don't set strict=True, it doesn't seem to be raising a
ValidationError even on invalid emails (I see valdiator is determining
false, but the exception isn't propagating to be thrown)
2. when I set strict=True, which I did to sanity check if that
mattered, it doesn't seem to see the property in the below example:
def test_simple_array_anyOf():
basicSchemaDefn = {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Test",
"properties": {
"ExampleAnyOf": {"$ref": "#/definitions/exampleAnyOf"}
},
"required": ["ExampleAnyOf"],
"type": "object",
"definitions": {
"exampleAnyOf": {
"oneOf":
{"type": "string", "format": "email"},
{"type": "string", "maxlength": 0},
]
}
},
}
builder = pjo.ObjectBuilder(basicSchemaDefn)
ns = builder.build_classes(strict=True)
ns.Test().from_json('{"ExampleAnyOf" : ***@***.***"}')
—
Reply to this email directly, view it on GitHub
<#51 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEH5EXGMIUKXAZ3SFP5B53YHXRBZAVCNFSM4COGO4MKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBTHA4DGNRZGY2A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Created #266. That does not have a test for the strict issue mentioned above, it just is for anyOf simplifying to oneOf with the first anyOf item being used. Feedback/tweaks welcome if you had something else in mind. |
When I integrated this upstream, I found that although it worked for my simple example, it didn't work when it was nested in a real-world example. My fault. It looks like |
…object creators
#51 handle nested anyof, ensure that data gets passed down via object creators
This code
``
with open('ComputerSystemCollection.json') as schema_file:
root_schema = json.load(schema_file)
builder = pjso.ObjectBuilder (root_schema)
ns = builder.build_classes()
``
to generate binding for the following schema:
http://redfish.dmtf.org/schemas/v1/ComputerSystemCollection.json
results in the following error:
Traceback (most recent call last):
File "./test.py", line 14, in
ns = builder.build_classes()
File "/usr/lib/python2.7/site-packages/python_jsonschema_objects/init.py", line 78, in build_classes
builder.construct(uri, defn)
File "/usr/lib/python2.7/site-packages/python_jsonschema_objects/classbuilder.py", line 418, in construct
ret = self._construct(uri, _args, *_kw)
File "/usr/lib/python2.7/site-packages/python_jsonschema_objects/classbuilder.py", line 426, in _construct
"anyOf is not supported as bare property")
NotImplementedError: anyOf is not supported as bare property
The text was updated successfully, but these errors were encountered: