azure-sdk-for-node/runtime/ms-rest
Jianye Xi 3f8fd317de increased version 2020-03-20 20:58:08 +08:00
..
.vscode Invalid syntax 2019-10-04 17:00:58 +02:00
lib Support dash in the parameter name of path template 2020-03-18 15:22:58 +08:00
test format code 2020-03-19 13:53:09 +08:00
.gitignore runtimes from version 1.15.1. From now onwards the runtimes would stay in the node sdk. 2016-10-06 12:22:41 -07:00
.npmignore do not publish the test folder 2018-09-26 15:08:37 -07:00
Changelog.md increased version 2020-03-20 20:58:08 +08:00
LICENSE updated runtime and removed underscore dependency from ms-rest 2016-05-17 19:20:58 -07:00
README.md adding impression pixel 2019-03-04 15:13:55 -08:00
index.d.ts Make nullable optional on Mapper 2018-06-21 10:27:20 -07:00
ms-rest.njsproj removed underscore dependency and added a retry filter to handle system errors 2016-10-18 15:42:04 -07:00
package.json increased version 2020-03-20 20:58:08 +08:00

README.md

MS-Rest

Infrastructure for serialization/deserialization, error handling, tracing, and http client pipeline configuration. Required by nodeJS client libraries generated using AutoRest.

  • Node.js version: 4.x.x or higher

How to Install

npm install ms-rest

Usage

var msrest = require('ms-rest');

Serialization/Deserialization

Features

  • Type checking

    • (String, Number, Boolean, ByteArray, Base64Url, Date, DateTime, Enum, TimeSpan, DateTimeRfc1123, UnixTime, Object, Stream, Sequence, Dictionary, Composite, Uuid(as a string))
  • Validation of specified constraints

    • ExclusiveMaximum, ExclusiveMinimum, InclusiveMaximum, InclusiveMinimum, MaxItems, MaxLength, MinItems, MinLength, MultipleOf, Pattern, UniqueItems
  • Flattening/Unflattening properties

  • Default Values

  • Model Properties marked as constant are set during serialization, irrespective of they being provided or not

  • Required check (If a model or property is marked required and is not provided in the object then an error is thrown)

  • Readonly check (If a model or property is marked readonly then it is not sent on the wire during, serialization)

  • Serializing Constant values

  • serialize an array of dictionary of primitive values

var mapper = {
  type : {
    name: 'Sequence', 
    element: {
      type : {
        name: 'Dictionary',
        value: {
          type: {
            name: 'Boolean'
          }
        }
      }
    }
  }
};
var array = [{ 1: true }, { 2: false }, { 1: true, 2: false, 3: true }];
var serializedArray = msRest.serialize(mapper, array, 'arrayObj');
assert.deepEqual(array, serializedArray);
var serializedProduct = msrest.serialize(mapper, productObj, 'productObject');
var deserializedArray = msRest.deserialize(mapper, serializedArray, 'serializedArrayObj');

For more examples on serialization/deserialization with complex types please take a look over here.

Impressions