Skip to content

Add more HTTP codes to ResponseDescriptionMap #3148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -996,67 +996,84 @@ private static bool IsFromFormAttributeUsedWithIFormFile(ApiParameterDescription

private static readonly IReadOnlyCollection<KeyValuePair<string, string>> ResponseDescriptionMap =
[
new KeyValuePair<string, string>("100", "Continue"),
new KeyValuePair<string, string>("101", "Switching Protocols"),
new KeyValuePair<string, string>("1\\d{2}", "Information"),

new KeyValuePair<string, string>("200", "OK"),
new KeyValuePair<string, string>("201", "Created"),
new KeyValuePair<string, string>("202", "Accepted"),
new KeyValuePair<string, string>("203", "Non-Authoritative Information"),
new KeyValuePair<string, string>("204", "No Content"),
new KeyValuePair<string, string>("205", "Reset Content"),
new KeyValuePair<string, string>("206", "Partial Content"),
new KeyValuePair<string, string>("2\\d{2}", "Success"),

new KeyValuePair<string, string>("300", "Multiple Choices"),
new KeyValuePair<string, string>("301", "Moved Permanently"),
new KeyValuePair<string, string>("302", "Found"),
new KeyValuePair<string, string>("303", "See Other"),
new KeyValuePair<string, string>("304", "Not Modified"),
new KeyValuePair<string, string>("305", "Use Proxy"),
new KeyValuePair<string, string>("307", "Temporary Redirect"),
new KeyValuePair<string, string>("308", "Permanent Redirect"),
new KeyValuePair<string, string>("3\\d{2}", "Redirect"),

new KeyValuePair<string, string>("400", "Bad Request"),
new KeyValuePair<string, string>("401", "Unauthorized"),
new KeyValuePair<string, string>("402", "Payment Required"),
new KeyValuePair<string, string>("403", "Forbidden"),
new KeyValuePair<string, string>("404", "Not Found"),
new KeyValuePair<string, string>("405", "Method Not Allowed"),
new KeyValuePair<string, string>("406", "Not Acceptable"),
new KeyValuePair<string, string>("407", "Proxy Authentication Required"),
new KeyValuePair<string, string>("408", "Request Timeout"),
new KeyValuePair<string, string>("409", "Conflict"),
new KeyValuePair<string, string>("410", "Gone"),
new KeyValuePair<string, string>("411", "Length Required"),
new KeyValuePair<string, string>("412", "Precondition Failed"),
new KeyValuePair<string, string>("413", "Content Too Large"),
new KeyValuePair<string, string>("414", "URI Too Long"),
new KeyValuePair<string, string>("415", "Unsupported Media Type"),
new KeyValuePair<string, string>("416", "Range Not Satisfiable"),
new KeyValuePair<string, string>("417", "Expectation Failed"),
new KeyValuePair<string, string>("421", "Misdirected Request"),
new KeyValuePair<string, string>("422", "Unprocessable Content"),
new KeyValuePair<string, string>("423", "Locked"),
new KeyValuePair<string, string>("424", "Failed Dependency"),
new KeyValuePair<string, string>("426", "Upgrade Required"),
new KeyValuePair<string, string>("428", "Precondition Required"),
new KeyValuePair<string, string>("429", "Too Many Requests"),
new KeyValuePair<string, string>("431", "Request Header Fields Too Large"),
new KeyValuePair<string, string>("451", "Unavailable For Legal Reasons"),
new KeyValuePair<string, string>("4\\d{2}", "Client Error"),

new KeyValuePair<string, string>("500", "Internal Server Error"),
new KeyValuePair<string, string>("501", "Not Implemented"),
new KeyValuePair<string, string>("502", "Bad Gateway"),
new KeyValuePair<string, string>("503", "Service Unavailable"),
new KeyValuePair<string, string>("504", "Gateway Timeout"),
new KeyValuePair<string, string>("505", "HTTP Version Not Supported"),
new KeyValuePair<string, string>("5\\d{2}", "Server Error"),

new KeyValuePair<string, string>("default", "Error")
// Informational responses
new("100", "Continue"),
new("101", "Switching Protocols"),
new("102", "Processing"),
new("103", "Early Hints"),
new("1\\d{2}", "Information"),

// Successful responses
new("200", "OK"),
new("201", "Created"),
new("202", "Accepted"),
new("203", "Non-Authoritative Information"),
new("204", "No Content"),
new("205", "Reset Content"),
new("206", "Partial Content"),
new("207", "Multi-Status "),
new("208", "Already Reported"),
new("226", "IM Used"),
new("2\\d{2}", "Success"),

// Redirection messages
new("300", "Multiple Choices"),
new("301", "Moved Permanently"),
new("302", "Found"),
new("303", "See Other"),
new("304", "Not Modified"),
new("305", "Use Proxy"),
new("307", "Temporary Redirect"),
new("308", "Permanent Redirect"),
new("3\\d{2}", "Redirect"),

// Client error responses
new("400", "Bad Request"),
new("401", "Unauthorized"),
new("402", "Payment Required"),
new("403", "Forbidden"),
new("404", "Not Found"),
new("405", "Method Not Allowed"),
new("406", "Not Acceptable"),
new("407", "Proxy Authentication Required"),
new("408", "Request Timeout"),
new("409", "Conflict"),
new("410", "Gone"),
new("411", "Length Required"),
new("412", "Precondition Failed"),
new("413", "Content Too Large"),
new("414", "URI Too Long"),
new("415", "Unsupported Media Type"),
new("416", "Range Not Satisfiable"),
new("417", "Expectation Failed"),
new("418", "I'm a teapot"),
new("421", "Misdirected Request"),
new("422", "Unprocessable Content"),
new("423", "Locked"),
new("424", "Failed Dependency"),
new("425", "Too Early"),
new("426", "Upgrade Required"),
new("428", "Precondition Required"),
new("429", "Too Many Requests"),
new("431", "Request Header Fields Too Large"),
new("451", "Unavailable For Legal Reasons"),
new("4\\d{2}", "Client Error"),

// Server error responses
new("500", "Internal Server Error"),
new("501", "Not Implemented"),
new("502", "Bad Gateway"),
new("503", "Service Unavailable"),
new("504", "Gateway Timeout"),
new("505", "HTTP Version Not Supported"),
new("506", "Variant Also Negotiates"),
new("507", "Insufficient Storage"),
new("508", "Loop Detected "),
new("510", "Not Extended"),
new("511", "Network Authentication Required"),
new("5\\d{2}", "Server Error"),

new("default", "Error")
];

#if NET7_0_OR_GREATER
Expand Down