/// <summary> /// Initializes a new instance of the <see cref="SwaggerRouteDataBuilder"/> class. /// </summary> /// <param name="operationNickName">The nickname for the operation.</param> /// <param name="method">The method for the route.</param> /// <param name="apiPath">The path for the API.</param> public SwaggerRouteDataBuilder(string operationNickName, HttpMethod method, string apiPath) { Data = new SwaggerRouteData { OperationNickname = operationNickName, OperationMethod = method, ApiPath = apiPath }; }
public static Operation ToOperation(this SwaggerRouteData routeData) { var operation = routeData.OperationModel.ToDataType <Operation>(); operation.Nickname = SwaggerConfig.NicknameConvention(routeData); operation.Summary = routeData.OperationSummary; operation.Method = routeData.OperationMethod; operation.Notes = routeData.OperationNotes; operation.Parameters = routeData.OperationParameters.Select(p => p.ToParameter()); operation.ResponseMessages = routeData.OperationResponseMessages.Any() ? routeData.OperationResponseMessages.OrderBy(r => r.Code) : null; operation.Produces = routeData.OperationProduces.Any() ? routeData.OperationProduces.OrderBy(p => p) : null; operation.Consumes = routeData.OperationConsumes.Any() ? routeData.OperationConsumes.OrderBy(c => c) : null; return(operation); }
/// <summary> /// Returns a unique id for the given <paramref name="route"/> /// that can be used by tools reading the output for further and easier /// manipulation. /// </summary> /// <param name="route">The route for which a nickname is returned.</param> /// <returns>a unique id for the given <paramref name="route"/> that can /// be used by tools reading the output for further and easier /// manipulation.</returns> public static string DefaultNicknameConvention(SwaggerRouteData route) { return(string.IsNullOrEmpty(route.OperationNickname) ? string.Format("{0}/{1}", route.OperationMethod.ToString().ToLower(), route.ApiPath).ToCamelCase() : route.OperationNickname); }
/// <summary> /// Returns a unique id for the given <paramref name="route"/> /// that can be used by tools reading the output for further and easier /// manipulation. /// </summary> /// <param name="route">The route for which a nickname is returned.</param> /// <returns>a unique id for the given <paramref name="route"/> that can /// be used by tools reading the output for further and easier /// manipulation.</returns> public static string DefaultNicknameConvention(SwaggerRouteData route) { return string.IsNullOrEmpty(route.OperationNickname) ? string.Format("{0}/{1}", route.OperationMethod.ToString().ToLower(), route.ApiPath).ToCamelCase() : route.OperationNickname; }