/// <summary> /// Convert a REST method into a swagger method /// </summary> /// <returns>The swagger method.</returns> /// <param name="method">Method.</param> internal static SwaggerMethod ToSwaggerMethod(this MethodDefinition method) { var output = new SwaggerMethod { Summary = method.Title }; if (!string.IsNullOrEmpty(method.Description)) { output.Description = method.Description; } output.Parameters.AddRange(from p in method.Parameters select p.ToSwaggerParameter()); // Make sure any path parameters are parsed since Swagger requires them var missingPathParameters = MissingRequestParameters(method); output.Parameters.AddRange(from p in missingPathParameters select p.ToSwaggerParameter()); if (output.Parameters.Count == 0) { output.Parameters = null; } output.Tags = null; string statusCode; var response = method.ToSwaggerResponse(out statusCode); output.Responses.Add(statusCode, response); //output.Responses.Add("200", new SwaggerResponse() // { // Description = "real response tbd", // Schema = method.ExpectedResponseAsSwaggerProperty() // }); // output.Responses = null; return(output); }
/// <summary> /// Convert a REST method into a swagger method /// </summary> /// <returns>The swagger method.</returns> /// <param name="method">Method.</param> internal static SwaggerMethod ToSwaggerMethod(this MethodDefinition method) { var output = new SwaggerMethod { Summary = method.Title }; if (!string.IsNullOrEmpty(method.Description)) output.Description = method.Description; output.Parameters.AddRange(from p in method.Parameters select p.ToSwaggerParameter()); // Make sure any path parameters are parsed since Swagger requires them var missingPathParameters = MissingRequestParameters(method); output.Parameters.AddRange(from p in missingPathParameters select p.ToSwaggerParameter()); if (output.Parameters.Count == 0) output.Parameters = null; output.Tags = null; string statusCode; var response = method.ToSwaggerResponse(out statusCode); output.Responses.Add(statusCode, response); //output.Responses.Add("200", new SwaggerResponse() // { // Description = "real response tbd", // Schemas = method.ExpectedResponseAsSwaggerProperty() // }); // output.Responses = null; return output; }