Commit 29b6ea96 authored by Jérome Perrin's avatar Jérome Perrin

full_schema: This seem to be the best syntax for conditional dependencies...

full_schema: This seem to be the best syntax for conditional dependencies depending on property values in json schema

in draft4, dependency keyword only varies based on the presence or abscence of
a property.

This solution has been suggested in :

http://stackoverflow.com/questions/9029524/json-schema-specify-field-is-required-based-on-value-of-another-field
http://stackoverflow.com/questions/5036366/writing-more-complex-json-schemas-that-have-dependencies-upon-other-keys#answer-5112681

( type from v3 is oneOf from v4 )
parent 4cf51818
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
"title" : "Fixed", "title" : "Fixed",
"type" : "object", "type" : "object",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Fixed"]
},
"mean" : { "mean" : {
"type" : "number", "type" : "number",
"default" : 0.75, "default" : 0.75,
...@@ -19,6 +23,10 @@ ...@@ -19,6 +23,10 @@
"title": "Exp", "title": "Exp",
"description" : "Exponential", "description" : "Exponential",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Exp"]
},
"mean" : { "mean" : {
"type" : "number", "type" : "number",
"default" : 0, "default" : 0,
...@@ -31,6 +39,10 @@ ...@@ -31,6 +39,10 @@
"title" : "Normal", "title" : "Normal",
"description" : "Normal", "description" : "Normal",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Normal"]
},
"mean" : { "mean" : {
"type" : "number", "type" : "number",
"default" : 0, "default" : 0,
...@@ -48,6 +60,10 @@ ...@@ -48,6 +60,10 @@
"title" : "Lognormal", "title" : "Lognormal",
"description" : "Lognormal", "description" : "Lognormal",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Lognormal"]
},
"mean" : { "mean" : {
"name" : "Mean", "name" : "Mean",
"type" : "number", "type" : "number",
...@@ -65,6 +81,10 @@ ...@@ -65,6 +81,10 @@
"title" : "Binomial", "title" : "Binomial",
"description" : "Binomial", "description" : "Binomial",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Binomial"]
},
"mean" : { "mean" : {
"type" : "number", "type" : "number",
"default" : 0 "default" : 0
...@@ -80,6 +100,10 @@ ...@@ -80,6 +100,10 @@
"title" : "Poisson", "title" : "Poisson",
"description" : "Poisson", "description" : "Poisson",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Poisson"]
},
"lambda" : { "lambda" : {
"type" : "number", "type" : "number",
"default" : 0 "default" : 0
...@@ -91,6 +115,10 @@ ...@@ -91,6 +115,10 @@
"title" : "Logistic", "title" : "Logistic",
"description" : "Logistic", "description" : "Logistic",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Logistic"]
},
"location" : { "location" : {
"type" : "number", "type" : "number",
"default" : 0, "default" : 0,
...@@ -108,6 +136,10 @@ ...@@ -108,6 +136,10 @@
"title" : "Caucy", "title" : "Caucy",
"description" : "Caucy", "description" : "Caucy",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Caucy"]
},
"location" : { "location" : {
"type" : "number", "type" : "number",
"default" : 0 "default" : 0
...@@ -123,6 +155,10 @@ ...@@ -123,6 +155,10 @@
"title" : "Geometric", "title" : "Geometric",
"description" : "Geometric", "description" : "Geometric",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Geometric"]
},
"probability" : { "probability" : {
"type" : "number", "type" : "number",
"default" : 0, "default" : 0,
...@@ -135,6 +171,10 @@ ...@@ -135,6 +171,10 @@
"title" : "Gama", "title" : "Gama",
"description" : "Gama", "description" : "Gama",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Gama"]
},
"shape" : { "shape" : {
"type" : "number", "type" : "number",
"default" : 0, "default" : 0,
...@@ -152,6 +192,10 @@ ...@@ -152,6 +192,10 @@
"title" : "Weibull", "title" : "Weibull",
"description" : "Weibull", "description" : "Weibull",
"properties" : { "properties" : {
"distribution": {
"type" : "string",
"enum": ["Weibull"]
},
"shape" : { "shape" : {
"type" : "number", "type" : "number",
"default" : 0, "default" : 0,
...@@ -247,28 +291,6 @@ ...@@ -247,28 +291,6 @@
] ]
}, },
"_dist" : { "_dist" : {
"allOf" : [{
"type" : "object",
"properties" : {
"distribution" : {
"type" : "string",
"default" : "Fixed",
"enum" : [
"Fixed",
"Exp",
"Normal",
"Lognormal",
"Binomial",
"Poisson",
"Logistic",
"Caucy",
"Geometric",
"Gama",
"Weibull"
]
}
}
}, {
"oneOf" : [{ "oneOf" : [{
"$ref" : "#/definitions/distributionTypes/_fixed" "$ref" : "#/definitions/distributionTypes/_fixed"
}, { }, {
...@@ -293,8 +315,6 @@ ...@@ -293,8 +315,6 @@
"$ref" : "#/definitions/distributionTypes/_weibull" "$ref" : "#/definitions/distributionTypes/_weibull"
} }
] ]
}
]
}, },
"_schedulingRule" : { "_schedulingRule" : {
"description" : "Scheduling Rule", "description" : "Scheduling Rule",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment