Exemple #1
0
        public string GenerateMethodGroupImports()
        {
            TSBuilder builder = new TSBuilder();

            builder.ImportAllAs("coreHttp", "@azure/core-http");
            if (MethodTemplateModels.Any((MethodTS method) => method.IsLongRunningOperation))
            {
                builder.ImportAllAs("coreArm", "@azure/core-arm");
            }

            CodeModelTS codeModel = CodeModelTS;

            if (CodeGeneratorTS.ShouldWriteModelsFiles(codeModel))
            {
                if (ContainsCompositeOrEnumTypeInParametersOrReturnType() || MethodTemplateModels.Any(m => m.HasCustomHttpResponseType))
                {
                    builder.ImportAllAs("Models", "../models");
                }
                if (codeModel.HasMappers())
                {
                    builder.ImportAllAs("Mappers", $"../models/{MappersModuleName}");
                }
            }

            if (HasMappableParameters)
            {
                builder.ImportAllAs("Parameters", "../models/parameters");
            }

            builder.Import(new string[] { codeModel.ContextName }, $"../{codeModel.ContextName.ToCamelCase()}");

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

            if (MethodTemplateModels.Any() || OptionalParameterTypeForClientConstructor == ServiceClientOptions)
            {
                builder.ImportAllAs("msRest", "ms-rest-js");
            }

            if (CodeGeneratorTS.ShouldWriteModelsFiles(this))
            {
                builder.ImportAllAs("Models", "./models");
            }

            if (HasMappers())
            {
                builder.ImportAllAs("Mappers", "./models/mappers");
            }

            if (HasMappableParameters)
            {
                builder.ImportAllAs("Parameters", "./models/parameters");
            }

            if (CodeGeneratorTS.ShouldWriteMethodGroupFiles(this))
            {
                builder.ImportAllAs("operations", "./operations");
            }
            builder.Import(new string[] { ContextName }, $"./{ContextName.ToCamelCase()}");

            return(builder.ToString());
        }
        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());
        }
 public void ImportMsRestForMappers(TSBuilder builder, IEnumerable <CompositeTypeTS> orderedMapperModels)
 {
     if (orderedMapperModels.Any())
     {
         builder.ImportAllAs("msRest", "ms-rest-js");
     }
 }
Exemple #5
0
 protected override void GenerateNodeSampleImports(TSBuilder builder)
 {
     GenerateNodeSampleMsRestJsImport(builder);
     builder.ImportAllAs("msRestAzure", "@azure/ms-rest-azure-js");
     GenerateNodeSampleMsRestNodeAuthImport(builder);
     GenerateNodeSampleClientImport(builder);
 }
Exemple #6
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());
        }
 protected override void GenerateNodeSampleImports(TSBuilder builder)
 {
     GenerateNodeSampleMsRestJsImport(builder);
     builder.ImportAllAs("coreArm", "@azure/core-arm");
     GenerateNodeSampleMsRestNodeAuthImport(builder);
     GenerateNodeSampleClientImport(builder);
 }
Exemple #8
0
        public string GenerateAzureServiceClientImports()
        {
            TSBuilder builder = new TSBuilder();

            builder.ImportAllAs("msRest", "ms-rest-js");

            bool usesAzureOptionsType = OptionalParameterTypeForClientConstructor == "AzureServiceClientOptions";

            if (usesAzureOptionsType || MethodTemplateModels.Any((MethodTS method) => method.IsLongRunningOperation))
            {
                builder.ImportAllAs("msRestAzure", "ms-rest-azure-js");
            }

            if (CodeGeneratorTS.ShouldWriteModelsFiles(this))
            {
                builder.ImportAllAs("Models", "./models");
            }
            if (CodeGeneratorTS.ShouldWriteMappersIndexFile(this))
            {
                builder.ImportAllAs("Mappers", "./models/mappers");
            }

            if (HasMappableParameters)
            {
                builder.ImportAllAs("Parameters", "./models/parameters");
            }

            if (MethodGroupModels.Any())
            {
                builder.ImportAllAs("operations", "./operations");
            }
            builder.Import(new string[] { ContextName }, $"./{ContextName.ToCamelCase()}");

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

            builder.ImportAllAs("msRest", "ms-rest-js");

            bool usesAzureOptionsType = OptionalParameterTypeForClientConstructor == "AzureServiceClientOptions";

            if (usesAzureOptionsType)
            {
                builder.ImportAllAs("msRestAzure", "ms-rest-azure-js");
            }

            builder.ImportAllAs("Models", "./models");
            builder.ImportAllAs("Mappers", "./models/mappers");

            if (HasMappableParameters)
            {
                builder.ImportAllAs("Parameters", "./models/parameters");
            }

            if (MethodGroupModels.Any())
            {
                builder.ImportAllAs("operations", "./operations");
            }
            builder.Import(new string[] { ContextName }, $"./{ContextName.ToCamelCase()}");

            return(builder.ToString());
        }
Exemple #10
0
        public virtual string GenerateModelIndexDTS()
        {
            TSBuilder builder = new TSBuilder();

            builder.Comment(Settings.Instance.Header);
            builder.Line();
            builder.ImportAllAs("moment", "moment");
            foreach (CompositeTypeJs modelType in OrderedModelTemplateModels)
            {
                builder.Line();
                modelType.GenerateModelDefinition(builder);
            }

            return(builder.ToString());
        }
Exemple #11
0
 protected void GenerateNodeSampleMsRestNodeAuthImport(TSBuilder builder)
 {
     builder.ImportAllAs("msRestNodeAuth", "ms-rest-nodeauth");
 }
Exemple #12
0
 protected void GenerateNodeSampleMsRestJsImport(TSBuilder builder)
 {
     builder.ImportAllAs("msRest", "ms-rest-js");
 }