/// <summary> /// Creates an api operation /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An api operation</returns> public static ResourceApiOperation CreateResourceApiOperation(ApiDescription api, XmlCommentDocumentationProvider docProvider) { ResourceApiOperation rApiOperation = new ResourceApiOperation() { httpMethod = api.HttpMethod.ToString(), nickname = docProvider.GetNickname(api.ActionDescriptor), responseClass = docProvider.GetResponseClass(api.ActionDescriptor), summary = api.Documentation, notes = docProvider.GetNotes(api.ActionDescriptor), parameters = new List<ResourceApiOperationParameter>() }; return rApiOperation; }
/// <summary> /// Creates an api operation /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An api operation</returns> public static ResourceApiOperation CreateResourceApiOperation(ApiDescription api, XmlCommentDocumentationProvider docProvider, DataTypeRegistry dataTypeRegistry) { ResourceApiOperation rApiOperation = new ResourceApiOperation() { httpMethod = api.HttpMethod.ToString(), nickname = docProvider.GetNickname(api.ActionDescriptor), responseClass = docProvider.GetResponseClass(api.ActionDescriptor), summary = api.Documentation, notes = docProvider.GetNotes(api.ActionDescriptor), type = docProvider.GetResponseClass(api.ActionDescriptor), parameters = new List <ResourceApiOperationParameter>(), responseMessages = new List <ResourceApiOperationResponseMessage>(), }; var responseType = api.ActualResponseType(); if (responseType == null) { rApiOperation.type = "void"; } else { var dataType = dataTypeRegistry.GetOrRegister(responseType); if (dataType.Type == "object") { rApiOperation.type = dataType.Id; } else { rApiOperation.type = dataType.Type; rApiOperation.format = dataType.Format; rApiOperation.items = dataType.Items; rApiOperation.Enum = dataType.Enum; } } return(rApiOperation); }
/// <summary> /// Creates an api operation /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An api operation</returns> public static ResourceApiOperation CreateResourceApiOperation(ApiDescription api, XmlCommentDocumentationProvider docProvider) { ResponseMeta responseMeta = docProvider.GetResponseType(api.ActionDescriptor); SwaggerType swaggerType = Helper.GetSwaggerType(responseMeta.Type); ResourceApiOperation rApiOperation = new ResourceApiOperation { httpMethod = api.HttpMethod.ToString(), nickname = docProvider.GetNickname(api.ActionDescriptor), items = swaggerType.Items, type = swaggerType.Name, summary = api.Documentation, notes = docProvider.GetNotes(api.ActionDescriptor), parameters = new List <ResourceApiOperationParameter>(), responseMessages = docProvider.GetResponseCodes(api.ActionDescriptor) }; var typesToReturn = new ConcurrentDictionary <string, string>(); Helper.TryToAddModels(models, responseMeta.Type, docProvider, typesToReturn); return(rApiOperation); }
/// <summary> /// Creates an api operation /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An api operation</returns> public static ResourceApiOperation CreateResourceApiOperation(ApiDescription api, XmlCommentDocumentationProvider docProvider) { ResponseMeta responseMeta = docProvider.GetResponseType(api.ActionDescriptor); SwaggerType swaggerType = Helper.GetSwaggerType(responseMeta.Type); ResourceApiOperation rApiOperation = new ResourceApiOperation { httpMethod = api.HttpMethod.ToString(), nickname = docProvider.GetNickname(api.ActionDescriptor), items = swaggerType.Items, type = swaggerType.Name, summary = api.Documentation, notes = docProvider.GetNotes(api.ActionDescriptor), parameters = new List<ResourceApiOperationParameter>(), responseMessages = docProvider.GetResponseCodes(api.ActionDescriptor) }; var typesToReturn = new ConcurrentDictionary<string, string>(); Helper.TryToAddModels(models, responseMeta.Type, docProvider, typesToReturn); return rApiOperation; }
/// <summary> /// Creates an api operation /// </summary> /// <param name="api">Description of the api via the ApiExplorer</param> /// <param name="docProvider">Access to the XML docs written in code</param> /// <returns>An api operation</returns> public static ResourceApiOperation CreateResourceApiOperation(ApiDescription api, XmlCommentDocumentationProvider docProvider, HttpControllerDescriptor controllerDescriptor) { var parts = docProvider.GetNotes(api.ActionDescriptor).Split(new string[] { "schema=" }, StringSplitOptions.None); ReflectedHttpActionDescriptor actionDescriptor = (api.ActionDescriptor as ReflectedHttpActionDescriptor); string _attributes = ""; _attributes += GetCustomAttributesAsString(actionDescriptor.MethodInfo.GetCustomAttributes(true)); _attributes += GetCustomAttributesAsString(controllerDescriptor.ControllerType.GetCustomAttributes(true)); ResourceApiOperation rApiOperation = new ResourceApiOperation() { httpMethod = api.HttpMethod.ToString(), nickname = docProvider.GetNickname(api.ActionDescriptor), responseClass = docProvider.GetResponseClass(api.ActionDescriptor), summary = api.Documentation+" "+_attributes, notes = parts[0], schema = parts.Length > 1 ? parts[1] : "", parameters = new List<ResourceApiOperationParameter>(), }; return rApiOperation; }