Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 21 additions & 0 deletions src/components/body_type_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ impl BodyType {
}
}

/// True if `value` is one of the generic Content-Types that get auto-set
/// when a body type is selected. Custom MIME types like
/// `application/vnd.api+json` or `text/csv` are NOT defaults and should
/// be preserved as-is.
pub fn is_default_content_type(value: &str) -> bool {
let v = value.trim();
if v.is_empty() {
return true;
}
matches!(
v.to_ascii_lowercase().as_str(),
"application/json"
| "text/plain"
| "application/x-www-form-urlencoded"
| "multipart/form-data"
| "application/xml"
| "text/xml"
| "text/html"
)
}

pub fn syntax_language(&self) -> &'static str {
match self {
BodyType::Json => "json",
Expand Down
Loading