Ignore:
Timestamp:
Aug 17, 2023, 4:57:23 PM (15 months ago)
Author:
alloc
Message:

21.1.16.0 release
Completed OpenAPI specs
Add support to path handlers to register OpenAPI specs
Fixed ItemIconHandler throwing error when requested path contains no dot

Location:
TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState/Animal.openapi.yaml

    r460 r463  
    3434        - WorldState
    3535      summary: Animals list
    36       description: Fetch a list of the currently spawned animals in the world
     36      description: Fetch a list of the currently spawned (non-hostile) animals in the world
    3737      operationId: animal.get
    3838      responses:
  • TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState/Player.cs

    r459 r463  
    11using System;
    2 using System.Collections.Generic;
    32using System.Net;
    43using JetBrains.Annotations;
     
    215214                }
    216215
    217                 protected override void HandleRestPost (RequestContext _context, IDictionary<string, object> _jsonInput, byte[] _jsonInputData) {
    218                         if (!JsonCommons.TryGetJsonField (_jsonInput, "command", out string commandString)) {
    219                                 SendEmptyResponse (_context, HttpStatusCode.BadRequest, _jsonInputData, "NO_COMMAND");
    220                                 return;
    221                         }
    222 
    223                         WebCommandResult.ResultType responseType = WebCommandResult.ResultType.Full;
    224 
    225                         if (JsonCommons.TryGetJsonField (_jsonInput, "format", out string formatString)) {
    226                                 if (formatString.EqualsCaseInsensitive ("raw")) {
    227                                         responseType = WebCommandResult.ResultType.Raw;
    228                                 } else if (formatString.EqualsCaseInsensitive ("simple")) {
    229                                         responseType = WebCommandResult.ResultType.ResultOnly;
    230                                 }
    231                         }
    232 
    233                         int commandSepIndex = commandString.IndexOf (' ');
    234                         string commandPart = commandSepIndex > 0 ? commandString.Substring (0, commandSepIndex) : commandString;
    235                         string argumentsPart = commandSepIndex > 0
    236                                 ? commandString.Substring (commandPart.Length + 1)
    237                                 : "";
    238 
    239                         IConsoleCommand command = SdtdConsole.Instance.GetCommand (commandPart, true);
    240 
    241                         if (command == null) {
    242                                 SendEmptyResponse (_context, HttpStatusCode.NotFound, _jsonInputData, "UNKNOWN_COMMAND");
    243                                 return;
    244                         }
    245 
    246                         int commandPermissionLevel = GameManager.Instance.adminTools.Commands.GetCommandPermissionLevel (command.GetCommands ());
    247 
    248                         if (_context.PermissionLevel > commandPermissionLevel) {
    249                                 SendEmptyResponse (_context, HttpStatusCode.Forbidden, _jsonInputData, "NO_PERMISSION");
    250                                 return;
    251                         }
    252 
    253                         _context.Response.SendChunked = true;
    254                         WebCommandResult wcr = new WebCommandResult (commandPart, argumentsPart, responseType, _context);
    255                         SdtdConsole.Instance.ExecuteAsync (commandString, wcr);
    256                 }
    257 
    258216                public override int DefaultPermissionLevel () => AdminWebModules.PermissionLevelGuest;
    259217        }
Note: See TracChangeset for help on using the changeset viewer.