fix: null team reviews
This commit is contained in:
parent
e6339d7c4f
commit
03c2ff9a17
6 changed files with 145 additions and 3 deletions
|
@ -1079,6 +1079,9 @@ pub struct Schema {
|
|||
pub xml: Option<Xml>,
|
||||
pub external_docs: Option<ExternalDocs>,
|
||||
pub example: Option<serde_json::Value>,
|
||||
|
||||
#[serde(flatten)]
|
||||
pub extensions: BTreeMap<String, serde_json::Value>,
|
||||
}
|
||||
|
||||
impl JsonDeref for Schema {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::openapi::*;
|
||||
use eyre::WrapErr;
|
||||
use heck::ToPascalCase;
|
||||
use std::fmt::Write;
|
||||
use std::{collections::BTreeMap, fmt::Write};
|
||||
|
||||
pub fn create_structs(spec: &OpenApiV2) -> eyre::Result<String> {
|
||||
let mut s = String::new();
|
||||
|
@ -51,6 +51,13 @@ pub fn create_struct_for_definition(
|
|||
|
||||
let mut subtypes = Vec::new();
|
||||
|
||||
let parse_with = schema
|
||||
.extensions
|
||||
.get("x-parse-with")
|
||||
.map(|ex| serde_json::from_value::<BTreeMap<String, String>>(ex.clone()))
|
||||
.transpose()?
|
||||
.unwrap_or_default();
|
||||
|
||||
let docs = create_struct_docs(schema)?;
|
||||
let mut fields = String::new();
|
||||
let required = schema.required.as_deref().unwrap_or_default();
|
||||
|
@ -90,6 +97,11 @@ pub fn create_struct_for_definition(
|
|||
if field_ty == "Option<time::OffsetDateTime>" {
|
||||
fields.push_str("#[serde(with = \"time::serde::rfc3339::option\")]\n");
|
||||
}
|
||||
if let Some(parse_method) = parse_with.get(prop_name) {
|
||||
fields.push_str("#[serde(deserialize_with = \"crate::");
|
||||
fields.push_str(parse_method);
|
||||
fields.push_str("\")]\n");
|
||||
}
|
||||
if let MaybeRef::Value { value } = &prop_schema {
|
||||
if let Some(desc) = &value.description {
|
||||
for line in desc.lines() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue