Skip to content

Commit b3ed58b

Browse files
authored
ODATA-1275 - open - Describe structure of "JSON properties" (#52)
* Proposal for https://issues.oasis-open.org/browse/ODATA-1275 * Simplified term JSON.Schema to be just a string * Merged master, refreshed * Merged master * Term JSON.Schema now of type Core.JSON Core: added type definition Core.JSON * Example for JSON vocab Transform examples to CSDL JSON * Refreshed JSON Schema example * Moved JSON type definition from Core to JSON * Adapted after discussion in TC * Test commit * Test commit * Test commit * Refreshed example * Added vocabulary to top-level README.md
1 parent 4148238 commit b3ed58b

7 files changed

Lines changed: 225 additions & 2 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
* [Validation](vocabularies/Org.OData.Validation.V1.md)
3434
* [Authorization](vocabularies/Org.OData.Authorization.V1.md)
3535
* [Aggregation](vocabularies/Org.OData.Aggregation.V1.md)
36-
36+
* [JSON](vocabularies/Org.OData.JSON.V1.md)
37+
3738
<div>
3839
<h3>Contact</h3>
3940
<p>Please send questions or comments about <a href="https://www.oasis-open.org/resources/tcadmin/github-repositories-for-oasis-tc-members-chartered-work">OASIS TC GitHub repositories</a> to <a href="mailto:robin@oasis-open.org">Robin Cover</a> and <a href="mailto:chet.ensign@oasis-open.org">Chet Ensign</a>. For questions about content in this repository, please contact the TC Chair or Co-Chairs as listed on the the OData TC's <a href="https://www.oasis-open.org/committees/odata/">home page</a>.</p>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"$Version": "4.0",
3+
"$Reference": {
4+
"https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": {
5+
"$Include": [
6+
{
7+
"$Namespace": "Org.OData.Core.V1",
8+
"$Alias": "Core"
9+
}
10+
]
11+
},
12+
"https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.JSON.V1.json": {
13+
"$Include": [
14+
{
15+
"$Namespace": "Org.OData.JSON.V1",
16+
"$Alias": "JSON"
17+
}
18+
]
19+
}
20+
},
21+
"json.schema.sample": {
22+
"example": {
23+
"$Kind": "ComplexType",
24+
"CodeDictionary": {
25+
"$Type": "JSON.JSON",
26+
"@Core.LongDescription": "Dictionary of three-digit code --> description",
27+
"@Core.AutoExpand": true,
28+
"@JSON.Schema@Core.MediaType": "application/json",
29+
"@JSON.Schema": {
30+
"type": "object",
31+
"additionalProperties": false,
32+
"patternProperties": {
33+
"^[0-9]{3}$": {
34+
"type": "string"
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
3+
<edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.xml">
4+
<edmx:Include Namespace="Org.OData.Core.V1" Alias="Core" />
5+
</edmx:Reference>
6+
<edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.JSON.V1.xml">
7+
<edmx:Include Namespace="Org.OData.JSON.V1" Alias="JSON" />
8+
</edmx:Reference>
9+
<edmx:DataServices>
10+
<Schema Namespace="json.schema.sample" xmlns="http://docs.oasis-open.org/odata/ns/edm">
11+
12+
<ComplexType Name="example">
13+
<Property Name="CodeDictionary" Type="JSON.JSON" Nullable="false">
14+
<Annotation Term="Core.LongDescription" String="Dictionary of three-digit code --> description" />
15+
<Annotation Term="Core.AutoExpand" Bool="true" />
16+
<Annotation Term="JSON.Schema">
17+
<String>{"type":"object","additionalProperties":false,"patternProperties":{"^[0-9]{3}$":{"type":"string"}}}</String>
18+
<Annotation Term="Core.MediaType" String="application/json" />
19+
</Annotation>
20+
</Property>
21+
</ComplexType>
22+
23+
</Schema>
24+
</edmx:DataServices>
25+
</edmx:Edmx>

examples/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
This example shows a filter restriction to "multiple values", i.e. to `eq` or `in` expressions.
66

7+
8+
## [JSON Schema](Org.OData.JSON.V1.Schema-sample.xml)
9+
10+
This example shows a type definition of a "JSON Stream" property with an attached JSON Schema to describe/restrict the possible JSON values.
11+
12+
713
## [Permissions](Org.OData.Capabilities.V1.permissions-sample.xml)
814

915
Permissions property defined under Read, Insert, Update, Delete in the capabilities vocabulary, gives the ability to list Auth flows and scopes within those flows required to perform operations on an entity set.
10-
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$Version": "4.0",
3+
"$Reference": {
4+
"https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.json": {
5+
"$Include": [
6+
{
7+
"$Namespace": "Org.OData.Core.V1",
8+
"$Alias": "Core"
9+
}
10+
]
11+
}
12+
},
13+
"Org.OData.JSON.V1": {
14+
"$Alias": "JSON",
15+
"@Core.Description": "Terms for JSON properties",
16+
"@Core.Links": [
17+
{
18+
"rel": "alternate",
19+
"href": "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.JSON.V1.xml"
20+
},
21+
{
22+
"rel": "latest-version",
23+
"href": "https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.JSON.V1.json"
24+
},
25+
{
26+
"rel": "describedby",
27+
"href": "https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.JSON.V1.md"
28+
}
29+
],
30+
"Schema": {
31+
"$Kind": "Term",
32+
"$Type": "JSON.JSON",
33+
"$AppliesTo": [
34+
"Property"
35+
],
36+
"@Core.RequiresType": "Edm.Stream",
37+
"@Core.Description": "The JSON Schema for this JSON property",
38+
"@Core.LongDescription": "The schema can be a schema reference, i.e. `{\"$ref\":\"url/of/schemafile#/path/to/schema/within/schemafile\"}`"
39+
},
40+
"JSON": {
41+
"$Kind": "TypeDefinition",
42+
"$UnderlyingType": "Edm.Stream",
43+
"@Core.Description": "A stream of media type `application/json`",
44+
"@Core.AcceptableMediaTypes": [
45+
"application/json"
46+
]
47+
}
48+
}
49+
}

vocabularies/Org.OData.JSON.V1.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# JSON Vocabulary
2+
**Namespace: [Org.OData.JSON.V1](Org.OData.JSON.V1.xml)**
3+
4+
Terms for JSON properties
5+
6+
7+
## Terms
8+
9+
Term|Type|Description
10+
:---|:---|:----------
11+
[Schema](Org.OData.JSON.V1.xml#L67)|[JSON](#JSON)|<a name="Schema"></a>The JSON Schema for this JSON property<p>The schema can be a schema reference, i.e. `{"$ref":"url/of/schemafile#/path/to/schema/within/schemafile"}`</p>
12+
13+
## <a name="JSON"></a>[JSON](Org.OData.JSON.V1.xml#L75)
14+
**Type:** Stream
15+
16+
A stream of media type `application/json`

vocabularies/Org.OData.JSON.V1.xml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
4+
Technical Committee:
5+
OASIS Open Data Protocol (OData) TC
6+
https://www.oasis-open.org/committees/odata
7+
8+
Chairs:
9+
- Ralf Handl (ralf.handl@sap.com), SAP SE
10+
- Michael Pizzo (mikep@microsoft.com), Microsoft
11+
12+
Editors:
13+
- Ralf Handl (ralf.handl@sap.com), SAP SE
14+
- Michael Pizzo (mikep@microsoft.com), Microsoft
15+
16+
Additional artifacts:
17+
This vocabulary is one component of a Work Product that also includes the following vocabulary components:
18+
- OData Core Vocabulary. Latest version: https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.xml.
19+
- OData Measures Vocabulary. Latest version: https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Measures.V1.xml.
20+
- OData Capabilities Vocabulary. Latest version: https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Capabilities.V1.xml.
21+
- OData Validation Vocabulary. Latest version: https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Validation.V1.xml.
22+
- OData Aggregation Vocabulary. Latest version: https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Aggregation.V1.xml.
23+
- OData Authorization Vocabulary. Latest version: https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Authorization.V1.xml.
24+
- OData JSON Vocabulary. Latest version: https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.JSON .V1.xml.
25+
26+
Related work:
27+
This vocabulary replaces or supersedes:
28+
- OData Version 4.0 Vocabulary components: OData JSON Vocabulary.
29+
This vocabulary is related to:
30+
- OData Version 4.01 Part 1: Protocol. Latest version: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html.
31+
- OData Version 4.01 Part 2: URL Conventions. Latest version: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html.
32+
- OData Common Schema Definition Language (CSDL) JSON Representation Version 4.01. Latest version: http://docs.oasis-open.org/odata/odata-csdl-json/v4.01/odata-csdl-json-v4.01.html.
33+
- OData Common Schema Definition Language (CSDL) XML Representation Version 4.01. Latest version: http://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html.
34+
- OData JSON Format Version 4.01. Latest version: http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html.
35+
- OData Extension for Data Aggregation Version 4.0. Latest version: http://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/odata-data-aggregation-ext-v4.0.html.
36+
37+
Abstract:
38+
This document contains terms for JSON properties.
39+
40+
-->
41+
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
42+
<edmx:Reference Uri="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.Core.V1.xml">
43+
<edmx:Include Alias="Core" Namespace="Org.OData.Core.V1" />
44+
</edmx:Reference>
45+
<edmx:DataServices>
46+
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Org.OData.JSON.V1" Alias="JSON">
47+
<Annotation Term="Core.Description">
48+
<String>Terms for JSON properties</String>
49+
</Annotation>
50+
<Annotation Term="Core.Links">
51+
<Collection>
52+
<Record>
53+
<PropertyValue Property="rel" String="latest-version" />
54+
<PropertyValue Property="href" String="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.JSON.V1.xml" />
55+
</Record>
56+
<Record>
57+
<PropertyValue Property="rel" String="alternate" />
58+
<PropertyValue Property="href" String="https://oasis-tcs.github.io/odata-vocabularies/vocabularies/Org.OData.JSON.V1.json" />
59+
</Record>
60+
<Record>
61+
<PropertyValue Property="rel" String="describedby" />
62+
<PropertyValue Property="href" String="https://github.com/oasis-tcs/odata-vocabularies/blob/master/vocabularies/Org.OData.JSON.V1.md" />
63+
</Record>
64+
</Collection>
65+
</Annotation>
66+
67+
<Term Name="Schema" Type="JSON.JSON" Nullable="false" AppliesTo="Property">
68+
<Annotation Term="Core.RequiresType" String="Edm.Stream" />
69+
<Annotation Term="Core.Description" String="The JSON Schema for this JSON property" />
70+
<Annotation Term="Core.LongDescription">
71+
<String>The schema can be a schema reference, i.e. `{"$ref":"url/of/schemafile#/path/to/schema/within/schemafile"}`</String>
72+
</Annotation>
73+
</Term>
74+
75+
<TypeDefinition Name="JSON" UnderlyingType="Edm.Stream">
76+
<Annotation Term="Core.Description" String="A stream of media type `application/json`" />
77+
<Annotation Term="Core.AcceptableMediaTypes">
78+
<Collection>
79+
<String>application/json</String>
80+
</Collection>
81+
</Annotation>
82+
</TypeDefinition>
83+
84+
</Schema>
85+
</edmx:DataServices>
86+
</edmx:Edmx>

0 commit comments

Comments
 (0)