예제 #1
0
        /// <summary>Generates the file.</summary>
        /// <returns>The file contents.</returns>
        public override string GenerateFile()
        {
            var classes  = GenerateType(_resolver.GenerateTypeName()).Code + "\n\n" + _resolver.GenerateTypes();
            var template = new FileTemplate() as ITemplate;

            template.Initialize(new FileTemplateModel
            {
                Namespace = Settings.Namespace ?? string.Empty,
                Classes   = ConversionUtilities.TrimWhiteSpaces(classes)
            });
            return(template.Render());
        }
        internal override string RenderFile(string clientCode, string[] clientClasses)
        {
            var template = new FileTemplate();

            template.Initialize(new // TODO: Add typed class
            {
                Namespace       = Settings.CSharpGeneratorSettings.Namespace,
                Toolchain       = SwaggerService.ToolchainVersion,
                Clients         = Settings.GenerateClientClasses ? clientCode : string.Empty,
                NamespaceUsages = Settings.AdditionalNamespaceUsages ?? new string[] { },
                Classes         = Settings.GenerateDtoTypes ? Resolver.GenerateClasses() : string.Empty
            });
            return(template.Render());
        }
예제 #3
0
        /// <summary>Generates the file.</summary>
        /// <returns>The file contents.</returns>
        public override string GenerateFile()
        {
            _resolver.Resolve(_schema, false, string.Empty); // register root type

            var template = new FileTemplate() as ITemplate;

            template.Initialize(new FileTemplateModel
            {
                Toolchain = JsonSchema4.ToolchainVersion,
                Namespace = Settings.Namespace ?? string.Empty,
                Classes   = ConversionUtilities.TrimWhiteSpaces(_resolver.GenerateTypes(null))
            });
            return(ConversionUtilities.TrimWhiteSpaces(template.Render()));
        }
        internal override string RenderFile(string clientCode)
        {
            var template = new FileTemplate();

            template.Initialize(new
            {
                Toolchain  = SwaggerService.ToolchainVersion,
                IsAngular2 = Settings.GenerateClientClasses && Settings.Template == TypeScriptTemplate.Angular2,

                Clients       = Settings.GenerateClientClasses ? clientCode : string.Empty,
                Types         = GenerateDtoTypes(),
                ExtensionCode = Settings.TypeScriptGeneratorSettings.TransformedExtensionCode,

                HasModuleName = !string.IsNullOrEmpty(Settings.ModuleName),
                ModuleName    = Settings.ModuleName
            });
            return(template.Render());
        }
예제 #5
0
        /// <summary>Generates the file.</summary>
        /// <returns>The file contents.</returns>
        public override string GenerateFile()
        {
            _resolver.Resolve(_schema, false, string.Empty); // register root type

            var template = new FileTemplate() as ITemplate;

            template.Initialize(new FileTemplateModel
            {
                Types = ConversionUtilities.TrimWhiteSpaces(_resolver.GenerateTypes(Settings.ProcessedExtensionCode)),

                HasModuleName = !string.IsNullOrEmpty(Settings.ModuleName),
                ModuleName    = Settings.ModuleName,

                ExtensionCodeBefore = Settings.ProcessedExtensionCode.CodeBefore,
                ExtensionCodeAfter  = Settings.ProcessedExtensionCode.CodeAfter
            });
            return(ConversionUtilities.TrimWhiteSpaces(template.Render()));
        }
예제 #6
0
        /// <summary>Generates the file.</summary>
        /// <returns>The file contents.</returns>
        public override string GenerateFile()
        {
            _resolver.Resolve(_schema, false, string.Empty); // register root type

            var template = new FileTemplate() as ITemplate;
            template.Initialize(new FileTemplateModel
            {
                Toolchain = JsonSchema4.ToolchainVersion,
                Types = ConversionUtilities.TrimWhiteSpaces(_resolver.GenerateTypes(Settings.ProcessedExtensionCode)),

                HasModuleName = !string.IsNullOrEmpty(Settings.ModuleName),
                ModuleName = Settings.ModuleName,

                ExtensionCodeBefore = Settings.ProcessedExtensionCode.CodeBefore,
                ExtensionCodeAfter = Settings.ProcessedExtensionCode.CodeAfter
            });
            return ConversionUtilities.TrimWhiteSpaces(template.Render());
        }