OData JSON Format for Common Schema Definition …



OData JSON Format for Common Schema Definition Language (CSDL) Version 4.0Working Draft 0213 18 July 2016Technical Committee:OASIS Open Data Protocol (OData) TCChairs:Ram Jeyaraman (Ram.Jeyaraman@), MicrosoftRalf Handl (ralf.handl@), SAP SEEditors:Ralf Handl (ralf.handl@), SAP SEHubert Heijkers (hubert.heijkers@nl.), IBMMike Pizzo (mikep@), MicrosoftMartin Zurmuehl (martin.zurmuehl@), SAP SEAdditional artifacts:This prose specification is one component of a Work Product that also includes:OData JSON Format for Common Schema Definition Language (CSDL) Version 4.0 (this document)edm.jsonRelated work:This specification replaces or supersedes:NoneThis specification is related to:OData JSON Format Version 4.0. OASIS Standard. 24 February 2014. Version 4.0, a multi-part Work Product which includes:OData Version 4.0 Part 1: Protocol. 24 February 2014. Version 4.0 Part 2: URL Conventions. 24 February 2014. Version 4.0 Part 3: Common Schema Definition Language (CSDL). 24 February 2014. components: OData ABNF Construction Rules Version 4.0 and OData ABNF Test Cases. 14 August 2013. components: OData Core Vocabulary, OData Measures Vocabulary and OData Capabilities Vocabulary. 24 February 2014. XML namespaces:NoneAbstract:The Open Data Protocol (OData) is an open protocol for creating and consuming queryable and interoperable RESTful APIs in a simple and standard way. OData services are described by an entity-relationship model, and the model description is an integral part of each OData service. This document extends the specification OData Version 4.0 Part 3: Conceptual Schema Definition Language (CSDL) by defining a JSON format for representing the entity-relationship model and resulting REST resources of an OData service. This JSON format for CSDL is based on the OpenAPI Specification, which itself is based on JSON Schema.Status:This Working Draft (WD) has been produced by one or more TC Members; it has not yet been voted on by the TC or approved as a Committee Draft (Committee Specification Draft or a Committee Note Draft). The OASIS document Approval Process begins officially with a TC vote to approve a WD as a Committee Draft. A TC may approve a Working Draft, revise it, and re-approve it any number of times as a Committee Draft.URI patterns:Initial publication URI: Permanent “Latest version” URI: Permanent link to latest version of edm.json: (Managed by OASIS TC Administration; please don’t modify.)Copyright ? OASIS Open 2016. All Rights Reserved.All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website.This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English.The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns.This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.Table of Contents TOC \o "1-5" \h \z \u 1Introduction PAGEREF _Toc456622976 \h 51.1 Terminology PAGEREF _Toc456622977 \h 51.2 Normative References PAGEREF _Toc456622978 \h 51.3 Non-Normative References PAGEREF _Toc456622979 \h 51.4 Typographical Conventions PAGEREF _Toc456622980 \h 72CSDL JSON Format Design PAGEREF _Toc456622981 \h 82.1 Design Goals PAGEREF _Toc456622982 \h 82.2 Design Principles PAGEREF _Toc456622983 \h 83Requesting the CSDL JSON Format PAGEREF _Toc456622984 \h 94CSDL JSON Documents PAGEREF _Toc456622985 \h 104.1 Keyword x-odata-version PAGEREF _Toc456622986 \h 104.2 Keyword swagger PAGEREF _Toc456622987 \h 104.3 Keyword info PAGEREF _Toc456622988 \h 104.4 Keywords schemes, host, and basePath PAGEREF _Toc456622989 \h 114.5 Keywords consumes and produces PAGEREF _Toc456622990 \h 114.6 Keyword tags PAGEREF _Toc456622991 \h 114.7 Keyword parameters PAGEREF _Toc456622992 \h 124.8 Keyword responses PAGEREF _Toc456622993 \h 134.9 Keyword paths PAGEREF _Toc456622994 \h 134.9.1 Entity Sets PAGEREF _Toc456622995 \h 134.9.1.1 Query a Collection of Entities PAGEREF _Toc456622997 \h 144.9.1.2 Create an Entity PAGEREF _Toc456622998 \h 164.9.1.3 Retrieve an Entity PAGEREF _Toc456622999 \h 174.9.1.4 Update an Entity PAGEREF _Toc456623000 \h 194.9.1.5 Delete an Entity PAGEREF _Toc456623001 \h 194.9.1.6 Invoke Bound Actions and Bound Functions PAGEREF _Toc456623002 \h 204.9.2 Singletons PAGEREF _Toc456623003 \h 214.9.2.1 Retrieve a Singleton PAGEREF _Toc456623004 \h 224.9.2.2 Update a Singleton PAGEREF _Toc456623005 \h 234.9.3 Action Imports PAGEREF _Toc456623006 \h 244.9.4 Function Imports PAGEREF _Toc456623007 \h 244.10 Keyword definitions PAGEREF _Toc456623008 \h 264.10.1 Entity Types and Complex Types PAGEREF _Toc456623009 \h 264.10.2 Properties PAGEREF _Toc456623010 \h 274.10.2.1 Primitive Properties PAGEREF _Toc456623011 \h 274.10.2.2 Complex Properties PAGEREF _Toc456623012 \h 324.10.2.3 Navigation Properties PAGEREF _Toc456623013 \h 324.10.2.4 Collection-Valued Properties PAGEREF _Toc456623014 \h 334.10.2.5 Nullable Properties PAGEREF _Toc456623015 \h 344.10.3 Enumeration Types PAGEREF _Toc456623016 \h 344.10.4 Type Definitions PAGEREF _Toc456623017 \h 364.11 Keywords x-actions and x-functions PAGEREF _Toc456623018 \h 364.12 Keyword x-entityContainer PAGEREF _Toc456623019 \h 374.13 Keyword x-terms PAGEREF _Toc456623020 \h 394.14 Keyword x-schemas PAGEREF _Toc456623021 \h 394.15 Keyword x-references PAGEREF _Toc456623022 \h 404.15.1 Keyword includeAnnotations PAGEREF _Toc456623023 \h 404.16 Annotations PAGEREF _Toc456623024 \h 414.16.1 Keyword annotations PAGEREF _Toc456623025 \h 414.16.2 Inline Annotations PAGEREF _Toc456623026 \h 414.16.2.1 Constant Expressions PAGEREF _Toc456623027 \h 414.16.2.2 Path Expressions PAGEREF _Toc456623028 \h 424.16.2.3 Collection Expressions PAGEREF _Toc456623029 \h 424.16.2.4 Record Expressions PAGEREF _Toc456623030 \h 424.16.2.5 Comparison and Logical Operators and If Expression PAGEREF _Toc456623031 \h 424.16.2.6 Expression Apply PAGEREF _Toc456623032 \h 434.16.2.7 Expressions Cast and IsOf PAGEREF _Toc456623033 \h 434.16.2.8 Expression LabeledElement PAGEREF _Toc456623034 \h 434.16.2.9 Expression LabeledElementReference PAGEREF _Toc456623035 \h 444.16.2.10 Expression Not PAGEREF _Toc456623036 \h 444.16.2.11 Expression Null PAGEREF _Toc456623037 \h 444.16.2.12 Expression UrlRef PAGEREF _Toc456623038 \h 454.16.2.13 Annotation Core.Description PAGEREF _Toc456623039 \h 455Extensions to the OpenAPI Specification PAGEREF _Toc456623040 \h 465.1 The edm.json Document PAGEREF _Toc456623041 \h 465.2 Keywords PAGEREF _Toc456623042 \h 465.3 Formats PAGEREF _Toc456623043 \h 466Payload Validation PAGEREF _Toc456623044 \h 486.1 Limitations PAGEREF _Toc456623045 \h 486.2 Mapping of Messages to Schemas PAGEREF _Toc456623046 \h 487Extensibility PAGEREF _Toc456623047 \h 508CSDL Examples PAGEREF _Toc456623048 \h 518.1 Products and Categories Example PAGEREF _Toc456623049 \h 518.2 Annotations for Products and Categories Example PAGEREF _Toc456623050 \h 579Conformance PAGEREF _Toc456623051 \h 599.1 OData Service Conformance PAGEREF _Toc456623052 \h 599.2 OData Client Conformance PAGEREF _Toc456623053 \h 59Appendix A.Acknowledgments PAGEREF _Toc456623054 \h 60Appendix B.Revision History PAGEREF _Toc456623055 \h 61IntroductionOData services are described in terms of an Entity Data Model (EDM). [OData-CSDL] defines an XML representation of the entity data model exposed by an OData service. This document defines an alternative representation using the JavaScript Object Notation (JSON), see [RFC7159].Instead of inventing an OData-specific JSON format for describing OData services the JSON representation of an entity data model is based in the OpenAPI Specification Version 2.0 (see [ REF OpenAPIspec \h \* MERGEFORMAT OpenAPI]). The OpenAPI Specification is a project used to describe and document RESTful APIs. It defines a set of JSON or YAML files required to describe such an API. These files can then be used by various tools to display the API, test the API, or generate clients in various programming languages. The OpenAPI Specification is extensible and allows adding keywords and formats for CSDL concepts that do not correspond to or aren’t fully covered by OpenAPI Specification concepts. TerminologyThe key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC2119].Normative References[OData-CSDL]OData Version 4.0 Part 3: Common Schema Definition Language (CSDL). See link in “Related work” section on cover page.[OData-JSON]OData JSON Format Version 4.0. See link in “Related work” section on cover page.[OData-Protocol]OData Version 4.0 Part 1: Protocol. See link in “Additional artifacts” section on cover page.[OData-URL]OData Version 4.0 Part 2: URL Conventions. See link in "Related work" section on cover page.[OData-VocCore]OData Core Vocabulary. See link in "Related work" section on cover page.[OData-VocCap]OData Capabilities Vocabulary. See link in "Related work" section on cover page.[OpenAPI]OpenAPI Specification Version 2.0, .[RFC2119]Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels”, BCP 14, RFC 2119, March 1997. . [RFC7159]Bray, T., Ed., “The JavaScript Object Notation (JSON) Data Interchange Format”, RFC 7159, March 2014. . Non-Normative References[ECMAScript]ECMAScript Language Specification Edition 5,1. June 2011. Standard ECMA-262. . [JS-Core]JSON Schema: core definitions and terminology.. [JS-Validation]JSON Schema: interactive and non interactive validation. . [XML-Schema-2]W3C XML Schema Definition Language (XSD) 1.1 Part 2: DatatypesW3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes, D. Peterson, S. Gao, C. M. Sperberg-McQueen, H. S. Thompson, P. V. Biron, A. Malhotra, Editors, W3C Recommendation, 5 April 2012, version available at ConventionsKeywords defined by this specification use this monospaced font.Normative source code uses this paragraph style.Some sections of this specification are illustrated with non-normative examples. Example SEQ Example \* ARABIC 1: text describing an example uses this paragraph styleNon-normative examples use this paragraph style.All examples in this document are non-normative and informative only.All other text is normative unless otherwise labeled.CSDL JSON Format DesignDesign GoalsThe goals and guiding design principles areCSDL JSON documents are valid OpenAPI Specification filesCSDL JSON documents contain the same information as CSDL XML documents defined in [ODataCSDL] CSDL JSON uses OpenAPI Specification concepts as much as possibleCSDL JSON uses [OData-JSON] concepts where it goes beyond the OpenAPI SpecificationJSON.parse() of CSDL JSON documents creates JavaScript object graphs that Appeal to JavaScript programmers by following common naming conventionsSatisfy basic access patternsCan easily be augmented with client-side post-processing to satisfy more sophisticated access patternsDesign PrinciplesTo achieve the design goals the following principles were applied:Structure-describing CSDL elements (structured types, type definitions, enumerations) are translated into OpenAPI Schema Objects within the OpenAPI Definitions ObjectAttributes and child elements of structure-describing CSDL elements that cannot be translated into OpenAPI Specification constructs are added as extension keywords to the target OpenAPI Specification constructsThe entity container is translated into an OpenAPI Paths ObjectAll other CSDL elements are translated into JSON with a consistent set of rulesElement and attribute names in UpperCamelCase are converted to lowerCamelCase, and uppercase attribute names are converted to lowercaseElements that can occur at most once within a parent become name/value pairsElements that can occur more than once within a parent and can be uniquely identified within their parent (schemas, key properties, entity sets, …) become a name/value pair with pluralized name and a "dictionary" object as value containing one name/value pair per element with the identifier as nameElements that can occur more than once within a parent and cannot be uniquely identified within their parent (action overloads, function overloads, …) become a name/value pair with pluralized name and an array as value containing one item per child elementRequesting the CSDL JSON FormatThe CSDL JSON format can be requested in Metadata Document Requests (see [ODataProtocol]) using the $format query option in the request URL with the MIME type application/openapi+json, optionally followed by format parameters.Alternatively, this format can be requested using the Accept header with the MIME type application/openapi+json, optionally followed by format parameters. If specified, $format overrides any value specified in the Accept header.Possible format parameters are:IEEE754CompatibleThese are defined in [OData-JSON].CSDL JSON DocumentsA CSDL JSON document is represented as an OpenAPI Specification document with additional keywords.In addition to the keywords swagger, info and paths required by the OpenAPI Specification a CSDL JSON document MUST contain the keyword x-odata-version.It MAY contain any keyword defined by the OpenAPI Specification, especially the definitions keyword, and it MAY contain the keywords xactions, x-functions, x-terms, xentityContainer, xschemas, and xreferences.Example SEQ Example \* ARABIC 2: Structure of a CSDL document{ "x-odata-version":"4.0", "swagger":"2.0", "info": …, "paths": …, "definitions": …, "x-actions": …, "x-functions": …, "x-terms": …, "x-entityContainer": …, "x-schemas": …, "x-references": …}Keyword x-odata-versionThe value of x-odata-version is the string "4.0".Keyword swaggerThe value of swagger is the string "2.0".Keyword infoThe value of info is an Info Object, see [ REF OpenAPIspec \h OpenAPI]. It MUST contain the keywords title and version, and it SHOULD contain the keyword description.The value of title SHOULD be the value of the annotation Core.Description (see [OData-VocCore]) of the main schema or the entity container of the CSDL document.The value of version SHOULD be the value of the annotation Core.SchemaVersion (see [OData-VocCore]) of the main schema.The value of description SHOULD be the value of the annotation Core.LongDescription (see [OData-VocCore]) of the main schema or the entity container.Example SEQ Example \* ARABIC 3: Info Object – note that description accepts Markdown format"info":{ "title":"OData Service for namespace ODataDemo", "version":"0.1.0", "description":"This OData service is located at \n\n## References\n- [Org.OData.Core.V1]()\n- [Org.OData.Measures.V1]()"}Keywords schemes, host, and basePathThe value of schemes is an array of strings. If present it MUST contain an item with the scheme component of the service root URL.The value of host is a string. If present it MUST be the authority component of the service root URL. The value of basePath is a string. If present it MUST be the path component of the service root URL. Example SEQ Example \* ARABIC 4: service root URL"schemes": [ "http"],"host":"localhost","basePath":"/service-root"Keywords consumes and producesThe values of consumes and produces are arrays of strings. If present they MUST contain an item for each media type listed in the Capabilities.SupportedFormats annotation (see [ REF VocCapabilities \h OData-VocCap]) on the entity container.Example SEQ Example \* ARABIC 5: supported formats"consumes":[ "application/json"],"produces":[ "application/json"]Keyword tagsThe value of tags is an array of Tag Objects, see [ REF OpenAPIspec \h OpenAPI]. Tags are used for logical grouping of operations. For an OData service the natural groups are entity sets and singletons, so the tags array SHOULD contain one Tag Object per entity set and singleton in the entity container.A Tag Object MUST contain the keyword name, whose value SHOULD be the name of the entity set or singleton, and it MAY contain the keyword description, whose value SHOULD be the value of the annotation Core.Description of the entity set or singleton.The tags array MAY contain additional Tag Objects for other logical groups, e.g. for action imports or function imports that are not associated with an entity set.Example SEQ Example \* ARABIC 6: tags with optional descriptions"tags":[ { "name": "Products" }, { "name": "Categories", "description": "Product Categories" }, { "name": "Suppliers" }, { "name": "MainSupplier", "description": "Primary Supplier" }, { "name": "Countries" }]Keyword parametersThe value of parameters is a Parameters Definitions Object, see [ REF OpenAPIspec \h OpenAPI]. It allows defining query options and headers that can be reused across operations of the service.It SHOULD contain one name/value pair per OData system query option supported by the service. Alternatively operation descriptions can reference the parameter definitions in the edm.json document.Example SEQ Example \* ARABIC 7: reusable query options"parameters": { "top": { "name": "$top", "type": "integer", "in": "query", "description": "Show only the first n items, see [OData Paging - Top]()" }, "skip": { "name": "$skip", "type": "integer", "in": "query", "description": "Skip the first n items, see [OData Paging - Skip]()" }, "count": { "name": "$count", "type": "boolean", "in": "query", "description": "Include count of items, see [OData Count]()" }, "filter": { "name": "$filter", "type": "string", "in": "query", "description": "Filter items by property values, see [OData Filtering]()" }, "search": { "name": "$search", "type": "string", "in": "query", "description": "Search items by search phrases, see [OData Searching]()" }}Keyword responsesThe value of responses is a Responses Definitions Object, see [ REF OpenAPIspec \h OpenAPI]. It allows defining responses that can be reused across operations of the service.It SHOULD contain one name/value pair for the standard OData error response that is referenced from all operations of the service. Alternatively operation descriptions can directly reference the odata.error schema in the edm.json document.Example SEQ Example \* ARABIC 8: reusable error response referencing the odata.error schema in edm.json"responses": { "error": { "description": "Error", "schema": { "$ref": "" } }}Keyword pathsThe value of paths is a Paths Object, see [ REF OpenAPIspec \h OpenAPI]. It is the main source of information on how to use the described API. It consists of name/value pairs whose name is a path template relative to the service root URL, and whose value is a Path Item Object, see [ REF OpenAPIspec \h OpenAPI].Due to the power and flexibility of OData a full representation of all service capabilities in the Paths Object is typically not feasible, so this specification only describes the minimum information required in the Paths Object. Implementations are allowed – and in fact encouraged – to add additional information that is deemed useful for the intended target audience of the OpenAPI description of that service, leveraging the documentation features of the OpenAPI Specification, especially and not limited to human-readable descriptions. The extension keyword x-entityContainer contains a full description of the OData entity container.The minimum information to be included in the Paths Object is described in the remainder of this section. The Paths Object SHOULD reflect the resources and capabilities of the service as closely as possible, i.e. only list supported operations and query options.Example SEQ Example \* ARABIC 9: paths for entity sets, individual entities, singletons, action imports, and function imports"paths": { "/Products": …, "/Products('{ID}')": …, "/Categories": …, "/Categories({ID})": …, "/Suppliers": …, "/Suppliers('{ID}')": …, "/MainSupplier": …, "/Countries": …, "/Countries('{Code}')": …, "/ProductsByRating(Rating={Rating})": …}Entity SetsEach entity set is represented as a name/value pair whose name is the service-relative resource path of the entity set prepended with a forward slash, and whose value is a Path Item Object, see [ REF OpenAPIspec \h OpenAPI].Example SEQ Example \* ARABIC 10: path template operation for an entity set"/Products": …Each entity set that is indexable by key is additionally represented as a name/value pair whose name is the path template for key access, with path parameters for the key values, and whose value is a Path Item Object describing the allowed operations on individual entities of this set. Example SEQ Example \* ARABIC 11: path template for an individual entity within an entity set – single-part key"/Products('{ID}')": …Example SEQ Example \* ARABIC 12: path template for an individual entity within an entity set – multi-part key"/OrderItems(OrderID={OrderID},ItemID={ItemID})": …If the service defines bound actions or functions applicable to the entity set or its entities, these MAY are representedbe described as additional name/value pairs with corresponding path templates for the action/function invocation.Example SEQ Example \* ARABIC 13: path template for a bound action"/LeaveRequests({ID})/OData.Demo.Approval": …Query a Collection of EntitiesThe Path Item Object for the entity set SHOULD contain the keyword get with an Operation Object as value that describes the capabilities for querying the entity set. The tags array of the Operation Object – as well as all other Operation Objects described in this section – SHOULD include the entity set name.Example SEQ Example \* ARABIC 14: GET operation for an entity set – summary and tags"/Products": { "get": { "summary": "Get entities from Products", "tags": [ "Products" ],The parameters array SHOULD contain Parameter Objects for system query options allowed for this entity set, and it SHOULD NOT list system query options not allowed for this entity set. Example SEQ Example \* ARABIC 15: GET operation for an entity set - parameters "parameters": [ { "$ref": "#/parameters/top" }, { "$ref": "#/parameters/skip" }, { "$ref": "#/parameters/search" }, { "$ref": "#/parameters/filter" }, { "$ref": "#/parameters/count" },Note: the syntax of the system query options $expand, $select, and $orderby is too flexible to be formally described with OpenAPI Specification means, yet the typical use cases of just providing a comma-separated list of properties can be expressed via an array-valued parameter with an enum constraint, as shown in the following example. This makes it easy to try out these system query options in OpenAPI tools.Example SEQ Example \* ARABIC 16: GET operation for an entity set – more specific parameters { "name": "$expand", "in": "query", "description": "Expand related entities, see [OData Expand]()", "type": "array", "uniqueItems": true, "items": { "type": "string" }, "enum": [ "*", "Category", "Supplier" ] }, { "name": "$select", "in": "query", "description": "Select properties to be returned, see [OData Select]()", "type": "array", "uniqueItems": true, "items": { "type": "string" }, "enum": [ "ID", "Description", "ReleaseDate", "DiscontinuedDate", "Rating", "Price", "Currency" ] }, { "name": "$orderby", "in": "query", "description": "Order items by property values, see [OData Sorting]()", "type": "array", "uniqueItems": true, "items": { "type": "string" }, "enum": [ "ID", "ID desc", "Description", "Description desc", "ReleaseDate", "ReleaseDate desc", "DiscontinuedDate", "DiscontinuedDate desc", "Rating", "Rating desc", "Price", "Price desc", "Currency", "Currency desc" ] } ],The value of responses is a Responses Object, see [ REF OpenAPIspec \h OpenAPI]. It SHOULD contain a name/value pair for the success case (HTTP response code 200) describing the structure of a successful response, referencing the schema of the entity set’s entity type in the global definitions. In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global responses.Example SEQ Example \* ARABIC 17: GET operation for an entity set - responses "responses": { "200": { "description": "Retrieved entities", "schema": { "type": "object", "title": "Collection of Product", "properties": { "value": { "type": "array", "items": { "$ref": "#/definitions/ODataDemo.Product" } } } } }, "default": { "$ref": "#/responses/error" } } } },Create an EntityIf the entity set allows inserts, the Path Item Object SHOULD contain the keyword post with an Operation Object as value that describes the capabilities for creating new entities. The tags array of the Operation Object SHOULD include the entity set name.The parameters array MUST contain a Parameter Objects for the request body that SHOULD reference the schema of the entity set’s entity type in the global definitions. The responses object SHOULD contain a name/value pair for the success case (HTTP response code 201) describing the structure of the success response, referencing the schema of the entity set’s entity type in the global definitions. If the service supports the preference return=minimal, it SHOULD contain a name/value pair for the HTTP response code 204. In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global responses.Example SEQ Example \* ARABIC 18: POST operation for an entity set "post": { "summary": "Add new entity to Products", "tags": [ "Products" ], "parameters": [ { "name": "Product", "in": "body", "description": "New entity", "schema": { "$ref": "#/definitions/ODataDemo.Product" } } ], "responses": { "201": { "description": "Created entity", "schema": { "$ref": "#/definitions/ODataDemo.Product" } }, "default": { "$ref": "#/responses/error" } } } }}Retrieve an EntityThe Path Item Object for individual entities in the entity set SHOULD contain the keyword get with an Operation Object as value that describes the capabilities for retrieving a single entity. The tags array of the Operation Object SHOULD include the entity set name.Example SEQ Example \* ARABIC 19: GET operation for an individual entity"/Products('{ID}')": { "get": { "summary": "Get entity from Products by key", "tags": [ "Products" ],The parameters array MUST contain a Parameter Object for each key property, and it SHOULD contain specific Parameter Objects for the system query options $select and $expand if these are allowed.The Parameter Objects describing the allowed key values MUST use the same type mapping as described for primitive properties in section REF _Ref451354600 \r \h 4.10.2.1, with the exception that for key properties of type Edm.Decimal the type keyword has the value "number". Example SEQ Example \* ARABIC 20: GET operation for an individual entity - parameters "parameters": [ { "name": "ID", "in": "path", "required": true, "description": "key: ID", "type": "string" }, { "name": "$select", "in": "query", "description": "Select properties to be returned, see [OData Select]()", "type": "array", "uniqueItems": true, "items": { "type": "string" }, "enum": [ "ID", "Description", "ReleaseDate", "DiscontinuedDate", "Rating", "Price", "Currency" ] }, { "name": "$expand", "in": "query", "description": "Expand related entities, see [OData Expand]()", "type": "array", "uniqueItems": true, "items": { "type": "string" }, "enum": [ "*", "Category", "Supplier" ] } ],The responses object SHOULD contain a name/value pair for the success case (HTTP response code 201) describing the structure of the success response, referencing the schema of the entity set’s entity type in the global definitions. In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global responses.Example SEQ Example \* ARABIC 21: GET operation for an individual entity - responses "responses": { "200": { "description": "Retrieved entity", "schema": { "$ref": "#/definitions/ODataDemo.Product" } }, "default": { "$ref": "#/responses/error" } } } },Update an EntityIf the entity set allows updates, the Path Item Object for individual entities in the entity set SHOULD contain the keyword patch with an Operation Object as value that describes the capabilities for updating entities. The tags array of the Operation Object SHOULD include the entity set name.The parameters array MUST contain a Parameter Object for each key property, using the same type mapping as described for primitive properties in section REF _Ref451354600 \r \h 4.10.2.1, with the exception that for key properties of type Edm.Decimal the type keyword has the value "number". The responses object SHOULD contain a name/value pair for the success case (HTTP response code 204). If the service supports the preference return=representation, it SHOULD contain a name/value pair for the HTTP response code 200 describing the structure of the success response, referencing the schema of the entity set’s entity type in the global definitions. In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global responses.Example SEQ Example \* ARABIC 22: PATCH operation for an individual entity "patch": { "summary": "Update entity in Products", "tags": [ "Products" ], "parameters": [ { "name": "ID", "in": "path", "required": true, "description": "key: ID", "type": "string" }, { "name": "Product", "in": "body", "description": "New property values", "schema": { "$ref": "#/definitions/ODataDemo.Product" } } ], "responses": { "204": { "description": "Success" }, "default": { "$ref": "#/responses/error" } } } },Delete an EntityIf the entity set allows deletion of entities, the Path Item Object for individual entities in the entity set SHOULD contain the keyword delete with an Operation Object as value that describes the capabilities for deleting entities. The tags array of the Operation Object SHOULD include the entity set name.The parameters array MUST contain a Parameter Object for each key property, using the same type mapping as described for primitive properties in section REF _Ref451354600 \r \h 4.10.2.1, with the exception that for key properties of type Edm.Decimal the type keyword has the value "number". The responses object SHOULD contain a name/value pair for the success case (HTTP response code 204). In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global responses.Example SEQ Example \* ARABIC 23: DELETE operation for an individual entity "delete": { "summary": "Delete entity from Products", "tags": [ "Products" ], "parameters": [ { "name": "ID", "in": "path", "required": true, "description": "key: ID", "type": "string" }, { "name": "If-Match", "in": "header", "description": "ETag", "type": "string" } ], "responses": { "204": { "description": "Success" }, "default": { "$ref": "#/responses/error" } } } }}Invoke Bound Actions and Bound FunctionsIf the service defines bound actions or functions applicable to the entity set or its entities, these MAY be described as additional name/value pairs …The HYPERLINK "" \l "pathItemObject" Path Item Object for a bound action MUST contain the keyword post, the HYPERLINK "" \l "pathItemObject" Path Item Object for a bound function MUST contain the keyword get. The value of the operation keyword is an HYPERLINK "" \l "operationObject" Operation Object that describes how to invoke the action or function. The tags array of the HYPERLINK "" \l "operationObject" Operation Object SHOULD include the entity set name.Example SEQ Example \* ARABIC 24: action bound to entity within a set – summary and tags"/LeaveRequests({ID})/OData.Demo.Rejection": { "post": { "summary": "Invoke action Rejection", "tags": [ "LeaveRequests" ],For actions and functions bound to a single entity within an entity set the parameters array MUST contain a HYPERLINK "" \l "parameterObject" Parameter Object for each key property, using the same type mapping as described for primitive properties in section REF _Ref451354600 \r \h 4.10.2.1, with the exception that for key properties of type Edm.Decimal the type keyword has the value "number". For bound actions the parameters array MUST contain a HYPERLINK "" \l "parameterObject" Parameter Object describing the structure of the request body. Its schema value MUST follow the rules for HYPERLINK "" \l "schemaObject" Schema Objects for complex types described in section REF _Ref456352935 \r \h 4.10.1, with one property per non-binding action parameter. For bound functions the parameters array MUST contain a HYPERLINK "" \l "parameterObject" Parameter Object for each non-binding parameter. Primitive parameters MUST use the same type mapping as described for primitive properties in section REF _Ref451354600 \r \h 4.10.2.1, with the exception that for parameters of type Edm.Decimal the type keyword has the value "number". Structured or collection-valued parameters MUST be represented as a parameter alias in the path template and the parameters array MUST contain a HYPERLINK "" \l "parameterObject" Parameter Object for the parameter alias as a query option of type string. The parameter description SHOULD describe the format this URL-encoded JSON object or array, and/or reference to [ REF odataURL \h OData-URL], section HYPERLINK "" \l "_Complex_and_Collection" 5.1.1.11.2.Depending on the result type of the bound action or function the parameters array SHOULD contain specific HYPERLINK "" \l "parameterObject" Parameter Objects for the allowed system query options.Example SEQ Example \* ARABIC 25: action bound to entity within a set – parameters Example SEQ Example \* ARABIC 20: … "parameters": [ { "name": "ID", "in": "path", "required": true, "description": "key: ID", "type": "integer", "format": "int32" }, { "name": "body", "in": "body", "description": "Action parameters", "schema": { "type": "object", "properties": { "Reason": { "type": [ "string", "null" ], "x-nullable": true } } } } ],The responses object SHOULD contain a name/value pair for the success case (HTTP response code 204). In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global HYPERLINK \l "_Keyword_responses" responses.Example SEQ Example \* ARABIC 26: action bound to entity within a set – responses "responses": { "204": { "description": "Success" }, "default": { "$ref": "#/responses/error" } } }}…SingletonsEach singleton is represented as a name/value pair whose name is the service-relative resource path of the singleton prepended with a forward slash, and whose value is Path Item Object describing the allowed operations on this singleton.If the service defines bound actions or functions applicable to singleton, these MAY be described as additional name/value pairs.All operations for a singleton SHOULD be tagged with the name of the entity set for consistent grouping in OpenAPI tools.If the service defines bound actions or functions applicable to the singleton, these MAY be described as additional name/value pairs with corresponding path templates for action/function invocation.Retrieve a SingletonThe Path Item Object for a singleton SHOULD contain the keyword get with an Operation Object as value that describes the capabilities for retrieving the singleton, unless the singleton is write-only. The tags array of the Operation Object SHOULD include the singleton’s name.The parameters array SHOULD contain specific Parameter Objects for the system query options $select and $expand if these are allowed.The responses object SHOULD contain a name/value pair for the success case (HTTP response code 200) describing the structure of the success response, referencing the schema of the singleton’s entity type in the global definitions. In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global responses.Example SEQ Example \* ARABIC 27: GET operation for a singleton"/MainSupplier": { "get": { "summary": "Get MainSupplier", "tags": [ "MainSupplier" ], "parameters": [ { "name": "$select", "in": "query", "description": "Select properties to be returned, see [OData Select]()", "type": "array", "uniqueItems": true, "items": { "type": "string" }, "enum": [ "ID", "Name", "Address", "Concurrency" ] }, { "name": "$expand", "in": "query", "description": "Expand related entities, see [OData Expand]()", "type": "array", "uniqueItems": true, "items": { "type": "string" }, "enum": [ "*", "Products" ] } ], "responses": { "200": { "description": "Retrieved entity", "schema": { "$ref": "#/definitions/ODataDemo.Supplier" } }, "default": { "$ref": "#/responses/error" } } },Update a SingletonThe Path Item Object for a singleton SHOULD contain the keyword patch with an Operation Object as value that describes the capabilities for updating the singleton, unless the singleton is read-only. The tags array of the Operation Object SHOULD include the singleton’s name.The responses object SHOULD contain a name/value pair for the success case (HTTP response code 204). If the service supports the preference return=representation, it SHOULD contain a name/value pair for the HTTP response code 200 describing the structure of the success response, referencing the schema of the singleton’s entity type in the global definitions. In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global responses.Example SEQ Example \* ARABIC 28: PATCH operation for a singleton "patch": { "summary": "Update MainSupplier", "tags": [ "MainSupplier" ], "parameters": [ { "name": "Supplier", "in": "body", "description": "New property values", "schema": { "$ref": "#/definitions/ODataDemo.Supplier" } } ], "responses": { "204": { "description": "Success" }, "default": { "$ref": "#/responses/error" } } }}Action ImportsEach action import is represented as a name/value pair whose name is the service-relative resource path of the action import prepended with a forward slash, and whose value is a Path Item Object containing the keyword post with an Operation Object as value that describes how to invoke the action import.If the actionfunction import specifies the EntitySet attribute, the tags array of the Operation Object SHOULD include the entity set name.… body parameterThe parameters array MUST contain a HYPERLINK "" \l "parameterObject" Parameter Object describing the structure of the request body. Its schema value MUST follow the rules for HYPERLINK "" \l "schemaObject" Schema Objects for complex types described in section REF _Ref456352935 \r \h 4.10.1, with one property per action parameter. The responses object SHOULD contain a name/value pair for the success case (HTTP response code 200) describing the structure of the success response, ideally by referencing an appropriate schema in the global HYPERLINK \l "_Keyword_definitions_1" definitions. In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global HYPERLINK \l "_Keyword_responses" responses.… responsesExample SEQ Example \* ARABIC 29: action import…"/IncreaseSalaries": { "post": { "summary": "Invoke action IncreaseSalaries", "tags": [ "Service Operations" ], "parameters": [ { "name": "body", "in": "body", "description": "Action parameters", "schema": { "type": "object", "properties": { "percentage": { "type": [ "number", "string" ], "format": "decimal", "x-scale": "variable" } } } } ], "responses": { "204": { "description": "Success" }, "default": { "$ref": "#/responses/error" } } }}…Function ImportsEach function import is represented as one name/value pair per unbound function overload whose name is the service-relative resource path template of the function overload, and whose value is a Path Item Object containing the keyword get with an Operation Object as value that describes how to invoke the function overload.If the function import specifies the EntitySet attribute, the tags array of the Operation Object SHOULD include the entity set name.The parameters array MUST contain a Parameter Object for each parameter of the function overload, and it SHOULD contain specific Parameter Objects for the allowed system query options.The Parameter Objects describing for primitive the allowed parameters values MUST use the same type mapping as described for primitive properties in section REF _Ref451354600 \r \h 4.10.2.1, with the exception that for parameters of type Edm.Decimal the type keyword has the value "number". Structured or collection-valued parameters MUST be represented as a parameter alias in the path template and the parameters array MUST contain a HYPERLINK "" \l "parameterObject" Parameter Object for the parameter alias as a query option of type string. The parameter description SHOULD describe the format this URL-encoded JSON object or array, and/or reference to [ REF odataURL \h OData-URL], section HYPERLINK "" \l "_Complex_and_Collection" 5.1.1.11.2.… structured and array-valued parametersThe responses object SHOULD contain a name/value pair for the success case (HTTP response code 200) describing the structure of the success response, ideally by referencing an appropriate schema in the global definitions. In addition it SHOULD contain a default name/value pair for the OData error response, ideally referencing the global responses.Example SEQ Example \* ARABIC 30: function import"/ProductsByRating(Rating={Rating})": { "get": { "summary": "Invoke function ProductsByRating", "tags": [ "Products" ], "parameters": [ { "name": "Rating", "in": "path", "required": true, "type": "integer", "x-nullable": true, "format": "int32" } ], "responses": { "200": { "description": "Success", "schema": { "title": "Result", "type": "object", "properties": { "value": { "type": "array", "items": { "$ref": "#/definitions/ODataDemo.Product" } } } } }, "default": { "$ref": "#/responses/error" } } } }}Keyword definitionsThe value of definitions is a Definitions Object, see [ REF OpenAPIspec \h OpenAPI]. Each entity type, complex type, enumeration type, and type definition defined in the CSDL document MUST be represented as a name/value pair of the Definitions Object.The name of each pair is the namespace-qualified name of the type. It uses the namespace instead of the alias because these definitions can be reused by other CSDL documents, and aliases are document-local, so they are meaningless for referencing documents.The value of each pair is a Schema Object, see [ REF OpenAPIspec \h OpenAPI].Example SEQ Example \* ARABIC 31: Definitions"definitions":{ "ODataDemo.Product": …, "ODataDemo.Category": …, "ODataDemo.Supplier": …, "ODataDemo.Country": …, "ODataDemo.Address": …, "org.example.Employee": …, "org.example.Manager": …}Entity Types and Complex TypesA structured type without a base type is represented as a Schema Object of type object.A structured type with a base type is represented as a Schema Object that contains the keyword allOf whose value is an array with two items: a JSON Reference to the definition of the base type, and a Schema Object describing the derived type. In addition it contains a name/value pair x-baseType whose value is the namespace-qualified name of the base type.The Schema Object describing the (derived) type contains the standard OpenAPI Specification keywords appropriate for type object. It MUST NOT contain the additionalProperties keyword in order to allow additional properties beyond the declared properties. This is necessary for inheritance as well as annotations and dynamic properties, and is in line with the model versioning rules defined in [OData-Protocol].In addition it MAY contain the extension keywords xabstract and xopenType, and for entity types also xmediaEntity and xkeys. The xabstract, xopenType, and xmediaEntity keywords pairs have Boolean values. If not present, their value is false. They correspond to the Abstract, OpenType, and HasStream attributes defined in [OData-CSDL].The value of xkeys is an array with one item per key property. An array is used to preserve the order of the key properties. If the key property has a key alias, the item is an object with one name/value pair, the name is the key alias and the value is the property path. For abstract entity types that neither specify a base type nor a key the value of xkeys is an empty array. The Schema Object MAY contain the keyword xannotations whose value is an object containing annotations.Example SEQ Example \* ARABIC 32: Product entity type"ODataDemo.Product":{ "type":"object", "x-mediaEntity":true, "x-keys":[ "ID" ], "properties": …, …}Example SEQ Example \* ARABIC 33: Manager entity type inheriting from Employee"org.example.Manager":{ "type":"object", "x-baseType":"org.example.Employee", "allOf":[ { "$ref":"#/definitions/org.example.Employee" }, { … } ]}Example SEQ Example \* ARABIC 34: Category entity type with key alias"org.example.Category18": { "type": "object", "x-keys": [ { "EntityInfoID": "Info/ID" } ], …}PropertiesEach structural property and navigation property is represented as a name/value pair of the standard OpenAPI properties object. The name is the property name, the value is a Schema Object describing the allowed values of the property.The Schema Object MAY contain the keyword xannotations whose value is an object containing annotations.Example SEQ Example \* ARABIC 35: structural and navigation properties of Supplier entity type"ODataDemo.Supplier":{ …, "properties":{ "ID":…, "Name":…, "Address":…, "Concurrency":…, "Products":… }, …}Primitive PropertiesPrimitive properties of type Edm.PrimitiveType, Edm.Stream, and any of the Edm.Geo* types are represented as Schema Objects that are JSON References to definitions in the edm.json document. JSON References to Edm.Geo* MAY contain the name/value pair x-srid with a string value. All other primitive properties are represented as a Schema Object with the following OpenAPI Specification types, formats, and validation keywords:OData Primitive TypeOpenAPI SpecificationCommentTypeFormatKeywordsEdm.Binarystringbase64urlmaxLlengthx-byteLengthOData-specific formatmaxLength is maximum length of string representation, i.e. 4*ceil(x-byteMaxLength/3) x-byteLength is the maximum length of the binary value in octetsEdm.BooleanbooleanEdm.Byteintegeruint8OData-specific formatEdm.DatestringdateOpenAPI formatEdm.DateTimeOffsetstringdate-timeprecisionOpenAPI formatOData-specific keywordEdm.Decimalnumber, stringdecimalminimum maximum multipleOfx-precision x-scaleOData-specific format string is needed for IEEE754Compatible modeOData-specific keywords x-precision and x-scaleEdm.Doublenumber[,string]doubleOpenAPI format with extended meaningstring is needed for -INF, INF, and NaNEdm.DurationstringdurationOData-specific formatEdm.GuidstringuuidOData-specific formatEdm.Int16 integerint16OData-specific formatEdm.Int32integerint32OpenAPI formatEdm.Int64integer, stringint64OpenAPI formatstring is needed for IEEE754Compatible modeEdm.SByteintegerint8OData-specific formatEdm.Singlenumber[,string]floatOpenAPI format with extended meaningstring is needed for -INF, INF, and NaNEdm.StringstringmaxLlengthSequence of UTF-8 charactersEdm.TimeOfDaystringtimex-precisionOData-specific format OData-specific keywordProperties of type Edm.Decimal and Edm.Int64 are represented as JSON strings if the format option IEEE754Compatible=true is specified, so they have to be declared with both number and string. Properties of type Edm.Decimal use OData-specific keywords x-precision and x-scale to represent the corresponding type facets. In addition a numeric scale value is represented with the OpenAPI Specification keyword multipleOf and a value of 10scale. The precision is represented with the maximum and minimum keywords and a value of ±(10precision-scale - 10scale) if the scale facet has a numeric value, and ±(10precision - 1) if the scale is variable).Properties of type Edm.Double and Edm.Single have special values for -INF, INF, and NaN that are represented as JSON strings, so they also have to be declared with both number and string. Services that do not support the special values -INF, INF, and NaN MAY omit the string keyword.The default value of a property is represented with the OpenAPI Specification keyword default.The Schema Object describing a property MAY contain the keyword xannotations whose value is an object containing annotations.Example SEQ Example \* ARABIC 36: non-nullable Boolean property with default value"BooleanValue":{ "type":"boolean", "default":false}Example SEQ Example \* ARABIC 37: non-nullable binary property with both maxLength and byteLength"BinaryValue":{ "type":"string", "format":"base64url", "maxLength":44, "byteLength":31, "default":"T0RhdGE"}Example SEQ Example \* ARABIC 38: non-nullable integer property"IntegerValue":{ "type":"integer", "format":"int32", "default":-128}Example SEQ Example \* ARABIC 39: non-nullable floating-point properties: string representation for -INF, INF, and NaN,"DoubleValue":{ "type":[ "number", "string" ], "format":"double", "default":3.1415926535897931},"SingleValue":{ "type":[ "number", "string" ], "format":"float"}Example SEQ Example \* ARABIC 40: non-nullable decimal property with unspecified precision: no minimum and maximum"DecimalValue":{ "type":[ "number", "string" ], "format":"decimal", "x-scale":"variable", "default":34.95}Example SEQ Example \* ARABIC 41: non-nullable decimal property with specified precision, minimum and maximum"FixedDecimalValue":{ "type":[ "number", "string" ], "format":"decimal", "x-precision":12, "x-scale":2, "multipleOf":0.01, "minimum":-999999999.99, "maximum":999999999.99}Example SEQ Example \* ARABIC 42: non-nullable string property with maximum length of 40 characters"StringValue":{ "type":"string", "maxLength":40 "default":"Say \"Hello\",\nthen go"}Example SEQ Example \* ARABIC 43: non-nullable date property"DateValue":{ "type":"string", "format":"date", "default":"2012-12-03"}Example SEQ Example \* ARABIC 44: non-nullable timestamp property with 7 fractional digits precision"DateTimeOffsetValue":{ "type":"string", "format":"date-time", "x-precision":7, "default":"2012-12-03T07:16:23:00.0000000Z"}Example SEQ Example \* ARABIC 45: non-nullable timestamp property with 12 fractional digits precision"DurationValue":{ "type":"string", "format":"duration", "x-precision":12, "default":"P12DT23H59M59.999999999999S"}Example SEQ Example \* ARABIC 46: non-nullable time property with 3 fractional digits precision"TimeOfDayValue":{ "type":"string", "format":"time", "x-precision":3, "default":"07:59:59.999"}Example SEQ Example \* ARABIC 47: non-nullable guid property with default value"GuidValue":{ "type":"string", "format":"uuid", "default":"1234567-89ab-cdef-0123-456789abcdef"}Example SEQ Example \* ARABIC 48: non-nullable 8-byte integer property, allowing for string representation in IEEE754Compatible mode"Int64Value":{ "type":[ "integer", "string" ], "format":"int64", "default":0}Example SEQ Example \* ARABIC 49: non-nullable enumeration property"ColorEnumValue":{ "$ref":"#/definitions/Model1.Color", "default":"yellow"},Example SEQ Example \* ARABIC 50: non-nullable geography-point property"GeographyPoint":{ "$ref":"", "default":{ "type":"Point", "coordinates":[ 142.1, 64.1 ] }}Example SEQ Example \* ARABIC 51: non-nullable stream property: not part of payload in version 4.0"StreamValue":{ "$ref":""}Example SEQ Example \* ARABIC 52: non-nullable property typed with a type definition"TypeDefValue":{ "$ref":"#/definitions/Model1.IntegerDecimal", "default":42}Example SEQ Example \* ARABIC 53: non-nullable primitive property with abstract type, e.g. in term definition"PrimitiveValue":{ "$ref":""}Complex PropertiesComplex properties are represented as JSON References to the definition of the complex type, either as local references for types directly defined in the CSDL document, or as external references for types defined in referenced CSDL documents.Example SEQ Example \* ARABIC 54: structural properties of Supplier entity type: a string property, a nullable string property, a complex property, and an integer property"properties":{ "ID":{ "type":"string" }, "Name":{ "type":[ "string", "null" ] }, "Address":{ "$ref":"#/definitions/ODataDemo.Address" }, "Concurrency":{ "type":"integer", "format":"int32" }, …}Navigation PropertiesNavigation properties are represented similar to complex properties so that a standard OpenAPI Specification validator can validate the expanded representation of the navigation property.Navigation properties contain the keyword xrelationship whose value is an object that MAY contain the keywords partner, onDelete, and referentialConstraints. The value of partner is the name of the partner navigation property. The value of onDelete is an object with a single name/value pair action whose value is one of the values Cascade, None, SetDefault, or SetNull defined in [OData-CSDL], section 7.3.1. The value of referentialConstraints is an object with one name/value pair per dependent property, using the dependend property name as name and an object as value. This object contains the keyword referencedProperty whose value is the name of the principal property. In addition this object MAY contain annotations.Example SEQ Example \* ARABIC 55: multi-valued navigation property Products with partner and on-delete constraint"Products":{ "type":"array", "items":{ "$ref":"#/definitions/ODataDemo.Product" }, "x-relationship":{ "partner":"Category", "onDelete":{ "action":"Cascade" } }}Example SEQ Example \* ARABIC 56: required single-valued navigation property Category"Category":{ "anyOf":[ { "$ref":"#/definitions/ODataDemo.Category" } ], "relationship":{}}Example SEQ Example \* ARABIC 57: nullable single-valued navigation property Country with referential constraint"Country":{ "anyOf":[ { "$ref":"#/definitions/ODataDemo.Country" }, { "type":"null" } ], "x-relationship":{ "referentialConstraints":{ "CountryName":{ "referencedProperty":"Name" } } }}Collection-Valued PropertiesCollection-valued structural and navigation properties are represented as Schema Objects of type array. The value of the items keyword is a Schema Object specifying the type of the items. Example SEQ Example \* ARABIC 58: collection-valued nullable string property Tags"Tags":{ "type":"array", "items":{ "type":[ "string", "null" ] }}Example SEQ Example \* ARABIC 59: collection-valued navigation property Products of Supplier entity type"Products":{ "type":"array", "items":{ "$ref":"#/definitions/ODataDemo.Product" }, "x-relationship":{ "partner":"Supplier" }}Nullable PropertiesNullable properties of primitive types except Edm.Stream and Edm.Geo* are represented with an array-valued type that consists of the corresponding OpenAPI Specification primitive type(s) and the null type. In addition they are marked with the keyword x-nullable whose value is true.Other nullable structural and navigation properties are represented as a Schema Object as described in the preceding section, with an additional keyword x-nullable whose value is true.Example SEQ Example \* ARABIC 60: nullable property Price of type Edm.Decimal with precision 15 and scale 3"Price":{ "type":["number","string","null"], "x-nullable":true, "format":"decimal", "x-precision":15, "x-scale":3, "multipleOf":1e-3, "minimum":-999999999999.999, "maximum":999999999999.999}Example SEQ Example \* ARABIC 61: nullable property Created of type Edm.DateTimeOffset with precision 6"Created":{ "type":["string","null"], "x-nullable":true, "format":"date-time", "x-precision":6}Example SEQ Example \* ARABIC 62: nullable collection-valued property Dates"Dates":{ "type":"array", "items":{ "type":["string","null"], "x-nullable":true, "format":"date" }},Example SEQ Example \* ARABIC 63: nullable navigation property Supplier"Supplier":{ "$ref":"#/definitions/ODataDemo.Supplier", "x-nullable":true, "x-relationship":{ "partner":"Products" }}Enumeration TypesAn enumeration type is represented as a Schema Object of type string containing the OpenAPI Specification enum keyword. Its value is an array that contains a string with the member name for each enumeration member.If the enumeration type allows multiple members to be selected simultaneously, the Schema Object contains the keyword x-isFlags pair with a value of true.The Schema Object contains the keyword xannotations whose value is an object containing annotations.The numeric value of each enumeration member is represented as an annotation on the member with the term value.Annotations on enumeration members are represented as name/value pairs whose name is the member name, followed by an at (@) sign, followed by the namespace-qualified term name, and optionally followed by a hash (#) sign and the qualifier. The annotation value is represented according to the rules defined in this specification.The x-annotations object MAY contain additional annotations. Example SEQ Example \* ARABIC 64: enumeration type with exclusive members and annotations on members and on the type"org.example.ShippingMethod":{ "type":"string", "enum":[ "FirstClass", "TwoDay", "Overnight" ], "x-annotations"p:{ "FirstClass@Core.Description":"Shipped with highest priority", "TwoDay@Core.Description":"Shipped within two days", "Overnight@Core.Description":"Shipped overnight" "description":"Method of shipping" }}Example SEQ Example \* ARABIC 65: enumeration type with flag values"org.example.Pattern":{ "type":"string", "enum":[ "Plain", "Red", "Blue", "Yellow", "Solid", "Striped", "SolidRed", "SolidBlue", "SolidYellow", "RedBlueStriped", "RedYellowStriped", "BlueYellowStriped" ], "x-isFlags":true, "x-annotations":{ "Plain@value":0, "Red@value":1, "Blue@value":2, "Yellow@value":4, "Solid@value":8, "Striped@value":16, "SolidRed@value":9, "SolidBlue@value":10, "SolidYellow@value":12, "RedBlueStriped@value":19, "RedYellowStriped@value":21, "BlueYellowStriped@value":22 }}Type Definitions A type definition is represented as a Schema Object describing the allowed values of the type definition using the same rules as for primitive properties.The Schema Object MAY contain the keyword xannotations whose value is an object containing annotations.Example SEQ Example \* ARABIC 66: type definitions based on Edm.String, Edm.Decimal and Edm.DateTimeOffset"Model1.Text50":{ "type":"string", "maxLength":50},"Model1.VariableDecimal":{ "type":"number", "description":"A type definition"},"Model1.ExactTimestamp":{ "type":"string", "format":"date-time", "x-precision":12}Keywords x-actions and x-functionsThe x-actions and x-functions objects contain one name/value pair for each action/function name defined in the CSDL document. The name is the namespace-qualified action/function name, the value is an array with one action/function description object for each overload for this name. An action/function description object contain the keywords entitySetPath, isBound, parameters, and returnType. Objects representing functions in addition MAY contain the keyword isComposable with a Boolean value.The value of entitySetPath is a string.The values of isBound and isComposable are Boolean. The value of parameters is an array with one object per parameter. It contains the keyword name for the parameter name and the keyword parameterType whose value is a Schema Object describing the allowed parameter values. It has the same structure as the Schema Object for a property.The value of returnType is a Schema Object describing the allowed return values. It has the same structure as the Schema Object for a property.All objects MAY contain annotations.Example SEQ Example \* ARABIC 67: action Rejection with two overloads and function Foo with one overload and no parameters"x-actions":{ "Model1.Rejection":[ { "isBound":true, "parameters":[ { "name":"foo", "parameterType":{ "$ref":"#/definitions/Model.One.Waldo" } } ] }, { "isBound":true, "parameters":[ { "name":"bar", "parameterType":{ "$ref":"#/definitions/Model.One.Waldo" } }, { "name":"Reason", "parameterType":{ "type":"string" } } ] } ]},"x-functions":{ "Model1.Foo":[ { "parameters":[ ], "returnType":{ "type":"string", "maxLength":42 } } ]}Keyword x-entityContainerThe entity container of an OData service describes the top-level addressable resources of that service. From this information an OData client can construct all potentially valid URLs for that service by applying the OData URL Conventions [ REF odataURL \h OData-URL]. The value of x-entityContainer is an object that contains the keywords name and resources. The value of name is a string containing the entity container name.The value of resources is an object with one name/value pair per entity container child. The name of each pair is the child's unqualified name, the value is an object.Each child object contains the keyword kind with a string value of either EntitySet, Singleton, ActionImport, or FunctionImport.An object describing an entity set MUST contain the keyword entityType whose value is a JSON Reference to the namespace-qualified name of the declared entity type of the entity set. In addition it MAY contain the keyword navigationPropertyBindings whose value is an object with one name/value pair per navigation property that has a binding. The name is the path to the navigation property, the value is a string with the name of the target entity set. If the target entity set is a child of the same entity container, the unqualified name is used, otherwise the namespace-qualified name.An object describing a singleton MUST contain the keyword type whose value is the namespace-qualified name of a JSON Reference to the entity type of the singleton. It MAY contain the keyword navigationPropertyBindings with the same structure as in objects describing an entity set.An object describing an action import MUST contain the keyword action whose value is the namespace-qualfied name of the action triggered by this action import. It MAY contain the keyword entitySet whose value is the name of the entity set containing the entity or entities returned by the action.An object describing a function import MUST contain the keyword function whose value is the namespace-qualified name of the function triggered by this function import. It MAY contain the keyword entitySet whose value is the name of the entity set containing the entity or entities returned by the function. If the function has no parameters, it also MAY have an includeInServiceDocument name/value pair with a Boolean value.The entity container object and each entity-container child object MAY contain annotations. Example SEQ Example \* ARABIC 68: entity container object"x-entityContainer":{ "name":"DemoService", "resources":{ "Products":{ "kind":"EntitySet", "entityType":"ODataDemo.Product", "type":"array","items":{ "$ref":"#…/definitions…/ODataDemo.Product" }, "navigationPropertyBindings":{ "Category":"Categories" } }, "Categories":{ "kind":"EntitySet", "entityType":{ "$ref":"#/definitions/"ODataDemo.Category" }, "navigationPropertyBindings":{ "Products":"Products" } }, "Suppliers":{ "kind":"EntitySet", "entityType"::{ "$ref":"#/definitions/"ODataDemo.Supplier" }, "navigationPropertyBindings":{ "Products":"Products", "Address/Country":"Countries" }, "@Core.OptimisticConcurrency":[ { "@odata.@propertyPath":"Concurrency" } ] }, "Countries":{ "kind":"EntitySet", "entityType":{ "$ref":"#/definitions/"ODataDemo.Country" } }, "Contoso":{ "kind":"Singleton", "type":{ "$ref":"#/definitions/"SelfODataDemo.Supplier" }, "navigationPropertyBindings":{ "Products":"Products" } }, "ProductsByRating":{ "kind":"FunctionImport", "entitySet":"Products", "function":"ODataDemo.ProductsByRating" } } }}Keyword x-termsThe value of x-terms is an object containing one name/value pair per term defined within the CSDL document. The name of each pair is the term's namespace-qualified name, the value is a Schema Object describing the type of the term. It has the same structure as the Schema Object for a property, and in addition MAY contain the keyword baseTerm whose value is the namespace-qualified name of the base term, and the keyword appliesTo whose value is either a string or an array of strings specifying the model element(s) the term can be applied to.All Schema Objects describing a term MAY contain annotations which are directly contained in the object without an x-annotations wrapper. Example SEQ Example \* ARABIC 69: term definition"x-terms":{ "Core.IsURL":{ "$ref":"#/definitions/Org.OData.Core.V1.Tag" "x-nullable":true "default": true, "appliesTo": [ "Property", "Term" ], "description": "Properties and terms annotated with this term MUST contain a valid URL", "@Core.RequiresType": "Edm.String" }, "Core.OptimisticConcurrency": { "type": "array", "items": { "$ref": "" }, "appliesTo": "EntitySet", "description": "Data modification requires the use of Etags. A non-empty collection contains the set of properties that are used to compute the ETag" }, "Y.Developer":{ "$ref":"#/definitions/Y.DeveloperType" "baseTerm":"X.Person" }}Keyword x-schemasOData schemas defined or included in the CSDL document are represented with the keyword xschemas whose value is an object that contains one name/value pair per OData schema defined or included in the CSDL document, and one name/value pair per defined alias.. For aliases the name is the alias, and the value is an object containing the keyword aliasFor whose value is the namespace of the aliased schema.For OData schemas defined in the document the name is the namespace of the schema, and the value is an object that MAY contain the keyword annotations and that also MAY contain annotations for the schema itself.For included OData schemas the name is the namespace of the schema, and the value is an object containing the keyword uri whose value is the URI of the referenced CSDL document describing the included schema.Example SEQ Example \* ARABIC 70: schemas"x-schemas":{ "SomeAlias":{ "aliasFor":"Some.DocumentDefined.Model" }, "Some.Included.Schema":{ "uri":"" }, "AnotherAlias":{ "aliasFor":"Some.Included.Schema" }, "Some.DocumentDefined.Model":{ "annotations": …, "@Annotation.With.Some.Term": … }}Keyword x-referencesReferences to other CSDL documents are represented with the keyword x-references whose value is an object with one name/value pair per referenced CSDL document. The name is the URI of the referenced CSDL document. Its value is an object that MAY contain the keyword includeAnnotations and that also MAY contain annotations.Example SEQ Example \* ARABIC 71: references"x-references": { "": { "@Some.Term": … }, "": { "includeAnnotations": … }}Keyword includeAnnotationsThe value of the includeAnnotations name/value pair is an object. It contains one name/value pair per included term namespace whose name is the term namespace and whose value is an array of objects. Each object in this array MAY have name/value pairs targetNamespace and qualifier. The values of these name/value pairs are strings.Example SEQ Example \* ARABIC 72: includeAnnotations"includeAnnotations":{ "Name.Space":[ { "targetNamespace": "Target.Space" }, { "targetNamespace": "Target.Space", "qualifier": "SomeName" }, { "qualifier": "SomeName" }, { } ]}AnnotationsAnnotations can appear inline within a model element, or externally as a group that targets a model element. Keyword annotationsAnnotations with external targeting are represented within their defining OData schema with the keyword annotations whose value is an object. It contains name/value pairs whose name is a path expression identifying the annotated model element and whose value is an object containing the annotations for the annotated model element in the same format that is used for inline annotations.Example SEQ Example \* ARABIC 73: Annotations with external targeting"annotations":{ "Some.EntityType/SomeProperty":{ "@X.Y":…, … }, "Another.EntityType":{ "@X.Y":…, … }, …}Inline AnnotationsAnnotations are represented similar to instance annotations in [OData-JSON], chapter 18.Annotations for JSON objects are name/value pairs placed within the object, the name is an at (@) sign followed by the namespace-qualified name of the term, optionally followed by a hash (#) sign and the qualifier of the annotation.Annotations for JSON arrays or primitives are name/value pairs placed next to the name/value pair whose value is the annotated array or primitive value. The name is the name of the annotated name/value pair followed by an at (@) sign, followed by the namespace-qualified name of the term, optionally followed by a hash (#) sign and the qualifier of the annotation.The value of the annotation is either a plain JSON value or a JSON object.Example SEQ Example \* ARABIC 74: annotation within an object, annotation of a non-object value, and annotation of an annotation"@Some.Term" : …,"Hugo@Some.Term" : …,"@Some.Term#SomeQualifier@Some.Term": …Annotations always specify an explicit value, even if the term definition specifies a default value. This is consistent with the representation of instance annotations in JSON payloads and an intentional difference to the XML representation of annotations. Constant ExpressionsConstant expressions edm:Bool and edm:String are represented as plain JSON values as defined in [OData-JSON], section 7.1. Example SEQ Example \* ARABIC 75"@A.Binary":"T0RhdGE","@A.Boolean" : true,"@A.Date":"2013-10-09","@A.DateTimeOffset":"2000-01-01T16:00:00.000Z","@A.Decimal":12.34,"@A.Duration":"P7D","@An.EnumMember":"Red,Striped","@A.Float":1.23e4,"@A.Float#inf": "INF","@A.Float#minusInf":"-INF","@A.Float#nan":"NaN","@A.Guid":"86a96539-871b-45cf-b96b-93dbc235105e","@An.Int": 42"@A.String":"plain text","@A.String#withAmp":"Fast&Furious","@A.String#ToBeEscaped":"A/\"good\"\r\nstory\\for\tkids","@A.TimeOfDay":"21:45:00",Path ExpressionsThe expressions edm:AnnotationPath, edm:NavigationPropertyPath, edm:Path, and edm:PropertyPath are represented similar to individual properties or operation responses in [OData-JSON], chapter 11, as a JSON object with a name/value pair @odata.@annotationPath, @odata.@navigationPath, @odata.@path, or @odata.@propertyPath whose value is a string containing the path expression. Example SEQ Example \* ARABIC 76: annotation with edm:Path dynamic expression"@Org.OData.Measures.V1.ISOCurrency":{? "@odata.@path":"Currency"}Collection ExpressionsThe dynamic expression edm:Collection is represented as a JSON array. Its items are representations of its child expressions according to the rules defined in this specification.Record ExpressionsThe dynamic expression edm:Record is represented as a JSON object. The Type attribute of the edm:Record expression is represented as an @odata.@type annotation. Each edm:PropertyValue child element is represented as a name/value pair with the value of the Property attribute as name. Its value expression is represented according to the rules defined in this specification. It MAY also contain annotations.Example SEQ Example \* ARABIC 77: annotation with edm:Record dynamic expression, one Boolean edm:PropertyValue and one with an edm:Collection value"@Capabilities.UpdateRestrictions":{ "Updatable":true, "NonUpdatableNavigationProperties":[ { "@odata.@navigationPropertyPath":"Supplier" }, { "@odata.@navigationPropertyPath":"Category" } ]}Comparison and Logical Operators and If ExpressionThe dynamic expression edm:If and the logical expressions edm:Eq, edm:Ne, edm:Ge, edm:Gt, edm:Le, edm:Lt, edm:And, and edm:Or are represented are represented as a JSON object with a name/value pair @odata.@if, @odata.@eq etc. whose value is a JSON array with items that are representations of the child expressions according to the rules defined in this specification. They MAY also contain annotations.Example SEQ Example \* ARABIC 78: edm:If expression using an edm:Path expression as its condition and evaluating to one of two edm:String expressions"@org.example.display.DisplayName":{ "@odata.@if":[ { "@odata.@path":"IsFemale" }, "Female", "Male" ]}Expression ApplyThe dynamic expression edm:Apply is represented as a JSON object with an @odata.@apply name/value pair whose value is an object with a function name/value pair with the function name as its string value. The child expressions are represented as a parameterValues name/value pair whose value is an array with items that are representations of the child expressions according to the rules defined in this specification.It MAY also contain annotations.Example SEQ Example \* ARABIC 79: edm:Apply expression with two edm:String expressions and one edm:Path expression as parameter values"@puted.Url":{ "@odata.@apply":{ "function":"odata.concat", "parameterValues":[ "Products(", { "@odata.@path":"ID" }, ")" ] }}Expressions Cast and IsOfThe dynamic expressions edm:Cast and edm:IsOf are represented as JSON objects with a name/value pair @odata.@cast or @odata.@isOf whose value is a string with a qualified type name. The facet attributes are represented as name/value pairs maxLength, precision, scale, and srid. The child expression is represented as the value of a value name/value pair according to the rules defined in this specification.They MAY also contain annotations.Example SEQ Example \* ARABIC 80: edm:IsOf expression using an edm:Path expression as its parameter"@For.Testing":{ "@odata.@isOf":"Edm.Binary", "value":{ "@odata.@path":"ImageData" }}Expression LabeledElementThe dynamic expression edm:LabeledElement is represented as a JSON object with an @odata.@labeledElement name/value pair whose value is a string with the qualified name of the labeled element. Its single child expression is represented as a value name/value pair whose value is the representation of the child expression according to the rules defined in this specification. It MAY also contain annotations.Example SEQ Example \* ARABIC 81: edm:LabeledElement expression{ "@odata.@labeledElement":"Model.MyReusableAnnotation", "value":…,}Expression LabeledElementReferenceThe dynamic expression edm:LabeledElementReference is represented as a JSON object with an @odata.@labeledElementReference name/value pair whose value is a string with the qualified name of the referenced labeled element.Example SEQ Example \* ARABIC 82: edm:LabeledElementReference expression{ "@odata.@labeledElementReference":"Model.MyReusableAnnotation"}Expression NotThe dynamic expression edm:Not is represented as a JSON object with an @odata.@not name/value pair whose value is the representation of the child expression according to the rules defined in this specification.It MAY also contain annotations.Example SEQ Example \* ARABIC 83: edm:Not expression "@Some.Term": { "@odata.@not":{ "@odata.@path":"IsHappy" }}Expression NullThe dynamic expression edm:Null can appear in positions that are represented as array items or values of name/value pairs in JSON, so it has to be represented as a single JSON primitive or object.If the dynamic expression edm:Null does not contain annotations, it is represented simply as the JSON null value.Example SEQ Example \* ARABIC 84: edm:Null expression without nested annotations"@Some.Term":null,If it does contain annotations, it is represented as a JSON object with an @odata.@null name/value pair whose value is an object that contains the annotations.Example SEQ Example \* ARABIC 85: edm:Null expression with nested annotations"@Some.Term":{ "@odata.@null":{ "@Within.Null":true }}Expression UrlRefThe dynamic expression edm:UrlRef is represented as a JSON object with an @odata.@urlRf name/value pair whose value is either a string containing the URL or an object representing the non-constant child expression according to the rules defined in this specification.It MAY also contain annotations.Example SEQ Example \* ARABIC 86: edm:UrlRef expressions with edm:String value and with edm:Path value"@Good.Reference#one":{ "@odata.@urlRef":""},"@Good.Reference#two":{ "@odata.@urlRef":{ "@odata.@path":"DocumentationUrl" }}Annotation Core.DescriptionThe annotation Core.Description (see [OData-VocCore]) semantically corresponds to the OpenAPI Specification keyword description, so unqualified annotations with Core.Description that have a constant string value are represented with this keyword. Qualified annotations and annotations with dynamic values are represented as other annotations.Example SEQ Example \* ARABIC 87: unqualified constant Core.Description as description"org.example.Size": { "enum": [ "S", "M", "L" ], "S@Core.Description": "Small", "M@Core.Description": "Medium", "L@Core.Description": "Large", "description": "T-Shirt Size", "@Core.Description#alt": "Size (S, M, L)", "@Core.LongDescription": "Size, expressed with letters familiar from e.g. T-Shirt sizes", },Extensions to the OpenAPI SpecificationThe edm.json DocumentThe edm.json document defines reuse types for CSDL JSON documents as well as the syntax of the OData extension keywords.The definitions object contains one name/value pair per reuse type, e.g. the OData primitive types and the standard OData error response, as well as types used for describing the extension keywords. The properties object contains one name/value pair per extension keyword whose value is a Schema Object.The parameters object contains one name/value pair per OData system query option referring to the formal specification of that query option.KeywordsOData CSDL contains many concepts that cannot be translated into OpenAPI concepts, these are represented using the custom keywords. On the document root level these are x-actionsx-entityContainerx-functionsx-odata-versionx-references x-schemasx-termsSchema Objects of type object MAY use the keywordsx-abstractx-keysx-mediaEntityx-openTypex-relationship Schema Objects for primitive types MAY use the keywords x-nullablex-precisionx-scalex-sridFormatsNot all constraints on values of OData primitive types can be expressed with OpenAPI means, and the format keyword of the OpenAPI specification allows defining new values. CSDL JSON documents use the following formats:FormatOData TypeCommentbase64urlEdm.BinaryOData-specific format dateEdm.DateOpenAPI format, was part of JSON Schema Draft 03decimalEdm.DecimalOData-specific formatdoubleEdm.DoubleOpenAPI format extended with -INF, INF, NaNdurationEdm.DurationOData-specific formatint16Edm.Int16 OData-specific formatint32Edm.Int32OpenAPI formatint64Edm.Int64OpenAPI formatint8Edm.SByteOData-specific formatsingleEdm.SingleOData-specific formattimeEdm.TimeOfDayOData-specific format, was part of JSON Schema Draft 03uint8Edm.ByteOData-specific formatuuidEdm.GuidOData-specific formatPayload ValidationThe OpenAPI Specification uses a subset of JSON Schema for describing the structure of JSON request and response bodies as HYPERLINK "" \l "schemaObject" Schema Objects below the HYPERLINK \l "_Keyword_definitions_1" definitions keyword. These HYPERLINK "" \l "schemaObject" Schema Objects can – with some limitations – be used to validate OData JSON request and response bodies.LimitationsThe most severe limitation is the omission of anyOf from the OAS subset of JSON Schema. This makes it impossible to fully describe nullable complex properties or nullable navigation properties in HYPERLINK "" \l "schemaObject" Schema Objects as being either null or having an object value that conforms to a specific schema. Off-the-shelf JSON Schema validators will consequently report a null value of a nullable complex or navigation property as an error.Nullability is instead expressed with the extension keyword x-nullable, so JSON Schema validators can be extended to evaluate this extension keyword and accept null values for properties whose HYPERLINK "" \l "schemaObject" Schema Object contains the keyword x-nullable with a Boolean value of true. Mapping of Messages to SchemasThe HYPERLINK "" \l "schemaObject" Schema Object to validate a given message body can be determined as follows:If the request URL matches a path template in the HYPERLINK \l "_Keyword_paths" paths keyword, and the HYPERLINK "" \l "pathItemObject" Path Item Object contains an operation keyword matching the HTTP verb of the request: search the parameters array for an item whose in keyword has the string value body, take the value of its schema keyword to validate the messageIf the message body contains a context URL, i.e. the outermost object contains the keyword @odata.context:If the context URL fragment matches #{type-name} or #{entity-set}{/type-name}/$entity, search the HYPERLINK \l "_Keyword_definitions_1" definitions object for a name/value pair whose name is identical to the type-name match. If the type-name match is alias-qualified, replace alias with namespace before searching. Take its value to validate the message.If the context URL fragment matches #Collection{type-name} or #{entity-set}{/type-name}, search the HYPERLINK \l "_Keyword_definitions_1" definitions object for a name/value pair whose name is identical to the type-name match. If the type-name match is alias-qualified, replace alias with namespace before searching. Construct a schema for the collection wrapper by replacing ... in the code snippet below with a JSON Pointer to the found HYPERLINK "" \l "schemaObject" Schema Object.{ "type": "object", "properties": { "value": { "type": "array", "items": { "$ref": "..." } } }}Use this constructed schema to validate the message.If the context URL fragment matches #{singleton}, search the resources object of the HYPERLINK \l "_Entity_Container" x-entityContainer object for a name/value pair whose name is identical to the singleton match. The type keyword of the value object references a HYPERLINK "" \l "schemaObject" Schema Object. Take it to validate the message.If the context URL fragment matches #{entity-set}/$entity, search the resources object of the HYPERLINK \l "_Entity_Container" x-entityContainer object for a name/value pair whose name is identical to the entity-set match. The entityType keyword of the value object references a HYPERLINK "" \l "schemaObject" Schema Object. Take it to validate the message.If the context URL fragment matches #{entity-set}, search the resources object of the HYPERLINK \l "_Entity_Container" x-entityContainer object for a name/value pair whose name is identical to the entity-set match. The entityType keyword of the value object references a HYPERLINK "" \l "schemaObject" Schema Object. Construct a schema for the collection wrapper by replacing ... in the code snippet below with a JSON Pointer to the found HYPERLINK "" \l "schemaObject" Schema Object.{ "type": "object", "properties": { "value": { "type": "array", "items": { "$ref": "..." } } }}Use this constructed schema to validate the message.ExtensibilityVocabularies and annotations already allow defining additional characteristics or capabilities of metadata elements, such as a service, entity type, property, function, action or parameter, and [OData-CSDL] defines which model elements can be annotated. This document specifies how these metadata annotations are represented in CSDL JSON documents. CSDL ExamplesFollowing are two basic examples of valid OData models as represented in CSDL JSON. These examples demonstrate many of the topics covered above. They represent the same documents as the XML examples in chapter 16 of [OData-CSDL].Products and Categories Example Example SEQ Example \* ARABIC 88:{ "x-odata-version":"4.0", "swagger":"2.0", "info":{ "title":"OData Service for namespace ODataDemo", "version":"", "description":"This OData service is located at \n\n## References\n- [Org.OData.Core.V1]()\n- [Org.OData.Measures.V1]()", "version":"0.1.0" }, "host":"localhost", "schemes": [ "http" ], "host":"localhost", "basePath":"/service-root", "consumes":[ "application/json" ], "produces":[ "application/json" ], "tags":[ { "name":"Products" }, { "name":"Categories", "description":"Product Categories" }, { "name":"Suppliers" }, { "name":"MainSupplier", "description":"Primary Supplier" }, { "name":"Countries" } ], "definitions":{ "ODataDemo.Product":{ "type":"object", "x-mediaEntity":true, "x-keys":[ "ID" ], "properties":{ "ID":{ "type":"string" }, "Description":{ "type":[ "string", "null" ], "x-nullable":true, "x-annotations":{ "@Core.IsLanguageDependent":true } }, "ReleaseDate":{ "type":[ "string", "null" ], "x-nullable":true, "format":"date" }, "DiscontinuedDate":{ "type":[ "string", "null" ], "x-nullable":true, "format":"date" }, "Rating":{ "type":[ "integer", "null" ], "x-nullable":true, "format":"int32" }, "Price":{ "type":[ "number", "string", "null" ], "x-nullable":true, "format":"decimal", "multipleOf":1, "x-annotations":{ "@Org.OData.Measures.V1.ISOCurrency":{ "@odata.@path":"Currency" } } }, "Currency":{ "type":[ "string", "null" ], "x-nullable":true, "maxLength":3 }, "Category":{ "$ref":"#/definitions/ODataDemo.Category", "x-relationship":{ "partner":"Products" } }, "Supplier":{ "$ref":"#/definitions/ODataDemo.Supplier", "x-nullable":true, "x-relationship":{ "partner":"Products" } } } }, "ODataDemo.Category":{ "type":"object", "x-keys":[ "ID" ], "properties":{ "ID":{ "type":"integer", "format":"int32" }, "Name":{ "type":"string", "x-annotations":{ "@Core.IsLanguageDependent":true } }, "Products":{ "type":"array", "items":{ "$ref":"#/definitions/ODataDemo.Product" }, "x-relationship":{ "partner":"Category", "onDelete":{ "action":"Cascade" } } } } }, "ODataDemo.Supplier":{ "type":"object", "x-keys":[ "ID" ], "properties":{ "ID":{ "type":"string" }, "Name":{ "type":[ "string", "null" ], "x-nullable":true }, "Address":{ "$ref":"#/definitions/ODataDemo.Address" }, "Concurrency":{ "type":"integer", "format":"int32" }, "Products":{ "type":"array", "items":{ "$ref":"#/definitions/ODataDemo.Product" }, "x-relationship":{ "partner":"Supplier" } } } }, "ODataDemo.Country":{ "type":"object", "x-keys":[ "Code" ], "properties":{ "Code":{ "type":"string", "maxLength":2 }, "Name":{ "type":[ "string", "null" ], "x-nullable":true } } }, "ODataDemo.Address":{ "type":"object", "properties":{ "Street":{ "type":[ "string", "null" ] , "x-nullable":true }, "City":{ "type":[ "string", "null" ] , "x-nullable":true }, "State":{ "type":[ "string", "null" ] , "x-nullable":true }, "ZipCode":{ "type":[ "string", "null" ] , "x-nullable":true }, "CountryName":{ "type":[ "string", "null" ] , "x-nullable":true }, "Country":{ "$ref":"#/definitions/ODataDemo.Country", "x-nullable":true, "x-relationship":{ "referentialConstraints":{ "CountryName":{ "referencedProperty":"Name" } } } } } } }, "x-schemas":{ "Org.OData.Core.V1":{ "uri":"" }, "Core":{ "aliasFor":"Org.OData.Core.V1" }, "Org.OData.Measures.V1":{ "uri":"" }, "UoM":{ "aliasFor":"Org.OData.Measures.V1" }, "ODataDemo":{ } }, "x-functions":{ "ODataDemo.ProductsByRating":[ { "parameters":[ { "name":"Rating", "parameterType":{ "type":[ "integer", "null" ] , "x-nullable":true, "format":"int32" } } ], "returnType":{ "type":"array", "items":{ "$ref":"#/definitions/ODataDemo.Product" } } } ] }, "x-entityContainer":{ "name":"DemoService", "resources":{ "Products":{ "kind":"EntitySet", "entityType":{ "$ref":"#/definitions/ODataDemo.Product" }, "navigationPropertyBindings":{ "Category":"Categories" } }, "Categories":{ "kind":"EntitySet", "entityType":{ "$ref":"#/definitions/"ODataDemo.Category" }, "navigationPropertyBindings":{ "Products":"Products" } }, "Suppliers":{ "kind":"EntitySet", "entityType":{ "$ref":"#/definitions/"ODataDemo.Supplier" }, "navigationPropertyBindings":{ "Products":"Products", "Address/Country":"Countries" }, "@Core.OptimisticConcurrency":[ { "@odata.@propertyPath":"Concurrency" } ] }, "MainSupplier":{ "kind":"Singleton", "type":{ "$ref":"#/definitions/"ODataDemo.Supplier" }, "navigationPropertyBindings":{ "Products":"Products" } }, "Countries":{ "kind":"EntitySet", "entityType":{ "$ref":"#/definitions/"ODataDemo.Country" } }, "ProductsByRating":{ "kind":"FunctionImport", "entitySet":"Products", "function":"ODataDemo.ProductsByRating" } } }, "paths":{ "Products":{…}, "Products('{ID}'}":{…}, "Categories":{…}, "Categories({ID}}":{…}, "Suppliers":{…}, "Suppliers('{ID}'}":{…}, "MainSupplier":{…}, "Countries":{…}, "Countries('{Code}'}":{…}, "ProductsByRating(Rating={Rating}}":{…}}, "parameters":{ "top":{…}, "skip":{…}, "count":{…}, "filter":{…}, "search":{…}, … }} Annotations for Products and Categories Example Example SEQ Example \* ARABIC 89: schema Annotations contains annotations for referenced schema ODataDemo with terms from vocabulary Some.Vocabulary.V1{ "x-odata-version":"4.0", "swagger":"2.0", "info":{ "title":"OData CSDL Document for namespace External.Annotations", "version":"", "description":"\n\n## References\n- [ODataDemo]($metadata)\n- [Some.Vocabulary.V1]()", "version":"0.1.0" }, "x-schemas":{ "ODataDemo":{ "uri":"$metadata" }, "Some.Vocabulary.V1":{ "uri":"" }, "Vocabulary1":{ "aliasFor":"Some.Vocabulary.V1" }, "External.Annotations":{ "annotations":{ "ODataDemo.Supplier":{ "@Vocabulary1.EMail":null, "@Vocabulary1.AccountID":{ "@odata.@path":"ID" }, "@Vocabulary1.Title":"Supplier Info", "@Vocabulary1.DisplayName":{ "@odata.@apply":"odata.concat", "parameterValues":[ { "@odata.@path":"Name" }, " in ", { "@odata.@path":"Address/CountryName" } ] } }, "ODataDemo.Product":{ "@Vocabulary1Self.Tags":[ "MasterData" ] } } } }, "paths":{ }} ConformanceOData is designed as a set of conventions that can be layered on top of existing standards to provide common representations for common functionality. Not all services will support all of the conventions defined in the protocol; services choose those conventions defined in OData as the representation to expose that functionality appropriate for their scenarios.This extension specification defines how to describe the functionality of an OData service with the means of the OpenAPI Specification. It does not require a specific conformance level for OData services as a precondition to conform to this extension specification.OData Service ConformanceConforming OData services MUST describe all functionality they expose according to the rules in sections REF _Ref356829677 \r \h 3 and REF _Ref451357970 \r \h 4 of this specification.If a service chooses to publish metadata at $metadata according to [ REF odataCSDL \h \* MERGEFORMAT OData-CSDL], its OpenAPI description MUST describe the same functionality that is described in the XML $metadata document.OData Client ConformanceConforming OData clients MUST be able to consume OData services that use any or all of the constructs defined in sections REF _Ref356829677 \r \h 3 and REF _Ref451357970 \r \h 4 of this specification, and any or all constructs defined in the referenced version of the OpenAPI Specification [ REF OpenAPIspec \h OpenAPI].AcknowledgmentsThe contributions of the OASIS OData Technical Committee members, enumerated in [ODataProtocol], are gratefully acknowledged.Revision HistoryRevisionDateEditorChanges MadeCommittee Specification Draft 012015-11-20Ralf HandlInitial versionCommittee Specification Draft 022016-05-18Ralf HandlNow based on OpenAPI Specification ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download