pub fn serialize_json(doc: &OpenApiDocument) -> Result<String>Expand description
Serializes an OpenAPI document to JSON format with pretty printing.
The output is formatted with indentation for readability, making it suitable for human review and version control.
§Arguments
doc- The OpenAPI document to serialize
§Returns
Returns the JSON 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_json;
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 json = serialize_json(&doc).unwrap();
println!("{}", json);