diff --git a/src/api/mod.rs b/src/api/mod.rs index a8b89de..acc32cb 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -35,7 +35,6 @@ impl Api { ) -> anyhow::Result { let resources = resources::from_openapi( paths, - &components.schemas, include_mode, excluded_operations, specified_operations, diff --git a/src/api/resources.rs b/src/api/resources.rs index 9fc94d5..a0a91f2 100644 --- a/src/api/resources.rs +++ b/src/api/resources.rs @@ -5,7 +5,6 @@ use std::{ use aide::openapi::{self, ReferenceOr}; use anyhow::{Context as _, bail}; -use indexmap::IndexMap; use schemars::schema::{InstanceType, Schema}; use serde::{Deserialize, Serialize}; @@ -23,7 +22,6 @@ pub type Resources = BTreeMap; pub(crate) fn from_openapi( paths: openapi::Paths, - component_schemas: &IndexMap, include_mode: IncludeMode, excluded_operations: &BTreeSet, specified_operations: &BTreeSet, @@ -45,7 +43,6 @@ pub(crate) fn from_openapi( &path, method, op, - component_schemas, include_mode, excluded_operations, specified_operations, @@ -169,10 +166,6 @@ pub struct Operation { /// Name of the request body type, if any. #[serde(skip_serializing_if = "Option::is_none")] pub(crate) request_body_schema_name: Option, - /// Some request bodies are required, but all the fields are optional (i.e. the CLI can omit - /// this from the argument list). - /// Only useful when `request_body_schema_name` is `Some`. - request_body_all_optional: bool, /// Name of the response body type, if any. #[serde(skip_serializing_if = "Option::is_none")] response_body_schema_name: Option, @@ -188,7 +181,6 @@ impl Operation { path: &str, method: &str, op: openapi::Operation, - component_schemas: &IndexMap, include_mode: IncludeMode, excluded_operations: &BTreeSet, specified_operations: &BTreeSet, @@ -312,51 +304,6 @@ impl Operation { } } - let request_body_all_optional = op - .request_body - .as_ref() - .map(|r| { - match r { - ReferenceOr::Reference { .. } => { - unimplemented!("reference") - } - ReferenceOr::Item(body) => { - if let Some(mt) = body.content.get("application/json") { - match mt.schema.as_ref().map(|so| &so.json_schema) { - Some(Schema::Object(schemars::schema::SchemaObject { - object: Some(ov), - .. - })) => { - return ov.required.is_empty(); - } - Some(Schema::Object(schemars::schema::SchemaObject { - reference: Some(s), - .. - })) => { - match component_schemas - .get( - &get_schema_name(Some(s)).expect("schema should exist"), - ) - .map(|so| &so.json_schema) - { - Some(Schema::Object(schemars::schema::SchemaObject { - object: Some(ov), - .. - })) => { - return ov.required.is_empty(); - } - _ => unimplemented!("double ref not supported"), - } - } - _ => {} - } - } - } - } - false - }) - .unwrap_or_default(); - let request_body_schema_name = op.request_body.and_then(|b| match b { ReferenceOr::Item(mut req_body) => { assert!(req_body.required); @@ -429,7 +376,6 @@ impl Operation { header_params, query_params, request_body_schema_name, - request_body_all_optional, response_body_schema_name, }; Some((res_path, op))