oasgen-macro 0.10.0

Dependency of oasgen. Generates OpenAPI 3.0 spec based on Rust code. Works with actix-web, but architected to easily extend to other frameworks (or no framework).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use syn::punctuated::Punctuated;
use syn::token::Comma;
use syn::Data::Struct;
use syn::{DataStruct, DeriveInput, Field, Fields, FieldsNamed};


/// Given derive input of a struct, get the fields of the struct.
pub fn get_fields(ast: &DeriveInput) -> &Punctuated<Field, Comma> {
    let fields = match &ast.data {
        Struct(DataStruct { ref fields, .. }) => fields,
        _ => panic!("#[ormlite] can only be used on structs"),
    };
    let fields = match fields {
        Fields::Named(FieldsNamed { named, .. }) => named,
        _ => panic!("#[ormlite] can only be used on structs with named fields"),
    };
    fields
}