serialize_yaml

Function serialize_yaml 

Source
pub fn serialize_yaml(doc: &OpenApiDocument) -> Result<String>
Expand description

Serializes an OpenAPI document to YAML format.

The output is formatted as standard YAML, suitable for use with OpenAPI tools and documentation generators.

§Arguments

  • doc - The OpenAPI document to serialize

§Returns

Returns the YAML string representation of the document.

§Errors

Returns an error if serialization fails.

§Example

use openapi_from_source::openapi_builder::OpenApiBuilder;
use openapi_from_source::serializer::serialize_yaml;
use openapi_from_source::schema_generator::SchemaGenerator;
use openapi_from_source::type_resolver::TypeResolver;

let builder = OpenApiBuilder::new();
let type_resolver = TypeResolver::new(vec![]);
let schema_gen = SchemaGenerator::new(type_resolver);
let doc = builder.build(schema_gen);
let yaml = serialize_yaml(&doc).unwrap();
println!("{}", yaml);