From 1c7411f6e688ed042b20e01c7720133c7dda8b34 Mon Sep 17 00:00:00 2001 From: Simon Thum Date: Wed, 14 May 2025 17:14:01 +0200 Subject: [PATCH] Add missing text stream overloads --- src/NSwag.Core.Yaml/OpenApiYamlDocument.cs | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs b/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs index 38a8c9dd4..71166a9a8 100644 --- a/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs +++ b/src/NSwag.Core.Yaml/OpenApiYamlDocument.cs @@ -64,7 +64,37 @@ public static async Task FromYamlAsync(string data, string docu => await FromYamlAsync(new StringReader(data), documentPath, expectedSchemaType, referenceResolverFactory, cancellationToken); - /// Creates a Swagger specification from a YAML string. + /// Creates a Swagger specification from a YAML text stream. + /// The JSON or YAML data. + /// The cancellation token. + /// The . + public static Task FromYamlAsync(TextReader data, CancellationToken cancellationToken = default) + { + return FromYamlAsync(data, null, SchemaType.Swagger2, null, cancellationToken); + } + + /// Creates a Swagger specification from a YAML text stream. + /// The JSON or YAML data. + /// The document path (URL or file path) for resolving relative document references. + /// The cancellation token. + /// The . + public static Task FromYamlAsync(TextReader data, string documentPath, CancellationToken cancellationToken = default) + { + return FromYamlAsync(data, documentPath, SchemaType.Swagger2, null, cancellationToken); + } + + /// Creates a Swagger specification from a YAML text stream. + /// The JSON or YAML data. + /// The document path (URL or file path) for resolving relative document references. + /// The expected schema type which is used when the type cannot be determined. + /// The cancellation token. + /// The . + public static Task FromYamlAsync(TextReader data, string documentPath, SchemaType expectedSchemaType, CancellationToken cancellationToken = default) + { + return FromYamlAsync(data, documentPath, expectedSchemaType, null, cancellationToken); + } + + /// Creates a Swagger specification from a YAML text stream. /// The JSON or YAML data as a reader. /// The document path (URL or file path) for resolving relative document references. /// The expected schema type which is used when the type cannot be determined.