Exemplo n.º 1
0
        private static void AddContentManagementServiceDefinition(this IOpenApiHostConfiguration config)
        {
            Type            contentServiceType = typeof(ContentService);
            OpenApiDocument apiYamlDoc         = OpenApiServiceDefinitions.GetOpenApiServiceFromEmbeddedDefinition(
                contentServiceType.Assembly,
                $"{contentServiceType.Namespace}.ContentManagementServices.yaml");

            config.Documents.Add(apiYamlDoc);
        }
Exemplo n.º 2
0
        // TODO: consolidate with functions startup code.
        // This fixes a bug from that - the 2nd exception handler was wrong on two counts:
        //  1. wrong exception type: if config is non-null and config.Documents is null, that's
        //      not ArgumentNullException
        //  2. wrong argument order: we had the nameof and message flipped
        // In any case, this startup is likely to be needed by any host, so we should put it
        // somewhere common.
        private static void ConfigureOpenApiHost(IOpenApiHostConfiguration config)
        {
            ArgumentNullException.ThrowIfNull(config);

            if (config.Documents is null)
            {
                throw new ArgumentException("AddTenancyApi callback: config.Documents", nameof(config));
            }

            config.Documents.AddSwaggerEndpoint();
        }
Exemplo n.º 3
0
        private static void LoadDocuments(IOpenApiHostConfiguration hostConfig)
        {
            OpenApiDocument openApiDocument;

            using (FileStream stream = File.OpenRead(".\\yaml\\petstore.yaml"))
            {
                openApiDocument = new OpenApiStreamReader().Read(stream, out _);
            }

            hostConfig.Documents.Add(openApiDocument);
            hostConfig.Documents.AddSwaggerEndpoint();
        }
        private static void ConfigureOpenApiHost(IOpenApiHostConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config), "AddTenancyApi callback: config");
            }

            if (config.Documents == null)
            {
                throw new ArgumentNullException(nameof(config.Documents), "AddTenancyApi callback: config.Documents");
            }

            config.Documents.AddSwaggerEndpoint();
        }
Exemplo n.º 5
0
 private static void MapContentManagementExceptions(this IOpenApiHostConfiguration config)
 {
     config.Exceptions.Map <ContentNotFoundException>(404);
     config.Exceptions.Map <ContentConflictException>(409);
 }
Exemplo n.º 6
0
 private static void MapTenancyExceptions(this IOpenApiHostConfiguration config)
 {
     config.Exceptions.Map <TenantNotFoundException>(404);
 }