Function for serializing the OpenAPI document to a string. Defaults to kotlinx-serialization for JSON or YAML.