public void TestMethod1() { ExpressionParser Parser = ExpressionParser.CreateParser(); HTTPAction action = new HTTPAction { Parser = Parser, URLServerPortExpression = "'http://npaa1215/rve1'$", VariableName = "html" }; action.ExecuteAction(); Assert.IsTrue(Parser.ParsingContext.Parameters.ContainsKey("html")); }
public static OperationConfig FromValues(HTTPAction action, Operation operation, string path) => new OperationConfig { HTTPAction = action, Operation = operation, Path = path };
private void AddAPICall(CoderStringBuilder output, PathItem path, HTTPAction action) { var operation = default(Operation); switch (action) { case HTTPAction.Put: { operation = path.Put; break; } case HTTPAction.Get: { operation = path.Get; break; } case HTTPAction.Post: { operation = path.Post; break; } case HTTPAction.Delete: { operation = path.Delete; break; } case HTTPAction.Head: { operation = path.Head; break; } case HTTPAction.Options: { operation = path.Options; break; } case HTTPAction.Patch: { operation = path.Patch; break; } } if (operation == null) { return; } var parameters = ""; if (operation.Parameters != null) { var optional = ""; if (operation.Parameters.All(_ => !_.Required)) { optional = "?"; } parameters = $"parameters{optional}: {CleanClassName($"{operation.OperationId}Request")}"; } var methodName = ""; if (operation.OperationId != null) { methodName = CleanClassName(operation.OperationId, false); } else { methodName = CleanClassName(GetPathToMethodName(action.ToString(), path.Path), false); } var operationContent = new StringBuilder($"{methodName}({parameters}): "); var success = operation.Responses.FirstOrDefault(_ => _.HttpStatusCode >= 200 && _.HttpStatusCode <= 299); if (success == null || success.Schema == null) { operationContent.Append("PromiseLike<void>;"); } else { operationContent.Append($"PromiseLike<{SchemaTypeCleaner(success.Schema)}>;"); } output.AppendLine(operationContent.ToString()); }