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); }
// 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(); }
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(); }
private static void MapContentManagementExceptions(this IOpenApiHostConfiguration config) { config.Exceptions.Map <ContentNotFoundException>(404); config.Exceptions.Map <ContentConflictException>(409); }
private static void MapTenancyExceptions(this IOpenApiHostConfiguration config) { config.Exceptions.Map <TenantNotFoundException>(404); }