Skip to content

Commit

Permalink
Clean unused dependencies related to repr feature
Browse files Browse the repository at this point in the history
  • Loading branch information
juhaku committed Nov 21, 2022
1 parent a4bf827 commit 7502d85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion utoipa-gen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "utoipa-gen"
description = "Code generation implementation for utoipa"
version = "2.4.0"
version = "2.4.1"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
20 changes: 11 additions & 9 deletions utoipa-gen/src/component/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ use proc_macro_error::{abort, ResultExt};
use quote::{quote, quote_spanned, ToTokens};
use syn::{
parse::Parse, punctuated::Punctuated, spanned::Spanned, token::Comma, Attribute, Data, Field,
Fields, FieldsNamed, FieldsUnnamed, Generics, Path, PathArguments, Token, TypePath, Variant,
Visibility,
Fields, FieldsNamed, FieldsUnnamed, Generics, Path, PathArguments, Token, Variant, Visibility,
};

use crate::{
component::features::{Example, Rename},
component::features::Rename,
doc_comment::CommentAttributes,
schema_type::{SchemaFormat, SchemaType},
Array, Deprecated,
};

use self::{
enum_variant::{CustomEnum, Enum, ObjectVariant, ReprVariant, SimpleEnumVariant, TaggedEnum},
enum_variant::{CustomEnum, Enum, ObjectVariant, SimpleEnumVariant, TaggedEnum},
features::{
ComplexEnumFeatures, EnumFeatures, EnumNamedFieldVariantFeatures,
EnumUnnamedFieldVariantFeatures, FromAttributes, NamedFieldFeatures,
Expand Down Expand Up @@ -472,7 +471,7 @@ impl ToTokens for EnumSchema<'_> {
.iter()
.find_map(|attribute| {
if attribute.path.is_ident("repr") {
attribute.parse_args::<TypePath>().ok()
attribute.parse_args::<syn::TypePath>().ok()
} else {
None
}
Expand Down Expand Up @@ -561,15 +560,18 @@ impl ToTokens for EnumSchemaType<'_> {
struct ReprEnum<'a> {
variants: &'a Punctuated<Variant, Comma>,
attributes: &'a [Attribute],
enum_type: TypePath,
enum_type: syn::TypePath,
}

#[cfg(feature = "repr")]
impl ToTokens for ReprEnum<'_> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let container_rules = serde::parse_container(self.attributes);
let repr_enum_features = features::parse_schema_features_with(self.attributes, |input| {
Ok(parse_features!(input as Example, super::features::Default))
Ok(parse_features!(
input as super::features::Example,
super::features::Default
))
})
.unwrap_or_default();

Expand All @@ -582,15 +584,15 @@ impl ToTokens for ReprEnum<'_> {

if is_not_skipped(&variant_rules) {
let repr_type = &self.enum_type;
Some(ReprVariant {
Some(enum_variant::ReprVariant {
value: quote! { Self::#variant_type as #repr_type },
type_path: repr_type,
})
} else {
None
}
})
.collect::<Vec<ReprVariant<TokenStream>>>()
.collect::<Vec<enum_variant::ReprVariant<TokenStream>>>()
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion utoipa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ repr = ["utoipa-gen/repr"]
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", optional = true }
serde_yaml = { version = "0.9", optional = true }
utoipa-gen = { version = "2.4.0", path = "../utoipa-gen" }
utoipa-gen = { version = "2.4.1", path = "../utoipa-gen" }
indexmap = { version = "1", features = ["serde"] }

[dev-dependencies]
Expand Down

0 comments on commit 7502d85

Please sign in to comment.