Exemple #1
0
        public static APIOperation Create(string name,
                                          RequestMethod method, string urlTemplate,
                                          ParameterContract[] parameters,
                                          RequestContract request,
                                          ResponseContract[] responses,
                                          string description = null,
                                          string operationId = null)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new InvalidEntityException("Operation's is required");
            }
            if (name.Length > 100)
            {
                throw new InvalidEntityException("Length of operation's name must be < 100");
            }
            if (String.IsNullOrWhiteSpace(urlTemplate))
            {
                throw new InvalidEntityException("Operation's urlTemplate is required");
            }


            APIOperation operation = new APIOperation();

            operation.Id                 = operationId ?? EntityIdGenerator.GenerateIdSignature(Constants.IdPrefixTemplate.APIOPERATION);
            operation.Name               = name;
            operation.Method             = method.ToString();
            operation.TemplateParameters = parameters;
            operation.Request            = request;
            operation.Responses          = responses;
            operation.Description        = description;

            operation.UrlTemplate = urlTemplate;
            //operation.UrlTemplate = APIOperationHelper.BuildURL(urlTemplate, parameters);

            return(operation);
        }
Exemple #2
0
 public APIOperationHelper(APIOperation operation)
 {
     this.Operation = operation;
 }