public override string GenerateModelIndexDTS()
        {
            TSBuilder builder = new TSBuilder();

            builder.Comment(Settings.Instance.Header);
            builder.Line();
            builder.Import(new[] { "BaseResource", "CloudError" }, "ms-rest-azure");
            builder.ImportAllAs("moment", "moment");
            builder.Line();
            builder.Export(export =>
            {
                export.Export("BaseResource");
                export.Export("CloudError");
            });
            foreach (CompositeTypeJs modelType in OrderedModelTemplateModels)
            {
                builder.Line();
                modelType.GenerateModelDefinition(builder);
            }
            foreach (PageCompositeTypeJsa pageModelType in PageTemplateModels)
            {
                builder.Line();
                pageModelType.GenerateModelDefinition(builder);
            }

            return(builder.ToString());
        }
Esempio n. 2
0
        public override string GenerateModelIndex()
        {
            TSBuilder builder = new TSBuilder();

            builder.Comment(AutoRest.Core.Settings.Instance.Header);
            builder.Line();
            builder.Line(ConstructRuntimeImportForModelIndex());
            if (ContainsDurationPropertyInModels() || IsAnyModelInheritingFromRequestOptionsBase() || MethodsWithCustomResponseType.Any())
            {
                builder.ImportAllAs("msRest", "@azure/ms-rest-js");
            }
            builder.Line();
            builder.Export("BaseResource", "CloudError");
            foreach (CompositeTypeTS model in OrderedModelTemplateModels)
            {
                builder.Line();
                builder.Line(model.Generate());
            }
            foreach (PageCompositeTypeTSa model in PageTemplateModels)
            {
                builder.Line();
                builder.Line(model.Generate());
            }
            foreach (EnumTypeTS model in EnumTemplateModels)
            {
                builder.Line();
                builder.Line(model.Generate(Settings.EnumTypes));
            }
            builder.Line(GenerateResponseTypes());

            return(builder.ToString());
        }
        public string GenerateServiceClientExports()
        {
            TSBuilder builder = new TSBuilder();

            builder.Export(exports =>
            {
                exports.Export(Name);
                exports.Export(ContextName);
                if (CodeGeneratorTS.ShouldWriteModelsFiles(this))
                {
                    exports.ExportAs("Models", $"{ClientPrefix}Models");
                }
                if (HasMappers())
                {
                    exports.ExportAs("Mappers", $"{ClientPrefix}Mappers");
                }
            });

            if (MethodGroupModels.Any())
            {
                builder.ExportAll("./operations");
            }
            return(builder.ToString());
        }