1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
use crate::reference::ReferenceOrExt; use openapiv3::*; /// Extension methods for Response pub trait ResponseExt { /// Returns the Schema for this response if it responds with application/json fn json_schema(&self) -> Option<&Schema>; } impl ResponseExt for Response { /// Gets the response for a status code in the operation fn json_schema(&self) -> Option<&Schema> { self.content .get("application/json") .and_then(|media| media.schema.as_ref().map(|schema| schema.to_item_ref())) } }