zackyang000 / node-odata

A library for easily create OData REST API, abide by OData protocol.
http://zackyang000.github.io/node-odata/en/
MIT License
365 stars 65 forks source link

Service document #101

Open r1mar opened 2 years ago

r1mar commented 2 years ago

Hello Zack,

a feature, that not implemented too. http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#_Toc31358933 11.1.1 Service Document Request Service documents enable simple hypermedia-driven clients to enumerate and explore the resources offered by the data service.

OData services MUST support returning a service document from the root URL of the service (the service root).

The format of the service document is dependent upon the format selected.

http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html 5 Service Document A service document in JSON is represented as a single JSON object with at least the context control information and a property value.

The value of the context control information MUST be the URL of the metadata document, without any fragment part.

The value of the value property MUST be a JSON array containing one element for each entity set and function import with an explicit or default value of true for the attribute IncludeInServiceDocument and each singleton exposed by the service, see [OData-CSDLJSON] or [OData-CSDLXML].

Each element MUST be a JSON object with at least two name/value pairs, one with name name containing the name of the entity set, function import, or singleton, and one with name url containing the URL of the entity set, which may be an absolute or a relative URL. It MAY contain a name/value pair with name title containing a human-readable, language-dependent title for the object.

JSON objects representing an entity set MAY contain an additional name/value pair with name kind and a value of EntitySet. If the kind name/value pair is not present, the object MUST represent an entity set.

JSON objects representing a function import MUST contain the kind name/value pair with a value of FunctionImport.

JSON objects representing a singleton MUST contain the kind name/value pair with a value of Singleton.

JSON objects representing a related service document MUST contain the kind name/value pair with a value of ServiceDocument.

Clients that encounter unknown values of the kind name/value pair not defined in this version of the specification MUST NOT stop processing and MUST NOT signal an error.

Service documents MAY contain annotations in any of its JSON objects. Services MUST NOT produce name/value pairs other than the ones explicitly defined in this section, and clients MUST ignore unknown name/value pairs.

Example 9: { "@context": "http://host/service/$metadata", "value": [ { "name": "Orders", "kind": "EntitySet", "url": "Orders" }, { "name": "OrderItems", "title": "Order Details", "url": "OrderItems" }, { "name": "TopProducts", "title": "Best-Selling Products", "kind": "FunctionImport", "url": "TopProducts" }, { "name": "MainSupplier", "title": "Main Supplier", "kind": "Singleton", "url": "MainSupplier" }, { "name": "Human Resources", "kind": "ServiceDocument", "url": "http://host/HR/" } ] }

Regards, Richard