write_openapi_types

Function write_openapi_types 

Source
pub fn write_openapi_types<P: AsRef<Path>>(
    openapi: OpenApi,
    config: FilterConfig,
    out_file: P,
) -> Result<(), Box<dyn Error>>
Expand description

Generates types according to the OpenAPI specification to a file. If it fails, it returns an error, and the specified file will be cleared (if it exists and it was opened).

ยงExample

write_openapi_types(
    OpenApi::from_file("../schema.json"),
    FilterConfig::from_file("../config.json"),
    "src/api/types.rs"
).unwrap();