expression

OpenAPI: describe response media and required fields

The response description states expected status codes, media types and payload structure. Required fields in a response schema express obligations on the producer. This local inspection checks selected fields only; it is not a full schema validator. Standalone synthetic example. Expected stdout (not executed): id name Common mistake: Assuming an example payload replaces a response schema.

Formal Syntax & Structure

rust syntaxrust
responses["200"].content["application/json"].schema

Working Example

Example Snippetrust
use axum::{Router, Json, body::{Body, to_bytes}, http::{Request, StatusCode}};use serde::{Deserialize, Serialize};use tower::ServiceExt;
#[tokio::main(flavor = "current_thread")]async fn main() {    let doc: serde_json::Value = serde_json::from_str(include_str!("../../openapi.json")).unwrap();    let schema = &doc["paths"]["/items/{id}"]["get"]["responses"]["200"]["content"]["application/json"]["schema"];    for field in schema["required"].as_array().unwrap() { println!("{}", field.as_str().unwrap()); }}
Rust Reference