示例#1
0
        /// <summary>
        /// Generates an OpenAPI document per variant specified in configuration.
        /// In addition, a "default" variant document is generated, which contains no alterations based on
        /// variant metadata.
        /// </summary>
        /// <param name="openApiGeneratorConfig">The configuration that will be used to generate
        /// the document.</param>
        /// <param name="generationDiagnostic">The generation diagnostics.</param>
        /// <param name="openApiDocumentGenerationSettings">The optional Open API document generation settings.</param>
        /// <returns>Dictionary mapping document variant metadata to their respective OpenAPI document.</returns>
        public IDictionary <DocumentVariantInfo, OpenApiDocument> GenerateDocuments(
            OpenApiGeneratorConfig openApiGeneratorConfig,
            out GenerationDiagnostic generationDiagnostic,
            OpenApiDocumentGenerationSettings openApiDocumentGenerationSettings = null)
        {
            foreach (var assemblyPath in openApiGeneratorConfig.AssemblyPaths)
            {
                if (!File.Exists(assemblyPath))
                {
                    throw new FileNotFoundException(assemblyPath);
                }
            }

            if (openApiDocumentGenerationSettings == null)
            {
                openApiDocumentGenerationSettings = new OpenApiDocumentGenerationSettings(
                    new SchemaGenerationSettings(new DefaultPropertyNameResolver()));
            }

            var internalOpenApiGenerator = new InternalOpenApiGenerator(
                openApiGeneratorConfig.OpenApiGeneratorFilterConfig,
                openApiDocumentGenerationSettings);

            return(internalOpenApiGenerator.GenerateOpenApiDocuments(
                       openApiGeneratorConfig.AnnotationXmlDocuments,
                       openApiGeneratorConfig.AssemblyPaths,
                       openApiGeneratorConfig.AdvancedConfigurationXmlDocument?.ToString(),
                       openApiGeneratorConfig.OpenApiDocumentVersion,
                       openApiGeneratorConfig.OpenApiInfoDescription,
                       out generationDiagnostic));
        }
示例#2
0
        /// <summary>
        /// Generates an OpenAPI document per variant specified in configuration.
        /// In addition, a "default" variant document is generated, which contains no alterations based on
        /// variant metadata.
        /// </summary>
        /// <param name="openApiGeneratorConfig">The configuration that will be used to generate
        /// the document.</param>
        /// <param name="generationDiagnostic">The generation diagnostics.</param>
        /// <returns>Dictionary mapping document variant metadata to their respective OpenAPI document.</returns>
        public IDictionary <DocumentVariantInfo, OpenApiDocument> GenerateDocuments(
            OpenApiGeneratorConfig openApiGeneratorConfig,
            out GenerationDiagnostic generationDiagnostic)
        {
            foreach (var assemblyPath in openApiGeneratorConfig.AssemblyPaths)
            {
                if (!File.Exists(assemblyPath))
                {
                    throw new FileNotFoundException(assemblyPath);
                }
            }

            var internalOpenApiGenerator = new InternalOpenApiGenerator(
                openApiGeneratorConfig.OpenApiGeneratorFilterConfig);

            return(internalOpenApiGenerator.GenerateOpenApiDocuments(
                       openApiGeneratorConfig.AnnotationXmlDocuments,
                       openApiGeneratorConfig.AssemblyPaths,
                       openApiGeneratorConfig.AdvancedConfigurationXmlDocument?.ToString(),
                       openApiGeneratorConfig.OpenApiDocumentVersion,
                       out generationDiagnostic));
        }