Kris Zyp ha scritto:
is equals to array nullable of string and null with maxItems = 3
...
and
{
"type" : ["null", {
"type" : [["null","string"]]
}],
"maxItems" : 3,
"pattern" : "patt"
}
is equals to array nullable of string and null with maxItems not setted
What do you think? If you use an object the system reset the options in
the root. You must do:
{
"type" : ["null", {
"type" : [["null","string"]],
"maxItems" : 3,
"pattern" : "patt"
}],
}
> ...
> and
>
> {
> "type" : ["null", {
> "type" : [["null","string"]]
> }],
> "maxItems" : 3,
> "pattern" : "patt"
> }
> is equals to array nullable of string and null with maxItems not setted
No, this is not a valid schema, the value for the type property or in the
union values must be a type definition, not a property definition. This
would be defining an array of objects that have a property of "type", but
the property definition for "type" is not valid (and clearly not what you
were intending).
You can do this:
{
"type" : ["null", {
"myProp":{"type" : [["null","string"]]}
}],
"maxItems" : 3,
"pattern" : "patt"
}
But I am not sure what you are trying to do...
Kris
{
"type" : ["null", {"type" : [["null","string"]],
maxItems : 9
},
{"type" : [["null","integer"]],
maxItems : 10
}
],
"pattern" : "patt"
}
Kris Zyp ha scritto:
This is a schema for an attribute.
Or the schema must start with a object/array element declaration?
>
The expression :
{ "type" : [["null","string"]]}
isn't a property definition but a type definition.
In another mail you tell me that
{"type" : "string" }
is a valid schema definition... but it isn't a property definition (what property?) but a type definition that a property can use. In this case an union use type definition.
What about?
Kris Zyp ha scritto:
> { "type" : [["null","string"]]}
> isn't a property definition but a type definition.
This is a property definition object.
{ "type" : [["null","string"]]} -> property definition object
[["null","string"]] -> type definition
> In another mail you tell me that
> {"type" : "string" }
> is a valid schema definition...
Yes the semantics of property definition object equal the semantics of
schema. A schema is basically just a root level property definition object
.
Sorry, for the confusion, I really need to make a graph/illustration of this
to clear things up.
Kris
I really that this increases the expressibility of JSON Schema in being able
to define things like this, but doesn't it also add complexity. This one
just seems like a very low usage capability for the complexity, but I am
open to it.
> I talk of object definition and not property definition.
> The same json object ({ "type" : [["null","string"]]} ) describes a
> type and not a property.
> Sorry but this statement is confused. If I use a json object how root
> is a type definition while if I use
> the same json object in an union or array is a property definition?
Perhaps we should use different names?
> Sorry but I don't see problem to use type (or property) object
> definition in an union or array. Moreover in this case
> you can clean the schema, inserting in array declaration only the
> property of the array:
> { "type" : [
> [
> {"type" : "string", "pattern":"xxx"},
> {"type" : "number", "format" : "integer",
> "maximum" : 10}
> ]
> ],
> "maxItems" : 100
> }
> instead of
> { "type" : [["string", "number"]],
> "pattern" : "xxx",
> "format" : "integer",
> "maximum" : 10,
> "maxItems" : 100
> }
Good point.
>
> moreover there could be conflicts:
> { "type" : [["string", ["string"]]],
> "pattern" : "xxx", <= this pattern is for the string or array of
> strings?
> "maxItems" : 100 <= this constraints is for the principal array or
> the nested array?
> }
Another good point. Still hestitant because of the increase in verbosity and
structural complexity, but I will keep thinking about it, and we can keep it
open idea for discussion.
Kris
I really that this increases the expressibility of JSON Schema in being able
to define things like this, but doesn't it also add complexity. This one
just seems like a very low usage capability for the complexity, but I am
open to it.
> I talk of object definition and not property definition.
> The same json object ({ "type" : [["null","string"]]} ) describes a
> type and not a property.
> Sorry but this statement is confused. If I use a json object how root
> is a type definition while if I use
> the same json object in an union or array is a property definition?
Perhaps we should use different names?
> Sorry but I don't see problem to use type (or property) object
> definition in an union or array. Moreover in this case
> you can clean the schema, inserting in array declaration only the
> property of the array:
> { "type" : [
> [
> {"type" : "string", "pattern":"xxx"},
> {"type" : "number", "format" : "integer",
> "maximum" : 10}
> ]
> ],
> "maxItems" : 100
> }
> instead of
> { "type" : [["string", "number"]],
> "pattern" : "xxx",
> "format" : "integer",
> "maximum" : 10,
> "maxItems" : 100
> }
Good point.
>
> moreover there could be conflicts:
> { "type" : [["string", ["string"]]],
> "pattern" : "xxx", <= this pattern is for the string or array of
> strings?
> "maxItems" : 100 <= this constraints is for the principal array or
> the nested array?
> }
Another good point. Still hestitant because of the increase in verbosity and
2. Should union capabilities be applicable to schemas in property
definitions in addition to union capabilities in type definition?
Currently, you can define a property to allow a string or number like:
"myProp": {"type":["number":"string"], "maximum":100, "maxLength":3}
It has been suggested that the union capability could be applied to the
schema for the property as well, so this could alternately be defined:
"myProp": [{"type":["number"], "maximum":100}, {"type":["string"],
"maxLength":3}]
[ ] only allow union on type definitions (only allow the first example)
[ ] allow union on type definitions and schemas (allow both examples)
Kris
----- Original Message -----
From: "Claudio D'Angelo" <claudio...@lombardia-servizi.it>
To: "JSON Schema" <json-...@googlegroups.com>
Sent: Saturday, January 12, 2008 12:50 AM
Subject: Re: Discussion on json-schema-examples
>
I agree with Claudio, I think there should just be number.
[ ] Just keep the set of possible types equivalent to the JSON primitive
[x] Same as above except also allow "any".
I like the idea of keeping a strict connection between JSON value types and
types defined in JSON Schema.
[x] only allow union on type definitions (only allow the first example)
> I'm also guessing that should have been "number","string and not
> "number":"string.
Oops, thanks, you are right, the first example should have been:
"myProp": {"type":["number","string"], "maximum":100, "maxLength":3}
1. Should we have separate definitions for minimum/maximum for a number, for
the minimum and maximum length of a string, and minimum and maximum number
of items in an array, or should they be combined in a single attribute.
[ ] separate minimum, minItems, minLength, max...
[ ] combine in one bi-property minimum/maximum.
[ ] combine two, keep one separate.
2. The number (or overloaded property, depending on vote from above) minimum
and maximum should be:
[ ] min/max
[ ] minimum/maximum - currently in the proposal.
3. Specifying possible values for a property:
[ ] options - currently in the proposal
[ ] enum
[ ] enumValues
[ ] enumeration
4. title
[ ] add title as a short description of a schema or property
[ ] leave title out (it is not currently in the spec)
5. final
[ ] remove the final attribute. One can indicate no additional properties
are allowed by setting the additionalProperties attribute to false (also
indicating the schema should not be extended)
[ ] keep final attribute as a way to indicate that the schema should not be
extended
[ ] Same as above except also allow "any".
[X ] allow union on type definitions and schemas (allow both examples)
1. Should we have separate definitions for minimum/maximum for a number, for
the minimum and maximum length of a string, and minimum and maximum number
of items in an array, or should they be combined in a single attribute.
[ ] separate minimum, minItems, minLength, max...
[X ] combine in one bi-property minimum/maximum.
[ ] combine two, keep one separate.
2. The number (or overloaded property, depending on vote from above) minimum
and maximum should be:
[ ] min/max
[X ] minimum/maximum - currently in the proposal.
3. Specifying possible values for a property:
[X ] options - currently in the proposal
[ ] enum
[ ] enumValues
[ ] enumeration
4. title
[X ] add title as a short description of a schema or property (
[ ] leave title out (it is not currently in the spec)
5. final
[ ] remove the final attribute. One can indicate no additional properties
are allowed by setting the additionalProperties attribute to false (also
indicating the schema should not be extended)
[ ] keep final attribute as a way to indicate that the schema should not be
extended
> 3. Specifying possible values for a property:
> [ ] options - currently in the proposal
> [x] enum
> [ ] enumValues
> [ ] enumeration
> 4. title
> [x] add title as a short description of a schema or property
> [ ] leave title out (it is not currently in the spec)
> [] add "annotation" as a short description of a schema or property,
> alt. name is "comment"
Regarding "annotation": I am not sure I understand the overloading argument.
Stephen, are you worried that people will want to have their own custom
property (which is allowed) called "title", that would interfere and have a
different meaning than the title of the schema?
> 5. final
> [x] remove the final attribute. One can indicate no additional properties
> Not to keep bringing up XML Schema but I think that
> it serves as a good analogy for at least reflecting upon.
I certainly appreciate the comparisons with XML Schema, as much as possible
we should learn from it to develop JSON Schema. Thanks for the insights and
analogies.
> XML Schema supports both Deriving Types By Extension:
> http://www.w3.org/TR/xmlschema-0/#DerivExt
> as well as Deriving Types By Restriction (what is being proposed
> here):
>
> http://www.w3.org/TR/xmlschema-0/#DerivByRestrict
Both of these concepts still follow the rule of a subtype defining a subset
of instances.
Perhaps an example would help:
Address =
{type:
{street:{type:"string"},
city:{type:"string"},
zip:{type:["number","string"]},
country:{type:"string"}}}
USAddress =
{extends: Address, // inherit all the properties from Address (would use
referencing here to reference Address)
type:
{state:{type:"string"}, // define the additional property "state"
zip:{type:"number"}, // constrain the zip property to be a number
country:{type:"string",enum:["US"]}} // constrain the value to only
being "US".
}
In this example all valid instances of USAddress are also valid instances of
Address (but not necessarily vice-versa).
An example of a valid USAddress (and by implication, Address):
{street:"299 Chestnut Dr", city: "Sandy", state:"UT",
zip:84070,country:"US"}
Kris
2. The set of types (bringing this one up again):
[ ] number, boolean, string, null, object, array
[ ] number, boolean, string, null, object, array, datetime, integer
[ ] also include any
[ ] move all formats to the type attribute. Anything besides string, number,
boolean, null, object, array, and integer would be considered a format of a
string.
[ ] move all formats to the type attribute and do subtyping of primitives in
MIME style format: boolean, text, text/url, text/phone, text/email, number,
number/integer, and so on...
----- Original Message -----
From: "Jakob Kruse" <kr...@kruse-net.dk>
To: "JSON Schema" <json-...@googlegroups.com>
Maybe some more informal voting to get an idea of what we want:
1. The type attribute can contain:
[ ] only a string primitive (string,boolean,number,etc...) or a union array
(of string primitives) with sub object property definitions and array item
definitions in a "properties" and "items" attributes. This is Jakob's
suggestion, I believe.
[ ] a string primitive or a union array of strings _or schemas_ with the
same delegation to "properties" and "items" like:
type: ["number",{type:"string",pattern:"[0-9]+"}]
This is kind of Jakob's and Claudio's suggestions combined.
[ ] a string primitive or a properties definition object/object type
definition or a single element array indicating an array instance, or a
union of string primitives and schemas (I think this was the favored choice
from the last vote) like:
type:
["number",{type:"string",pattern:"[0-9]+"},{type:{foo:{type:"string"},bar:{type:"string"}}}]
[x] The current proposal behavior of a type being an string primitive,
single element array, object type definition, or union.
If you need me to clarify these options more I can.
2. The set of types (bringing this one up again):
[] number, boolean, string, null, object, array
[x] number, boolean, string, null, object, array, datetime, integer
[x] also include any