/
Andru196
/
NSwagClone
Обзор
Документация
Войти
/
Andru196
/
NSwagClone
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
1
Аналитика
Безопасность
master
src/NSwag.CodeGeneration.TypeScript.Tests/ObjectParameterTests.cs
76 строк
3 KB
Marko Lahma
Remove unused usings (#5051)
23 ноя 2024, 12:43
Не верифицирован
23 ноя 2024, 12:43
c062ed8
Код
Авторство
О чём код?
using Xunit; namespace NSwag.CodeGeneration.TypeScript.Tests { public class ObjectParameterTests { [Fact] public async Task when_content_is_formdata_with_property_object_then_content_should_be_json_typescript() { var json = @"{ ""x-generator"": ""NSwag v13.5.0.0 (NJsonSchema v10.1.15.0 (Newtonsoft.Json v11.0.0.0))"", ""openapi"": ""3.0.0"", ""info"": { ""title"": ""My Title"", ""version"": ""1.0.0"" }, ""paths"": { ""/api/FileUpload/UploadFile"": { ""post"": { ""tags"": [ ""FileUpload"" ], ""operationId"": ""FileUpload_UploadFile"", ""requestBody"": { ""content"": { ""multipart/form-data"": { ""schema"": { ""properties"": { ""file"": { ""type"": ""string"", ""format"": ""binary"" }, ""propertyDto"": { ""type"": ""object"", ""description"": ""Configurable properties"" }, ""test"": { ""type"": ""string"" } } } } } }, ""responses"": { ""200"": { ""description"": """", ""content"": { ""application/octet-stream"": { ""schema"": { ""type"": ""string"", ""format"": ""binary"" } } } } } } }, }, ""components"": {} }"; var document = await OpenApiDocument.FromJsonAsync(json); // Act var codeGenerator = new TypeScriptClientGenerator(document, new TypeScriptClientGeneratorSettings()); var code = codeGenerator.GenerateFile(); // Assert Assert.Contains("const content_ = new FormData();", code); Assert.Contains("content_.append(\"propertyDto\", JSON.stringify(propertyDto))", code); } } }