Skip to content

Commit 6b00ece

Browse files
author
Chebotov Nikolay
committed
1) Fix #10 issue;
2) Add small fixes.
1 parent 9623163 commit 6b00ece

11 files changed

+59
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
These are the changes to each version that has been released on the official [Visual Studio extension gallery](https://marketplace.visualstudio.com/items?itemName=unchase.UnchaseOpenAPIConnectedService).
99

10+
## v1.3.10 `2019-11-22`
11+
12+
- [x] Fix [issue #10](https://github.com/unchase/Unchase.OpenAPI.Connectedservice/issues/10)
13+
- [x] Add small fixes
14+
1015
## v1.3.9 `2019-11-14`
1116

1217
- [x] Add output relative project path in the first wizard page

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ Install from `Tools -> Extensions and Updates` menu inside [Visual Studio](https
5454

5555
## Settings Meaning
5656

57-
Meaning of the Unchase [OpenAPI (Swagger) Connected Service](https://marketplace.visualstudio.com/items?itemName=unchase.unchaseOpenAPIConnectedService) settings according to [NSWagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio):
57+
Meaning of the Unchase [OpenAPI (Swagger) Connected Service](https://marketplace.visualstudio.com/items?itemName=unchase.unchaseOpenAPIConnectedService) settings according to [NSwagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio):
5858

5959
![Unchase OpenAPI (Swagger) Connected Service settings meaning](img/Unchase-OpenAPI-Swagger-Connected-Service-Settings-Meaning.png)
6060

6161
## Custom Commands
6262

6363
### `Open in NSwagStudio` Command
6464

65-
Since *v1.1.** have been added menu command embedded in Visual Studio Solution Explorer context menu lets you open generated `.nswag` and `.nswag.json` files in [NSWagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio).
65+
Since *v1.1.** have been added menu command embedded in Visual Studio Solution Explorer context menu lets you open generated `.nswag` and `.nswag.json` files in [NSwagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio).
6666

67-
This extension is for those times where you generate `.nswag` and `.nswag.json` files and you want to be able to quickly open it in [NSWagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio).
67+
This extension is for those times where you generate `.nswag` and `.nswag.json` files and you want to be able to quickly open it in [NSwagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio).
6868

6969
#### Prerequisite
7070

71-
> In order to use this extension, you must have [Visual Studio](https://visualstudio.microsoft.com/vs/) 2017/2019, this connected service as well as [NSWagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio) installed.
71+
> In order to use this extension, you must have [Visual Studio](https://visualstudio.microsoft.com/vs/) 2017/2019, this connected service as well as [NSwagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio) installed.
7272
7373
#### Solution Explorer
7474

@@ -78,7 +78,7 @@ You can open `.nswag` and `.nswag.json` files in [NSWagStudio](https://github.co
7878

7979
#### Path to NSwagStudio.exe
8080

81-
If you installed [NSWagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio) at a non-default location, a prompt will ask for the path to `NSwagStudio.exe`.
81+
If you installed [NSwagStudio](https://github.com/NSwag/NSwag/wiki/NSwagStudio) at a non-default location, a prompt will ask for the path to `NSwagStudio.exe`.
8282

8383
You can always change the location in *Tools -> Options -> Web -> Unchase OpenAPI (Swagger) Connected Service*:
8484

src/Common/UserSettingsPersistenceHelper.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Unchase.OpenAPI.ConnectedService.Common
99
{
1010
internal class UserSettingsPersistenceHelper
1111
{
12+
#region Public methods
1213
/// <summary>
1314
/// Saves user settings to isolated storage. The data is stored with the user's roaming profile.
1415
/// </summary>
@@ -106,7 +107,9 @@ public static T Load<T>(string providerId, string name, Action<T> onLoaded, Conn
106107

107108
return result;
108109
}
110+
#endregion
109111

112+
#region Private methods
110113
private static string GetStorageFileName(string providerId, string name)
111114
{
112115
return providerId + "_" + name + ".xml";
@@ -130,8 +133,9 @@ private static void ExecuteNoncriticalOperation(
130133
}
131134
catch (Exception ex)
132135
{
133-
logger.WriteMessageAsync(LoggerMessageCategory.Warning, failureMessage, failureMessageArg, ex);
136+
logger.WriteMessageAsync(LoggerMessageCategory.Warning, failureMessage, failureMessageArg, ex).GetAwaiter().GetResult();
134137
}
135138
}
139+
#endregion
136140
}
137141
}

src/Handler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Unchase.OpenAPI.ConnectedService
99
[ConnectedServiceHandlerExport(Constants.ProviderId, AppliesTo = "VB | CSharp | Web")]
1010
internal class Handler : ConnectedServiceHandler
1111
{
12+
#region Methods
1213
public override async Task<AddServiceInstanceResult> AddServiceInstanceAsync(ConnectedServiceHandlerContext context, CancellationToken cancellationToken)
1314
{
1415
var instance = (Instance)context.ServiceInstance;
@@ -53,5 +54,6 @@ private static async Task<BaseCodeGenDescriptor> ReGenerateCodeAsync(ConnectedSe
5354
var clientFilePath = await codeGenDescriptor.AddGeneratedCodeAsync();
5455
return codeGenDescriptor;
5556
}
57+
#endregion
5658
}
5759
}

src/Instance.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ namespace Unchase.OpenAPI.ConnectedService
55
{
66
internal class Instance : ConnectedServiceInstance
77
{
8+
#region Properties
89
public ServiceConfiguration ServiceConfig { get; set; }
10+
911
public string SpecificationTempPath { get; set; }
12+
#endregion
1013

14+
#region Constructors
1115
public Instance()
1216
{
1317
InstanceId = Constants.ExtensionCategory;
1418
Name = Constants.DefaultServiceName;
1519
}
20+
#endregion
1621
}
1722
}

src/Models/UserSettings.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ private UserSettings()
6363
#endregion
6464

6565
#region Public methods
66+
/// <summary>
67+
/// Set properties from <see cref="UserSettings"/>.
68+
/// </summary>
69+
/// <param name="serviceConfiguration"><see cref="ServiceConfiguration"/>.</param>
70+
internal void SetFromServiceConfiguration(ServiceConfiguration serviceConfiguration)
71+
{
72+
this.CopySpecification = serviceConfiguration.CopySpecification;
73+
this.Endpoint = serviceConfiguration.Endpoint;
74+
this.GenerateCSharpClient = serviceConfiguration.GenerateCSharpClient;
75+
this.GenerateCSharpController = serviceConfiguration.GenerateCSharpController;
76+
this.GenerateTypeScriptClient = serviceConfiguration.GenerateTypeScriptClient;
77+
this.OpenGeneratedFilesOnComplete = serviceConfiguration.OpenGeneratedFilesOnComplete;
78+
this.Runtime = serviceConfiguration.Runtime;
79+
this.ServiceName = serviceConfiguration.ServiceName;
80+
this.UseRelativePath = serviceConfiguration.UseRelativePath;
81+
this.Variables = serviceConfiguration.Variables;
82+
}
83+
6684
public void Save()
6785
{
6886
UserSettingsPersistenceHelper.Save(this, Constants.ProviderId, UserSettings.Name, null, this._logger);

src/Provider.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Unchase.OpenAPI.ConnectedService
1212
[ConnectedServiceProviderExport(Constants.ProviderId, SupportsUpdate = true)]
1313
internal class Provider : ConnectedServiceProvider
1414
{
15+
#region Constructors
1516
public Provider()
1617
{
1718
Category = Constants.ExtensionCategory;
@@ -24,11 +25,12 @@ public Provider()
2425
BitmapSizeOptions.FromWidthAndHeight(64, 64)
2526
);
2627
CreatedBy = Constants.Author;
27-
Version = new Version(1, 1, 0, 0);
2828
Version = typeof(Provider).Assembly.GetName().Version;
2929
MoreInfoUri = new Uri(Constants.Website);
3030
}
31+
#endregion
3132

33+
#region Methods
3234
public override Task<ConnectedServiceConfigurator> CreateConfiguratorAsync(ConnectedServiceProviderContext context)
3335
{
3436
return Task.FromResult<ConnectedServiceConfigurator>(new Wizard(context));
@@ -39,5 +41,6 @@ public override IEnumerable<Tuple<string, Uri>> GetSupportedTechnologyLinks()
3941
yield return Tuple.Create("OpenAPI (Swagger)", new Uri("https://swagger.io/docs/specification/about/"));
4042
yield return Tuple.Create("NSwag", new Uri("https://github.com/RSuter/NSwag"));
4143
}
44+
#endregion
4245
}
4346
}

src/ViewModels/CSharpClientSettingsViewModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Unchase.OpenAPI.ConnectedService.ViewModels
99
{
1010
internal class CSharpClientSettingsViewModel : ConnectedServiceWizardPage
1111
{
12+
#region Properties
1213
public string GeneratedFileName { get; set; }
1314

1415
public OpenApiToCSharpClientCommand Command { get; set; } = new OpenApiToCSharpClientCommand
@@ -26,13 +27,16 @@ internal class CSharpClientSettingsViewModel : ConnectedServiceWizardPage
2627
public CSharpClassStyle[] ClassStyles { get; } = Enum.GetNames(typeof(CSharpClassStyle))
2728
.Select(t => (CSharpClassStyle)Enum.Parse(typeof(CSharpClassStyle), t))
2829
.ToArray();
30+
#endregion
2931

32+
#region Constructors
3033
public CSharpClientSettingsViewModel() : base()
3134
{
3235
this.Title = "CSharp Client Settings";
3336
this.Description = "Settings for generating CSharp client";
3437
this.Legend = "CSharp Client Settings";
3538
this.View = new CSharpClientSettings {DataContext = this};
3639
}
40+
#endregion
3741
}
3842
}

src/ViewModels/CSharpControllerSettingsViewModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Unchase.OpenAPI.ConnectedService.ViewModels
1010
{
1111
internal class CSharpControllerSettingsViewModel : ConnectedServiceWizardPage
1212
{
13+
#region Properties
1314
public OpenApiToCSharpControllerCommand Command { get; set; } = new OpenApiToCSharpControllerCommand { Namespace = string.Empty };
1415

1516
/// <summary>Gets the list of operation modes.</summary>
@@ -36,13 +37,16 @@ internal class CSharpControllerSettingsViewModel : ConnectedServiceWizardPage
3637
public CSharpControllerRouteNamingStrategy[] RouteNamingStrategies { get; } = Enum.GetNames(typeof(CSharpControllerRouteNamingStrategy))
3738
.Select(t => (CSharpControllerRouteNamingStrategy)Enum.Parse(typeof(CSharpControllerRouteNamingStrategy), t))
3839
.ToArray();
40+
#endregion
3941

42+
#region Constructors
4043
public CSharpControllerSettingsViewModel() : base()
4144
{
4245
this.Title = "CSharp Controller Settings";
4346
this.Description = "Settings for generating CSharp controller";
4447
this.Legend = "CSharp Controller Settings";
4548
this.View = new CSharpControllerSettings {DataContext = this};
4649
}
50+
#endregion
4751
}
4852
}

src/ViewModels/TypeScriptClientSettingsViewModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Unchase.OpenAPI.ConnectedService.ViewModels
1010
{
1111
internal class TypeScriptClientSettingsViewModel : ConnectedServiceWizardPage
1212
{
13+
#region Properties
1314
public OpenApiToTypeScriptClientCommand Command { get; set; } = new OpenApiToTypeScriptClientCommand();
1415

1516
/// <summary>Gets the supported TypeScript versions.</summary>
@@ -57,13 +58,16 @@ internal class TypeScriptClientSettingsViewModel : ConnectedServiceWizardPage
5758
public TypeScriptNullValue[] NullValues { get; } = Enum.GetNames(typeof(TypeScriptNullValue))
5859
.Select(t => (TypeScriptNullValue)Enum.Parse(typeof(TypeScriptNullValue), t))
5960
.ToArray();
61+
#endregion
6062

63+
#region Constructors
6164
public TypeScriptClientSettingsViewModel() : base()
6265
{
6366
this.Title = "TypeScript Client Settings";
6467
this.Description = "Settings for generating TypeScript client";
6568
this.Legend = "TypeScript Client Settings";
6669
this.View = new TypeScriptClientSettings {DataContext = this};
6770
}
71+
#endregion
6872
}
6973
}

0 commit comments

Comments
 (0)