source: TFP-WebServer/WebServer/src/WebAPI/APIs/OpenAPI.cs@ 487

Last change on this file since 487 was 459, checked in by alloc, 15 months ago

Updated to dashboard/marker files 0.8.0
Added initial OpenAPI support

File size: 737 bytes
RevLine 
[459]1using System.Net;
2using JetBrains.Annotations;
3using Webserver.Permissions;
4
5namespace Webserver.WebAPI.APIs {
6 [UsedImplicitly]
7 public class OpenAPI : AbsRestApi {
8 public OpenAPI (Web _parentWeb) : base (_parentWeb) {
9 }
10
11 protected override void HandleRestGet (RequestContext _context) {
12 string path = _context.RequestPath;
13
14 if (!ParentWeb.OpenApiHelpers.TryGetOpenApiSpec (path, out string specText)) {
15 WebUtils.WriteText (_context.Response, $"Spec for {path} not found", HttpStatusCode.NotFound);
16 return;
17 }
18
19 WebUtils.WriteText (_context.Response, specText, _mimeType: "text/x-yaml");
20 }
21
22 public override int DefaultPermissionLevel () => AdminWebModules.PermissionLevelGuest;
23 }
24}
Note: See TracBrowser for help on using the repository browser.