-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from NSwag/master
Release v2.18
- Loading branch information
Showing
22 changed files
with
527 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/NSwag.CodeGeneration.Tests/ClientGeneration/FormParameterTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NJsonSchema; | ||
using NSwag.CodeGeneration.CodeGenerators.CSharp; | ||
|
||
namespace NSwag.CodeGeneration.Tests.ClientGeneration | ||
{ | ||
[TestClass] | ||
public class FormParameterTests | ||
{ | ||
[TestMethod] | ||
public void When_form_parameters_are_defined_then_MultipartFormDataContent_is_generated() | ||
{ | ||
//// Arrange | ||
var service = new SwaggerService(); | ||
service.Paths["foo/bar"] = new SwaggerOperations | ||
{ | ||
{ | ||
SwaggerOperationMethod.Post, | ||
new SwaggerOperation | ||
{ | ||
Parameters = new List<SwaggerParameter> | ||
{ | ||
new SwaggerParameter | ||
{ | ||
Name = "foo", | ||
Kind = SwaggerParameterKind.FormData, | ||
Type = JsonObjectType.String | ||
}, | ||
new SwaggerParameter | ||
{ | ||
Name = "bar", | ||
IsRequired = true, | ||
Kind = SwaggerParameterKind.FormData, | ||
Type = JsonObjectType.String | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
//// Act | ||
var generator = new SwaggerToCSharpClientGenerator(service, new SwaggerToCSharpClientGeneratorSettings | ||
{ | ||
|
||
}); | ||
var code = generator.GenerateFile(); | ||
|
||
//// Assert | ||
Assert.IsTrue(code.Contains("new MultipartFormDataContent")); | ||
Assert.IsTrue(code.Contains("if (foo != null)")); | ||
Assert.IsTrue(code.Contains("throw new ArgumentNullException(\"bar\");")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 34 additions & 34 deletions
68
src/NSwag.CodeGeneration/CodeGenerators/CSharp/SwaggerToCSharpGeneratorSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="SwaggerToCSharpGeneratorSettings.cs" company="NSwag"> | ||
// Copyright (c) Rico Suter. All rights reserved. | ||
// </copyright> | ||
// <license>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</license> | ||
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using NJsonSchema.CodeGeneration.CSharp; | ||
|
||
namespace NSwag.CodeGeneration.CodeGenerators.CSharp | ||
{ | ||
/// <summary>Settings for the <see cref="SwaggerToCSharpGenerator"/>.</summary> | ||
public abstract class SwaggerToCSharpGeneratorSettings : CodeGeneratorBaseSettings | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpClientGeneratorSettings"/> class.</summary> | ||
protected SwaggerToCSharpGeneratorSettings() | ||
{ | ||
AdditionalNamespaceUsages = null; | ||
CSharpGeneratorSettings = new CSharpGeneratorSettings | ||
{ | ||
Namespace = "MyNamespace" | ||
}; | ||
} | ||
|
||
/// <summary>Gets or sets the CSharp generator settings.</summary> | ||
public CSharpGeneratorSettings CSharpGeneratorSettings { get; set; } | ||
|
||
/// <summary>Gets or sets the class name of the service client.</summary> | ||
public string ClassName { get; set; } | ||
|
||
/// <summary>Gets or sets the additional namespace usages.</summary> | ||
public string[] AdditionalNamespaceUsages { get; set; } | ||
} | ||
//----------------------------------------------------------------------- | ||
// <copyright file="SwaggerToCSharpGeneratorSettings.cs" company="NSwag"> | ||
// Copyright (c) Rico Suter. All rights reserved. | ||
// </copyright> | ||
// <license>https://github.com/NSwag/NSwag/blob/master/LICENSE.md</license> | ||
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using NJsonSchema.CodeGeneration.CSharp; | ||
|
||
namespace NSwag.CodeGeneration.CodeGenerators.CSharp | ||
{ | ||
/// <summary>Settings for the <see cref="SwaggerToCSharpGeneratorBase"/>.</summary> | ||
public abstract class SwaggerToCSharpGeneratorSettings : CodeGeneratorBaseSettings | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="SwaggerToCSharpClientGeneratorSettings"/> class.</summary> | ||
protected SwaggerToCSharpGeneratorSettings() | ||
{ | ||
AdditionalNamespaceUsages = null; | ||
CSharpGeneratorSettings = new CSharpGeneratorSettings | ||
{ | ||
Namespace = "MyNamespace" | ||
}; | ||
} | ||
|
||
/// <summary>Gets or sets the CSharp generator settings.</summary> | ||
public CSharpGeneratorSettings CSharpGeneratorSettings { get; set; } | ||
|
||
/// <summary>Gets or sets the class name of the service client.</summary> | ||
public string ClassName { get; set; } | ||
|
||
/// <summary>Gets or sets the additional namespace usages.</summary> | ||
public string[] AdditionalNamespaceUsages { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.