Skip to content

Commit

Permalink
1) Fix #10 issue;
Browse files Browse the repository at this point in the history
2) Add small fixes.
  • Loading branch information
Chebotov Nikolay committed Nov 22, 2019
1 parent 9623163 commit 6b00ece
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

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).

## v1.3.10 `2019-11-22`

- [x] Fix [issue #10](https://github.com/unchase/Unchase.OpenAPI.Connectedservice/issues/10)
- [x] Add small fixes

## v1.3.9 `2019-11-14`

- [x] Add output relative project path in the first wizard page
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ Install from `Tools -> Extensions and Updates` menu inside [Visual Studio](https

## Settings Meaning

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):
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):

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

## Custom Commands

### `Open in NSwagStudio` Command

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).
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).

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).
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).

#### Prerequisite

> 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.
> 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.
#### Solution Explorer

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

#### Path to NSwagStudio.exe

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`.
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`.

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

Expand Down
6 changes: 5 additions & 1 deletion src/Common/UserSettingsPersistenceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Unchase.OpenAPI.ConnectedService.Common
{
internal class UserSettingsPersistenceHelper
{
#region Public methods
/// <summary>
/// Saves user settings to isolated storage. The data is stored with the user's roaming profile.
/// </summary>
Expand Down Expand Up @@ -106,7 +107,9 @@ public static T Load<T>(string providerId, string name, Action<T> onLoaded, Conn

return result;
}
#endregion

#region Private methods
private static string GetStorageFileName(string providerId, string name)
{
return providerId + "_" + name + ".xml";
Expand All @@ -130,8 +133,9 @@ private static void ExecuteNoncriticalOperation(
}
catch (Exception ex)
{
logger.WriteMessageAsync(LoggerMessageCategory.Warning, failureMessage, failureMessageArg, ex);
logger.WriteMessageAsync(LoggerMessageCategory.Warning, failureMessage, failureMessageArg, ex).GetAwaiter().GetResult();
}
}
#endregion
}
}
2 changes: 2 additions & 0 deletions src/Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Unchase.OpenAPI.ConnectedService
[ConnectedServiceHandlerExport(Constants.ProviderId, AppliesTo = "VB | CSharp | Web")]
internal class Handler : ConnectedServiceHandler
{
#region Methods
public override async Task<AddServiceInstanceResult> AddServiceInstanceAsync(ConnectedServiceHandlerContext context, CancellationToken cancellationToken)
{
var instance = (Instance)context.ServiceInstance;
Expand Down Expand Up @@ -53,5 +54,6 @@ private static async Task<BaseCodeGenDescriptor> ReGenerateCodeAsync(ConnectedSe
var clientFilePath = await codeGenDescriptor.AddGeneratedCodeAsync();
return codeGenDescriptor;
}
#endregion
}
}
5 changes: 5 additions & 0 deletions src/Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ namespace Unchase.OpenAPI.ConnectedService
{
internal class Instance : ConnectedServiceInstance
{
#region Properties
public ServiceConfiguration ServiceConfig { get; set; }

public string SpecificationTempPath { get; set; }
#endregion

#region Constructors
public Instance()
{
InstanceId = Constants.ExtensionCategory;
Name = Constants.DefaultServiceName;
}
#endregion
}
}
18 changes: 18 additions & 0 deletions src/Models/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ private UserSettings()
#endregion

#region Public methods
/// <summary>
/// Set properties from <see cref="UserSettings"/>.
/// </summary>
/// <param name="serviceConfiguration"><see cref="ServiceConfiguration"/>.</param>
internal void SetFromServiceConfiguration(ServiceConfiguration serviceConfiguration)
{
this.CopySpecification = serviceConfiguration.CopySpecification;
this.Endpoint = serviceConfiguration.Endpoint;
this.GenerateCSharpClient = serviceConfiguration.GenerateCSharpClient;
this.GenerateCSharpController = serviceConfiguration.GenerateCSharpController;
this.GenerateTypeScriptClient = serviceConfiguration.GenerateTypeScriptClient;
this.OpenGeneratedFilesOnComplete = serviceConfiguration.OpenGeneratedFilesOnComplete;
this.Runtime = serviceConfiguration.Runtime;
this.ServiceName = serviceConfiguration.ServiceName;
this.UseRelativePath = serviceConfiguration.UseRelativePath;
this.Variables = serviceConfiguration.Variables;
}

public void Save()
{
UserSettingsPersistenceHelper.Save(this, Constants.ProviderId, UserSettings.Name, null, this._logger);
Expand Down
5 changes: 4 additions & 1 deletion src/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Unchase.OpenAPI.ConnectedService
[ConnectedServiceProviderExport(Constants.ProviderId, SupportsUpdate = true)]
internal class Provider : ConnectedServiceProvider
{
#region Constructors
public Provider()
{
Category = Constants.ExtensionCategory;
Expand All @@ -24,11 +25,12 @@ public Provider()
BitmapSizeOptions.FromWidthAndHeight(64, 64)
);
CreatedBy = Constants.Author;
Version = new Version(1, 1, 0, 0);
Version = typeof(Provider).Assembly.GetName().Version;
MoreInfoUri = new Uri(Constants.Website);
}
#endregion

#region Methods
public override Task<ConnectedServiceConfigurator> CreateConfiguratorAsync(ConnectedServiceProviderContext context)
{
return Task.FromResult<ConnectedServiceConfigurator>(new Wizard(context));
Expand All @@ -39,5 +41,6 @@ public override IEnumerable<Tuple<string, Uri>> GetSupportedTechnologyLinks()
yield return Tuple.Create("OpenAPI (Swagger)", new Uri("https://swagger.io/docs/specification/about/"));
yield return Tuple.Create("NSwag", new Uri("https://github.com/RSuter/NSwag"));
}
#endregion
}
}
4 changes: 4 additions & 0 deletions src/ViewModels/CSharpClientSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Unchase.OpenAPI.ConnectedService.ViewModels
{
internal class CSharpClientSettingsViewModel : ConnectedServiceWizardPage
{
#region Properties
public string GeneratedFileName { get; set; }

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

#region Constructors
public CSharpClientSettingsViewModel() : base()
{
this.Title = "CSharp Client Settings";
this.Description = "Settings for generating CSharp client";
this.Legend = "CSharp Client Settings";
this.View = new CSharpClientSettings {DataContext = this};
}
#endregion
}
}
4 changes: 4 additions & 0 deletions src/ViewModels/CSharpControllerSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Unchase.OpenAPI.ConnectedService.ViewModels
{
internal class CSharpControllerSettingsViewModel : ConnectedServiceWizardPage
{
#region Properties
public OpenApiToCSharpControllerCommand Command { get; set; } = new OpenApiToCSharpControllerCommand { Namespace = string.Empty };

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

#region Constructors
public CSharpControllerSettingsViewModel() : base()
{
this.Title = "CSharp Controller Settings";
this.Description = "Settings for generating CSharp controller";
this.Legend = "CSharp Controller Settings";
this.View = new CSharpControllerSettings {DataContext = this};
}
#endregion
}
}
4 changes: 4 additions & 0 deletions src/ViewModels/TypeScriptClientSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Unchase.OpenAPI.ConnectedService.ViewModels
{
internal class TypeScriptClientSettingsViewModel : ConnectedServiceWizardPage
{
#region Properties
public OpenApiToTypeScriptClientCommand Command { get; set; } = new OpenApiToTypeScriptClientCommand();

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

#region Constructors
public TypeScriptClientSettingsViewModel() : base()
{
this.Title = "TypeScript Client Settings";
this.Description = "Settings for generating TypeScript client";
this.Legend = "TypeScript Client Settings";
this.View = new TypeScriptClientSettings {DataContext = this};
}
#endregion
}
}
3 changes: 3 additions & 0 deletions src/Wizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public Wizard(ConnectedServiceProviderContext context)
this.UserSettings = UserSettings.Load(context.Logger);
this.UserSettings.ProjectPath = this.ProjectPath;

if (this.Context.IsUpdating)
this.UserSettings.SetFromServiceConfiguration(context.GetExtendedDesignerData<ServiceConfiguration>());

ConfigOpenApiEndpointViewModel = new ConfigOpenApiEndpointViewModel(this.UserSettings, this);
CSharpClientSettingsViewModel = new CSharpClientSettingsViewModel();
TypeScriptClientSettingsViewModel = new TypeScriptClientSettingsViewModel();
Expand Down

0 comments on commit 6b00ece

Please sign in to comment.