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
1 change: 0 additions & 1 deletion src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl Api {
) -> anyhow::Result<Self> {
let resources = resources::from_openapi(
paths,
&components.schemas,
include_mode,
excluded_operations,
specified_operations,
Expand Down
54 changes: 0 additions & 54 deletions src/api/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -23,7 +22,6 @@ pub type Resources = BTreeMap<String, Resource>;

pub(crate) fn from_openapi(
paths: openapi::Paths,
component_schemas: &IndexMap<String, openapi::SchemaObject>,
include_mode: IncludeMode,
excluded_operations: &BTreeSet<String>,
specified_operations: &BTreeSet<String>,
Expand All @@ -45,7 +43,6 @@ pub(crate) fn from_openapi(
&path,
method,
op,
component_schemas,
include_mode,
excluded_operations,
specified_operations,
Expand Down Expand Up @@ -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<String>,
/// 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<String>,
Expand All @@ -188,7 +181,6 @@ impl Operation {
path: &str,
method: &str,
op: openapi::Operation,
component_schemas: &IndexMap<String, aide::openapi::SchemaObject>,
include_mode: IncludeMode,
excluded_operations: &BTreeSet<String>,
specified_operations: &BTreeSet<String>,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down
Loading