UNPKG

@microsoft.azure/autorest.incubator

Version:
39 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const schema_1 = require("../../common/code-model/schema"); const message = require("./messages"); function objectWithFormat(schema, state) { if (schema.type === schema_1.JsonType.Object && schema.format) { state.error(`Schema is declared 'object' but has a format: '${schema.format}'`, message.ObjectShouldNotHaveFormat); return true; } return false; } exports.objectWithFormat = objectWithFormat; function schemaHasEnum(schema, state) { if (schema.enum.length > 0) { state.error(`Schema with type:'${schema.type} and 'format:'${schema.format}' does not support 'enum' value restrictions.`, message.DoesNotSupportEnum); return true; } return false; } exports.schemaHasEnum = schemaHasEnum; function hasXmsEnum(schema, state) { if (schema.enum.length > 0) { if (schema.extensions["x-ms-enum"]) { state.error(`Schema with type:'${schema.type} and 'format:'${schema.format}' does not support 'x-ms-enum' generation `, message.SchemaDoeNotSupportXMSEnum); return true; } } return false; } exports.hasXmsEnum = hasXmsEnum; function arrayMissingItems(schema, state) { if (schema.type === schema_1.JsonType.Array && !schema.items) { state.error(`Array schema missing items type`, message.ArrayMissingItems); return true; } return false; } exports.arrayMissingItems = arrayMissingItems; //# sourceMappingURL=validations.js.map