fixup! software/jstestnode: add json for instance parameters
This json schema was not finished ...
-
before i looked at this schema i had thought no schema could have
oneOf/anyOf
at the top level, that's why rjs_json_form renders only the first variant ofoneOf/anyOf
at the top level. Do i correctly understand:- that the properties indicated in
oneOf
are thetarget
entity properties? -
target
,testsuit
are the property ofjstestnode
entity?
If both of the above statements are correct, then the choice of Firefox/Selenium/Nodejs is the choice of target type, isn't it? If this is true, then placing this choice at the same level as
jstestnode
is not logical.As i see the schema can be rewritten:
- at the top level there are 2 properties -
target
andtest-suite
. -
target
has 3oneOf
items, every item has constanttype
@jerome , what do you think?
Also I wonder if there's a way not to repeat the
"test-suite": { "$ref": "#/common/test-suite" },
i think the repetition can be avoided by:
{ "allOf": [ { "properties": { "test-suite": { "description": "The test suite to run", "type": "string", "enum": [ "jio", "renderjs" ] } } }, { "oneOf": [ { "type": "object", "additionalProperties": false, "properties": { "type": { "type": "string", "const": "selenium-server" } } } ] } ] }
rjs_json_form supports any order and quantity of
anyOf/oneOf/allOf
enclosed in each other.[edit: fix misprint in example]
- that the properties indicated in
-
Owner
Thanks @bk . I'll try this again soon. I remember trying something similar but could not find the correct syntax. I also feel this is the correct approach.
Sorry for not replying earlier. I really appreciated your feedback, I could not find the time to look into this seriously yet.
PS I assume you meant
allOf
and notandOf
. Or is it a recent json schema feature ? -
PS I assume you meant allOf and not andOf. Or is it a recent json schema feature ?
Sorry. Of couse i meant
allOf
. -
@jerome , the fact that i didn't implement the
anyOf/oneOf
at the top level doesn't correspond to the specs. I did this on purpose because i think such schemes don't fit for visualization as forms. I think an user is accustomed to see the static set of fields on the top level and that fields can have arrays or properties with variable ('oneOf/anyOf') items, values. For example i think when user opens the Person for edit he expects to see the properties of Person, not a choice "edit Person or Organisation".Before rendering schema in form generator any quantity of
anyOf/oneOf
situated on the same level will be simplified to oneanyOf
even if some ofanyOf/oneOf
are inside ofallOf
. That's why the schema{ "allOf": [ { "properties": { "test-suite": { "description": "The test suite to run", "type": "string", "enum": [ "jio", "renderjs" ] } } }, { "oneOf": [ { "type": "object", "additionalProperties": false, "properties": { "type": { "type": "string", "const": "selenium-server" } } }, { "type": "object", "additionalProperties": false, "properties": { "type": { "type": "string", "const": "firefox" } } } ] } ] }
will be simplified to:
{ "anyOf": [ { "type": "object", "additionalProperties": false, "properties": { "test-suite": { "description": "The test suite to run", "type": "string", "enum": [ "jio", "renderjs" ] }, "type": { "type": "string", "const": "selenium-server" } } }, { "type": "object", "additionalProperties": false, "properties": { "test-suite": { "description": "The test suite to run", "type": "string", "enum": [ "jio", "renderjs" ] }, "type": { "type": "string", "const": "firefox" } } } ] }
So, there are 2 variants
- make changes in your schema (this will invoke changes in the backend):
- at the top level there are 2 properties - target and test-suite.
- target has 3 oneOf items, every item has constant type
- make changes in form generator, so it can render
anyOf/oneOf
at the top level.
@jerome , what is your opinion?
-
Owner
Thanks @bk
That's true that a "oneOf" at top level is a bit strange, for ERP5 we would first choose adding a person or organisation, for SlapOS we could use different "software types" for this (but we don't use much of this, I think that with testnode we can only request the default software).
For other reasons (so that it uses the same
test-runner
key as ERP5), I was also considering at moving theoneOf
to select the target down one level. If we havetest-runner
, instead of:{ "remote-access-url": "http://localhost", "test-suite": "jio", "target": "firefox" }
We would use
{ "remote-access-url": "http://localhost", "test-suite": "jio", "test-runner": { "target": "firefox" } }
or
{ "remote-access-url": "http://localhost", "test-suite": "jio", "test-runner": { "target": "selenium-server", "server-url": "http://localhost", "verify-server-certificate": false, "desired-capabilities": { "browserName": "Firefox", "version": "52" } } }
I tried quickly ( jerome/slapos@3ed2e7fe / https://codepen.io/perrinjerome/pen/RqGOWj ), but I could not get rjs_json_form show a list field for target type. I might be doing something wrong.
At this point I can't say if we need to support top level oneOf/allOf, I still need to understand how to get it working at "non top level".
-
Hello @jerome , could you have a look at: https://codepen.io/bkrocherov/pen/MzbeRx There i changed the schema:
- added titles for each of oneOf item
- changed test-runner property - it's required
- switched additionalProperties to False.
The view of the schema at https://codepen.io/bkrocherov/pen/MzbeRx is one i expected. I don't find yet why we have differences in css, which broke the view and why clicking on empty space rises the exception.
-
Hello @jerome,
i've found the cause why clicking on empty space rises the exception and have fixed it: bk/rjs_json_form@0c9057b2 .
About css: it looks like this css is broken by template engine. Correct css can be :
- compiled by
./node_modules/.bin/grunt less
- or downloaded from https://d1.erp5.ru/nexedi/rjs_json_form/gadget_erp5_nojqm.css .
- compiled by
-
mentioned in merge request !425 (merged)