Skip to content

check_valid_responses rejects 4XX and 5XX #160

@jayvdb

Description

@jayvdb

Describe the bug

pub fn check_valid_responses(&self) -> Vec<Alert> {
let mut alerts: Vec<Alert> = vec![];
for (path, item) in &self.swagger.get_paths() {
for (m, op) in item.get_ops() {
let statuses = op.responses().keys().cloned().collect::<Vec<String>>();
for status in statuses {
if let Ok(res_code) = status.parse::<u16>() {
if !(100..600).contains(&res_code) {
alerts.push(Alert::new(
Level::Low,
"Responses have an invalid or unrecognized status code",
format!("swagger path:{path} operation:{m} status:{status}"),
));
}
} else if status != "default" {
alerts.push(Alert::new(
Level::Low,
"Responses have an invalid or unrecognized status code",
format!("swagger path:{path} operation:{m} status:{status}"),
));
}
}
}
}
alerts
}
only allows u16 and "default"

https://swagger.io/docs/specification/v3_0/describing-responses/ allows ranges like "4XX"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions