Skip to content
Closed
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
26 changes: 1 addition & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions progenitor-impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ serde_json = "1.0"
syn = { version = "1.0", features = ["parsing"] }
thiserror = "1.0"
# To publish, use a numbered version
#typify = "0.0.10"
typify = { git = "https://github.com/oxidecomputer/typify" }
#typify-impl = "0.0.10"
typify-impl = { git = "https://github.com/oxidecomputer/typify" }
unicode-ident = "1.0.6"

[dev-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions progenitor-impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use proc_macro2::TokenStream;
use quote::quote;
use serde::Deserialize;
use thiserror::Error;
use typify::{TypeSpace, TypeSpaceSettings};
use typify_impl::{TypeSpace, TypeSpaceSettings};

use crate::to_schema::ToSchema;

pub use typify::TypeSpaceImpl as TypeImpl;
pub use typify::TypeSpacePatch as TypePatch;
pub use typify_impl::TypeSpaceImpl as TypeImpl;
pub use typify_impl::TypeSpacePatch as TypePatch;

mod method;
mod template;
Expand All @@ -24,7 +24,7 @@ pub enum Error {
#[error("unexpected value type {0}: {1}")]
BadValue(String, serde_json::Value),
#[error("type error {0}")]
TypeError(#[from] typify::Error),
TypeError(#[from] typify_impl::Error),
#[error("unexpected or unhandled format in the OpenAPI document {0}")]
UnexpectedFormat(String),
#[error("invalid operation path {0}")]
Expand Down
16 changes: 7 additions & 9 deletions progenitor-impl/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
use openapiv3::{Components, Parameter, ReferenceOr, Response, StatusCode};
use proc_macro2::TokenStream;
use quote::{format_ident, quote, ToTokens};
use typify::TypeId;
use typify_impl::{TypeDetails, TypeId};

use crate::{
template::PathTemplate,
Expand Down Expand Up @@ -1218,7 +1218,7 @@ impl Generator {

let typ = self.type_space.get_type(success_response).ok()?;
let details = match typ.details() {
typify::TypeDetails::Struct(details) => details,
TypeDetails::Struct(details) => details,
_ => return None,
};

Expand All @@ -1230,15 +1230,15 @@ impl Generator {
}

// We need a next_page property that's an Option<String>.
if let typify::TypeDetails::Option(ref opt_id) = self
if let TypeDetails::Option(ref opt_id) = self
.type_space
.get_type(properties.get("next_page")?)
.ok()?
.details()
{
if !matches!(
self.type_space.get_type(opt_id).ok()?.details(),
typify::TypeDetails::String
TypeDetails::String
) {
return None;
}
Expand All @@ -1252,9 +1252,7 @@ impl Generator {
.ok()?
.details()
{
typify::TypeDetails::Array(item) => {
Some(DropshotPagination { item })
}
TypeDetails::Array(item) => Some(DropshotPagination { item }),
_ => None,
}
}
Expand Down Expand Up @@ -1377,7 +1375,7 @@ impl Generator {
OperationParameterType::Type(type_id) => {
let ty = self.type_space.get_type(type_id)?;
let details = ty.details();
matches!(&details, typify::TypeDetails::Option(_))
matches!(&details, TypeDetails::Option(_))
}
OperationParameterType::RawBody => false,
};
Expand All @@ -1402,7 +1400,7 @@ impl Generator {
let ty = self.type_space.get_type(type_id)?;
let details = ty.details();
match &details {
typify::TypeDetails::Option(opt_id) => {
TypeDetails::Option(opt_id) => {
// TODO currently we explicitly turn optional
// parameters into Option types; we could
// probably defer this to the code generation
Expand Down