-
-
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.
Load controlles and types via command line (NSwagStudio), #953
- Loading branch information
Showing
20 changed files
with
351 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using NSwag.Commands; | ||
using System.Threading.Tasks; | ||
using NSwag.SwaggerGeneration; | ||
|
||
namespace NSwag.Commands | ||
|
@@ -15,12 +15,11 @@ namespace NSwag.Commands | |
/// <seealso cref="NSwag.Commands.AssemblyTypeToSwaggerCommandBase" /> | ||
public class AssemblyTypeToSwaggerCommand : AssemblyTypeToSwaggerCommandBase | ||
{ | ||
|
||
/// <summary>Creates a new generator instance.</summary> | ||
/// <returns>The generator.</returns> | ||
protected override AssemblyTypeToSwaggerGeneratorBase CreateGenerator() | ||
protected override Task<AssemblyTypeToSwaggerGeneratorBase> CreateGeneratorAsync() | ||
{ | ||
return new AssemblyTypeToSwaggerGenerator(Settings); | ||
return Task.FromResult<AssemblyTypeToSwaggerGeneratorBase>(new AssemblyTypeToSwaggerGenerator(Settings)); | ||
} | ||
} | ||
} |
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,40 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="ListTypesCommand.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 System; | ||
using System.Threading.Tasks; | ||
using NSwag.SwaggerGeneration; | ||
|
||
namespace NSwag.Commands | ||
{ | ||
/// <summary>The generator.</summary> | ||
/// <seealso cref="NSwag.Commands.WebApiToSwaggerCommandBase" /> | ||
public class ListTypesCommand : ListTypesCommandBase | ||
{ | ||
/// <summary>Creates a new generator instance.</summary> | ||
/// <returns>The generator.</returns> | ||
/// <summary>Creates a new generator instance.</summary> | ||
/// <returns>The generator.</returns> | ||
/// <exception cref="InvalidOperationException">Configuraiton file does not contain AssemblyTypeToSwagger settings.</exception> | ||
protected override async Task<AssemblyTypeToSwaggerGeneratorBase> CreateGeneratorAsync() | ||
{ | ||
if (!string.IsNullOrEmpty(File)) | ||
{ | ||
var document = await NSwagDocument.LoadAsync(File); | ||
|
||
var settings = document.SwaggerGenerators?.AssemblyTypeToSwaggerCommand?.Settings; | ||
if (settings == null) | ||
throw new InvalidOperationException("Configuraiton file does not contain AssemblyTypeToSwagger settings."); | ||
|
||
return new AssemblyTypeToSwaggerGenerator(settings); | ||
} | ||
else | ||
return new AssemblyTypeToSwaggerGenerator(Settings); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/NSwag.AssemblyLoaderCore/Commands/ListWebApiControllersCommand.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,40 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="ListWebApiControllersCommand.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 System; | ||
using System.Threading.Tasks; | ||
using NSwag.SwaggerGeneration.WebApi; | ||
|
||
namespace NSwag.Commands | ||
{ | ||
/// <summary>The generator.</summary> | ||
/// <seealso cref="NSwag.Commands.WebApiToSwaggerCommandBase" /> | ||
public class ListWebApiControllersCommand : ListWebApiControllersCommandBase | ||
{ | ||
/// <summary>Creates a new generator instance.</summary> | ||
/// <returns>The generator.</returns> | ||
/// <summary>Creates a new generator instance.</summary> | ||
/// <returns>The generator.</returns> | ||
/// <exception cref="InvalidOperationException">Configuraiton file does not contain WebApiToSwagger settings.</exception> | ||
protected override async Task<WebApiAssemblyToSwaggerGeneratorBase> CreateGeneratorAsync() | ||
{ | ||
if (!string.IsNullOrEmpty(File)) | ||
{ | ||
var document = await NSwagDocument.LoadAsync(File); | ||
|
||
var settings = document.SwaggerGenerators?.WebApiToSwaggerCommand?.Settings; | ||
if (settings == null) | ||
throw new InvalidOperationException("Configuraiton file does not contain WebApiToSwagger settings."); | ||
|
||
return new WebApiAssemblyToSwaggerGenerator(settings); | ||
} | ||
else | ||
return new WebApiAssemblyToSwaggerGenerator(Settings); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,20 +6,20 @@ | |
// <author>Rico Suter, [email protected]</author> | ||
//----------------------------------------------------------------------- | ||
|
||
using NSwag.Commands; | ||
using System.Threading.Tasks; | ||
using NSwag.SwaggerGeneration.WebApi; | ||
|
||
namespace NSwag.Commands | ||
{ | ||
/// <summary></summary> | ||
/// <summary>The generator.</summary> | ||
/// <seealso cref="NSwag.Commands.WebApiToSwaggerCommandBase" /> | ||
public class WebApiToSwaggerCommand : WebApiToSwaggerCommandBase | ||
{ | ||
/// <summary>Creates a new generator instance.</summary> | ||
/// <returns>The generator.</returns> | ||
protected override WebApiAssemblyToSwaggerGeneratorBase CreateGenerator() | ||
protected override Task<WebApiAssemblyToSwaggerGeneratorBase> CreateGeneratorAsync() | ||
{ | ||
return new WebApiAssemblyToSwaggerGenerator(Settings); | ||
return Task.FromResult<WebApiAssemblyToSwaggerGeneratorBase>(new WebApiAssemblyToSwaggerGenerator(Settings)); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Threading.Tasks; | ||
using NConsole; | ||
using Newtonsoft.Json; | ||
using NSwag.Commands.Base; | ||
using NSwag.SwaggerGeneration; | ||
|
||
namespace NSwag.Commands | ||
{ | ||
public abstract class AssemblyOutputCommandBase : OutputCommandBase | ||
{ | ||
public AssemblyOutputCommandBase() | ||
{ | ||
Settings = new AssemblyTypeToSwaggerGeneratorSettings(); | ||
} | ||
|
||
[JsonIgnore] | ||
public AssemblyTypeToSwaggerGeneratorSettings Settings { get; set; } | ||
|
||
[Argument(Name = "AssemblyConfig", IsRequired = false, Description = "The path to the assembly App.config or Web.config (optional).")] | ||
public string AssemblyConfig | ||
{ | ||
get { return Settings.AssemblyConfig; } | ||
set { Settings.AssemblyConfig = value; } | ||
} | ||
|
||
[Argument(Name = "ReferencePaths", IsRequired = false, Description = "The paths to search for referenced assembly files (comma separated).")] | ||
public string[] ReferencePaths | ||
{ | ||
get { return Settings.ReferencePaths; } | ||
set { Settings.ReferencePaths = value; } | ||
} | ||
|
||
/// <summary>Creates a new generator instance.</summary> | ||
/// <returns>The generator.</returns> | ||
protected abstract Task<AssemblyTypeToSwaggerGeneratorBase> CreateGeneratorAsync(); | ||
} | ||
} |
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.