From 72f62c23b3f480d5ec1d9a772f33b3684ab8ae14 Mon Sep 17 00:00:00 2001 From: Ludovic Pourrat <52542520+ludovic-pourrat@users.noreply.github.com> Date: Fri, 17 May 2024 10:26:35 +0200 Subject: [PATCH] Serialize schemas feature #400 --- schema_parse.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/schema_parse.go b/schema_parse.go index 2be5a37..539bd9c 100644 --- a/schema_parse.go +++ b/schema_parse.go @@ -20,11 +20,21 @@ func Parse(schema string) (Schema, error) { return ParseBytes([]byte(schema)) } +// Serialize serializes a schema object. +func Serialize(schema Schema) string { + return SerializeWithCache(schema, DefaultSchemaCache) +} + // ParseWithCache parses a schema string using the given namespace and schema cache. func ParseWithCache(schema, namespace string, cache *SchemaCache) (Schema, error) { return ParseBytesWithCache([]byte(schema), namespace, cache) } +// SerializeWithCache serializes a schema using the given namespace and schema cache. +func SerializeWithCache(schema Schema, cache *SchemaCache) string { + return serializeType(schema, cache) +} + // MustParse parses a schema string, panicing if there is an error. func MustParse(schema string) Schema { parsed, err := Parse(schema)