private SyntaxTree CreateOpenApiTree(string newAssemblyNamespace, DirectoryInfo directoryInfo) { if (OpenApiOutputModel != null && OpenApiOutputModel.IsConfiguredForUserInterface) { string templateSource = TemplateProvider.GetTemplate("swaggerui", "csharp"); return(CreateSyntaxTreeFromHandlebarsTemplate(templateSource, "SwaggerUi", new { Namespace = newAssemblyNamespace }, directoryInfo)); } return(null); }
private SyntaxTree CreateReDocTree(string newAssemblyNamespace, DirectoryInfo directoryInfo) { if (OpenApiOutputModel != null && !string.IsNullOrWhiteSpace(OpenApiOutputModel.ReDocUserInterfaceRoute)) { string templateSource = TemplateProvider.GetTemplate("redocui", "csharp"); return(CreateSyntaxTreeFromHandlebarsTemplate(templateSource, "ReDocUi", new { Namespace = newAssemblyNamespace, ReDocUserInterfaceRoute = OpenApiOutputModel.ReDocUserInterfaceRoute }, directoryInfo)); } return(null); }
protected SyntaxTree CreateLinkBack( IReadOnlyCollection <AbstractFunctionDefinition> functionDefinitions, Type backlinkType, PropertyInfo backlinkPropertyInfo, string newAssemblyNamespace, DirectoryInfo outputAuthoredSourceFolder) { if (backlinkType == null) { return(null); // back link referencing has been disabled } // Now we need to create a class that references the assembly with the configuration builder // otherwise the reference will be optimised away by Roslyn and it will then never get loaded // by the function host - and so at runtime the builder with the runtime info in won't be located string linkBackTemplateSource = TemplateProvider.GetCSharpLinkBackTemplate(); Func <object, string> linkBackTemplate = Handlebars.Compile(linkBackTemplateSource); LinkBackModel linkBackModel = null; if (backlinkPropertyInfo != null) { linkBackModel = new LinkBackModel { TypeName = backlinkType.EvaluateType(), PropertyName = backlinkPropertyInfo.Name, PropertyTypeName = backlinkPropertyInfo.PropertyType.EvaluateType(), Namespace = newAssemblyNamespace }; } else { linkBackModel = new LinkBackModel { TypeName = backlinkType.EvaluateType(), PropertyName = null, Namespace = newAssemblyNamespace }; } string outputLinkBackCode = linkBackTemplate(linkBackModel); OutputDiagnosticCode(outputAuthoredSourceFolder, "ReferenceLinkBack", outputLinkBackCode); SyntaxTree linkBackSyntaxTree = CSharpSyntaxTree.ParseText(outputLinkBackCode); return(linkBackSyntaxTree); }