@microsoft.azure/autorest.incubator
Version:
AutoRest incubator project
91 lines • 3.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const extensions_1 = require("../../common/code-model/extensions");
const dictionary_1 = require("../../common/dictionary");
var Purpose;
(function (Purpose) {
Purpose["Header"] = "Header";
})(Purpose = exports.Purpose || (exports.Purpose = {}));
class Schema extends extensions_1.Extensions {
constructor(name, initializer) {
super();
this.required = new Array();
this.enum = new Array();
this.allOf = new Array();
this.oneOf = new Array();
this.anyOf = new Array();
this.properties = new dictionary_1.Dictionary();
this.extensions = new dictionary_1.Dictionary();
this.details = {
default: {
description: 'MISSING DESCRIPTION 04',
name
}
};
this.apply(initializer);
}
}
exports.Schema = Schema;
function getPolymorphicBases(schema) {
// are any of my parents polymorphic directly, or any of their parents?
return [...dictionary_1.values(schema.allOf).linq.where(parent => parent.discriminator ? true : false), ...dictionary_1.values(schema.allOf).linq.selectMany(getPolymorphicBases)];
}
exports.getPolymorphicBases = getPolymorphicBases;
function getAllProperties(schema) {
return [...dictionary_1.values(schema.allOf).linq.selectMany(getAllProperties), ...dictionary_1.values(schema.properties)];
}
exports.getAllProperties = getAllProperties;
class Property extends extensions_1.Extensions {
constructor(name, initializer) {
super();
this.extensions = new dictionary_1.Dictionary();
this.serializedName = name;
this.details = {
default: {
description: 'MISSING DESCRIPTION 03',
name,
required: false
}
};
this.apply(initializer);
}
}
exports.Property = Property;
class Discriminator extends extensions_1.Extensions {
constructor(propertyName, initializer) {
super();
this.propertyName = propertyName;
this.extensions = new dictionary_1.Dictionary();
this.mapping = new dictionary_1.Dictionary();
this.apply(initializer);
}
}
exports.Discriminator = Discriminator;
var JsonType;
(function (JsonType) {
JsonType["Array"] = "array";
JsonType["Boolean"] = "boolean";
JsonType["Integer"] = "integer";
JsonType["Number"] = "number";
JsonType["Object"] = "object";
JsonType["String"] = "string";
})(JsonType = exports.JsonType || (exports.JsonType = {}));
function isJsonType(type, schema) {
return schema ? schema.type === type : false;
}
exports.isJsonType = isJsonType;
function isSchemaObject(schema) {
return isJsonType(JsonType.Object, schema);
}
exports.isSchemaObject = isSchemaObject;
class XML extends extensions_1.Extensions {
constructor(initializer) {
super();
this.extensions = new dictionary_1.Dictionary();
this.attribute = false;
this.wrapped = false;
this.apply(initializer);
}
}
exports.XML = XML;
//# sourceMappingURL=schema.js.map