public static RestApiAttribute Build(AttributeData att) { if (att.ConstructorArguments.Length != 2) { throw new NotSupportedException($"{TypeFullNames.RestApiAttribute} must have constructor with 2 arguments."); } var method = (LambdaHttpMethod)att.ConstructorArguments[0].Value; var template = att.ConstructorArguments[1].Value as string; var data = new RestApiAttribute(method, template); return(data); }
private string ProcessRestApiAttribute(ILambdaFunctionSerializable lambdaFunction, RestApiAttribute restApiAttribute) { var eventPath = $"Resources.{lambdaFunction.Name}.Properties.Events"; var methodName = restApiAttribute.Method.ToString(); var methodPath = $"{eventPath}.Root{methodName}"; _jsonWriter.SetToken($"{methodPath}.Type", "Api"); _jsonWriter.SetToken($"{methodPath}.Properties.Path", restApiAttribute.Template); _jsonWriter.SetToken($"{methodPath}.Properties.Method", methodName.ToUpper()); return($"Root{methodName}"); }
/// <summary> /// Returns aa <see cref="HashSet{T}"/> of string containing template parameter /// parsed from the <see cref="RestApiAttribute.Template"/>. /// </summary> /// <param name="attribute">this <see cref="RestApiAttribute"/> object.</param> public static HashSet <string> GetTemplateParameters(this RestApiAttribute attribute) { var template = attribute.Template; return(GetTemplateParameters(template)); }