Skip to content

Commit

Permalink
oapi: update AnyValue parse_any (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Sep 11, 2024
1 parent 879376b commit 7344d2d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crates/oapi-macros/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,10 @@ impl AnyValue {

pub(crate) fn parse_any(input: ParseStream) -> syn::Result<Self> {
if input.peek(Lit) {
let lit = input
.parse::<Lit>()
.expect("parse_any: parse `Lit` failed")
.to_token_stream();
Ok(AnyValue::Json(lit))
let punct = input.parse::<Option<Token![-]>>()?;
let lit = input.parse::<Lit>().unwrap();

Ok(AnyValue::Json(quote! { #punct #lit}))
} else {
let fork = input.fork();
let is_json = if fork.peek(syn::Ident) && fork.peek2(Token![!]) {
Expand Down

0 comments on commit 7344d2d

Please sign in to comment.