Beispiel #1
0
        public void Apply(ApiDescription apiDescription, ApiOperationSpec operationSpec)
        {
            try
            {
                var descriptionXml = XElement.Parse(apiDescription.Documentation);

                var notes = descriptionXml.Element("remarks");
                if (notes != null)
                {
                    operationSpec.notes = notes.Value;
                }

                foreach (var error in descriptionXml.Elements("response"))
                {
                    operationSpec.errorResponses.Add(new ApiErrorResponseSpec()
                    {
                        code = Convert.ToInt32(error.Attribute("code").Value), reason = error.Value
                    });
                }

                var summary = descriptionXml.Element("summary");
                operationSpec.summary = summary != null ? summary.Value : descriptionXml.Value;
            }
            catch (XmlException) { } // sorry, found no other reliable way to tell if this is xml or not
        }
Beispiel #2
0
 public void Apply(ApiDescription apiDescription, ApiOperationSpec operationSpec)
 {
     operationSpec.errorResponses.Add(new ApiErrorResponseSpec {
         code = _code, reason = _reason
     });
 }
Beispiel #3
0
        private void AssertApiParameterSpec(ApiOperationSpec operationSpec, string paramName, Action <ApiParameterSpec> applyAssertions)
        {
            var paramSpec = operationSpec.parameters.Single(p => p.name == paramName);

            applyAssertions(paramSpec);
        }