UNPKG

@autorest/go

Version:
78 lines 3.9 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// export class CodeModel { constructor(info, type, packageName, options) { this.clients = new Array(); this.constants = new Array(); this.info = info; this.interfaces = new Array(); this.models = new Array(); this.options = options; this.packageName = packageName; this.paramGroups = new Array(); this.responseEnvelopes = new Array(); this.type = type; } sortContent() { const sortAscending = function (a, b) { return a < b ? -1 : a > b ? 1 : 0; }; this.constants.sort((a, b) => { return sortAscending(a.name, b.name); }); for (const enm of this.constants) { enm.values.sort((a, b) => { return sortAscending(a.name, b.name); }); } this.interfaces.sort((a, b) => { return sortAscending(a.name, b.name); }); for (const iface of this.interfaces) { // we sort by literal value so that the switch/case statements in polymorphic_helpers.go // are ordered by the literal value which can be somewhat different from the model name. iface.possibleTypes.sort((a, b) => { return sortAscending(a.discriminatorValue.literal, b.discriminatorValue.literal); }); } this.models.sort((a, b) => { return sortAscending(a.name, b.name); }); for (const model of this.models) { model.fields.sort((a, b) => { return sortAscending(a.name, b.name); }); } this.paramGroups.sort((a, b) => { return sortAscending(a.name, b.name); }); for (const paramGroup of this.paramGroups) { paramGroup.fields.sort((a, b) => { return sortAscending(a.name, b.name); }); } this.responseEnvelopes.sort((a, b) => { return sortAscending(a.name, b.name); }); for (const respEnv of this.responseEnvelopes) { respEnv.headers.sort((a, b) => { return sortAscending(a.fieldName, b.fieldName); }); } this.clients.sort((a, b) => { return sortAscending(a.name, b.name); }); for (const client of this.clients) { if (client.instance?.kind === 'constructable') { client.instance.constructors.sort((a, b) => sortAscending(a.name, b.name)); if (client.instance.options.kind === 'clientOptions') { client.instance.options.parameters.sort((a, b) => sortAscending(a.name, b.name)); } } client.parameters.sort((a, b) => sortAscending(a.name, b.name)); client.methods.sort((a, b) => { return sortAscending(a.name, b.name); }); client.clientAccessors.sort((a, b) => { return sortAscending(a.name, b.name); }); for (const method of client.methods) { method.httpStatusCodes.sort(); } } } } export class Info { constructor(title) { this.title = title; } } export class Options { constructor(headerText, generateFakes, injectSpans, disallowUnknownFields, generateExamples) { this.headerText = headerText; this.generateFakes = generateFakes; this.injectSpans = injectSpans; this.omitConstructors = false; this.disallowUnknownFields = disallowUnknownFields; this.generateExamples = generateExamples; } } //# sourceMappingURL=package.js.map