Permalink
Please sign in to comment.
Showing
with
434 additions
and 0 deletions.
- +32 −0 samples/NSwag.Sample.NetOwinMiddleware/Controllers/ProductsController.cs
- +10 −0 samples/NSwag.Sample.NetOwinMiddleware/Models/Product.cs
- +177 −0 samples/NSwag.Sample.NetOwinMiddleware/NSwag.Sample.NetOwinMiddleware.csproj
- +34 −0 samples/NSwag.Sample.NetOwinMiddleware/Properties/AssemblyInfo.cs
- +35 −0 samples/NSwag.Sample.NetOwinMiddleware/Startup.cs
- +30 −0 samples/NSwag.Sample.NetOwinMiddleware/Web.Debug.config
- +31 −0 samples/NSwag.Sample.NetOwinMiddleware/Web.Release.config
- +59 −0 samples/NSwag.Sample.NetOwinMiddleware/Web.config
- +20 −0 samples/NSwag.Sample.NetOwinMiddleware/packages.config
- +6 −0 samples/Samples.sln
@@ -0,0 +1,32 @@ | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Web.Http; | |||
using NSwag.Sample.NetOwinMiddleware.Models; | |||
|
|||
namespace NSwag.Sample.NetOwinMiddleware.Controllers | |||
{ | |||
public class ProductsController : ApiController | |||
{ | |||
Product[] products = new Product[] | |||
{ | |||
new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 }, | |||
new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M }, | |||
new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M } | |||
}; | |||
|
|||
public IEnumerable<Product> GetAllProducts() | |||
{ | |||
return products; | |||
} | |||
|
|||
public IHttpActionResult GetProduct(int id) | |||
{ | |||
var product = products.FirstOrDefault((p) => p.Id == id); | |||
if (product == null) | |||
{ | |||
return NotFound(); | |||
} | |||
return Ok(product); | |||
} | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
namespace NSwag.Sample.NetOwinMiddleware.Models | |||
{ | |||
public class Product | |||
{ | |||
public int Id { get; set; } | |||
public string Name { get; set; } | |||
public string Category { get; set; } | |||
public decimal Price { get; set; } | |||
} | |||
} |
@@ -0,0 +1,177 @@ | |||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" /> | |||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |||
<PropertyGroup> | |||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
<ProductVersion> | |||
</ProductVersion> | |||
<SchemaVersion>2.0</SchemaVersion> | |||
<ProjectGuid>{F8839807-B6F6-41E3-BC98-DFAD3C03085E}</ProjectGuid> | |||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> | |||
<OutputType>Library</OutputType> | |||
<AppDesignerFolder>Properties</AppDesignerFolder> | |||
<RootNamespace>NSwag.Sample.NetOwinMiddleware</RootNamespace> | |||
<AssemblyName>NSwag.Sample.NetOwinMiddleware</AssemblyName> | |||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | |||
<UseIISExpress>true</UseIISExpress> | |||
<Use64BitIISExpress /> | |||
<IISExpressSSLPort /> | |||
<IISExpressAnonymousAuthentication /> | |||
<IISExpressWindowsAuthentication /> | |||
<IISExpressUseClassicPipelineMode /> | |||
<UseGlobalApplicationHostFile /> | |||
<NuGetPackageImportStamp> | |||
</NuGetPackageImportStamp> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
<DebugSymbols>true</DebugSymbols> | |||
<DebugType>full</DebugType> | |||
<Optimize>false</Optimize> | |||
<OutputPath>bin\</OutputPath> | |||
<DefineConstants>DEBUG;TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
<DebugSymbols>true</DebugSymbols> | |||
<DebugType>pdbonly</DebugType> | |||
<Optimize>true</Optimize> | |||
<OutputPath>bin\</OutputPath> | |||
<DefineConstants>TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Reference Include="Microsoft.CSharp" /> | |||
<Reference Include="Microsoft.Owin, Version=4.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Microsoft.Owin.FileSystems, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Microsoft.Owin.FileSystems.3.0.1\lib\net45\Microsoft.Owin.FileSystems.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Microsoft.Owin.Host.SystemWeb, Version=4.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.4.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Microsoft.Owin.StaticFiles, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Microsoft.Owin.StaticFiles.3.0.1\lib\net45\Microsoft.Owin.StaticFiles.dll</HintPath> | |||
</Reference> | |||
<Reference Include="NJsonSchema, Version=9.13.17.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\NJsonSchema.9.13.17\lib\net45\NJsonSchema.dll</HintPath> | |||
</Reference> | |||
<Reference Include="NSwag.AspNet.Owin, Version=12.0.13.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\NSwag.AspNet.Owin.12.0.13\lib\net45\NSwag.AspNet.Owin.dll</HintPath> | |||
</Reference> | |||
<Reference Include="NSwag.Core, Version=12.0.13.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\NSwag.Core.12.0.13\lib\net45\NSwag.Core.dll</HintPath> | |||
</Reference> | |||
<Reference Include="NSwag.SwaggerGeneration, Version=12.0.13.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\NSwag.SwaggerGeneration.12.0.13\lib\net45\NSwag.SwaggerGeneration.dll</HintPath> | |||
</Reference> | |||
<Reference Include="NSwag.SwaggerGeneration.WebApi, Version=12.0.13.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\NSwag.SwaggerGeneration.WebApi.12.0.13\lib\net45\NSwag.SwaggerGeneration.WebApi.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Net" /> | |||
<Reference Include="System.Net.Http" /> | |||
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Runtime.Serialization" /> | |||
<Reference Include="System.Web.DynamicData" /> | |||
<Reference Include="System.Web.Entity" /> | |||
<Reference Include="System.Web.ApplicationServices" /> | |||
<Reference Include="System.ComponentModel.DataAnnotations" /> | |||
<Reference Include="System" /> | |||
<Reference Include="System.Data" /> | |||
<Reference Include="System.Core" /> | |||
<Reference Include="System.Data.DataSetExtensions" /> | |||
<Reference Include="System.Web.Extensions" /> | |||
<Reference Include="System.Web.Http, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Web.Http.Owin, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | |||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.2.7\lib\net45\System.Web.Http.Owin.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Xml.Linq" /> | |||
<Reference Include="System.Drawing" /> | |||
<Reference Include="System.Web" /> | |||
<Reference Include="System.Xml" /> | |||
<Reference Include="System.Configuration" /> | |||
<Reference Include="System.Web.Services" /> | |||
<Reference Include="System.EnterpriseServices" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Reference Include="Newtonsoft.Json"> | |||
<HintPath>..\packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> | |||
</Reference> | |||
<Reference Include="System.Web.Http.WebHost"> | |||
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.4\lib\net45\System.Web.Http.WebHost.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform"> | |||
<HintPath>..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath> | |||
</Reference> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Content Include="Web.config" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Include="Controllers\ProductsController.cs" /> | |||
<Compile Include="Models\Product.cs" /> | |||
<Compile Include="Properties\AssemblyInfo.cs" /> | |||
<Compile Include="Startup.cs" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="packages.config" /> | |||
<None Include="Web.Debug.config"> | |||
<DependentUpon>Web.config</DependentUpon> | |||
</None> | |||
<None Include="Web.Release.config"> | |||
<DependentUpon>Web.config</DependentUpon> | |||
</None> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Folder Include="App_Data\" /> | |||
<Folder Include="App_Start\" /> | |||
</ItemGroup> | |||
<PropertyGroup> | |||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | |||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | |||
</PropertyGroup> | |||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> | |||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" /> | |||
<ProjectExtensions> | |||
<VisualStudio> | |||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> | |||
<WebProjectProperties> | |||
<UseIIS>True</UseIIS> | |||
<AutoAssignPort>True</AutoAssignPort> | |||
<DevelopmentServerPort>52772</DevelopmentServerPort> | |||
<DevelopmentServerVPath>/</DevelopmentServerVPath> | |||
<IISUrl>http://localhost:52772/</IISUrl> | |||
<NTLMAuthentication>False</NTLMAuthentication> | |||
<UseCustomServer>False</UseCustomServer> | |||
<CustomServerUrl> | |||
</CustomServerUrl> | |||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> | |||
</WebProjectProperties> | |||
</FlavorProperties> | |||
</VisualStudio> | |||
</ProjectExtensions> | |||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | |||
<PropertyGroup> | |||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | |||
</PropertyGroup> | |||
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" /> | |||
</Target> | |||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
Other similar extension points exist, see Microsoft.Common.targets. | |||
<Target Name="BeforeBuild"> | |||
</Target> | |||
<Target Name="AfterBuild"> | |||
</Target> | |||
--> | |||
</Project> |
@@ -0,0 +1,34 @@ | |||
using System.Reflection; | |||
using System.Runtime.InteropServices; | |||
|
|||
// General Information about an assembly is controlled through the following | |||
// set of attributes. Change these attribute values to modify the information | |||
// associated with an assembly. | |||
[assembly: AssemblyTitle("NSwag.Sample.NetOwinMiddleware")] | |||
[assembly: AssemblyDescription("")] | |||
[assembly: AssemblyConfiguration("")] | |||
[assembly: AssemblyCompany("")] | |||
[assembly: AssemblyProduct("NSwag.Sample.NetOwinMiddleware")] | |||
[assembly: AssemblyCopyright("Copyright © 2019")] | |||
[assembly: AssemblyTrademark("")] | |||
[assembly: AssemblyCulture("")] | |||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible | |||
// to COM components. If you need to access a type in this assembly from | |||
// COM, set the ComVisible attribute to true on that type. | |||
[assembly: ComVisible(false)] | |||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM | |||
[assembly: Guid("f8839807-b6f6-41e3-bc98-dfad3c03085e")] | |||
|
|||
// Version information for an assembly consists of the following four values: | |||
// | |||
// Major Version | |||
// Minor Version | |||
// Build Number | |||
// Revision | |||
// | |||
// You can specify all the values or you can default the Revision and Build Numbers | |||
// by using the '*' as shown below: | |||
[assembly: AssemblyVersion("1.0.0.0")] | |||
[assembly: AssemblyFileVersion("1.0.0.0")] |
@@ -0,0 +1,35 @@ | |||
using System.Web.Http; | |||
using Microsoft.Owin; | |||
using NSwag.AspNet.Owin; | |||
using Owin; | |||
|
|||
[assembly: OwinStartup(typeof(NSwag.Sample.NetOwinMiddleware.Startup))] | |||
|
|||
namespace NSwag.Sample.NetOwinMiddleware | |||
{ | |||
public class Startup | |||
{ | |||
public void Configuration(IAppBuilder app) | |||
{ | |||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=316888 | |||
var config = new HttpConfiguration(); | |||
|
|||
app.UseSwaggerUi3(typeof(Startup).Assembly, settings => | |||
{ | |||
// configure settings here | |||
// settings.GeneratorSettings.*: Generator settings and extension points | |||
// settings.*: Routing and UI settings | |||
settings.GeneratorSettings.DefaultUrlTemplate = "api/{controller}/{id?}"; | |||
}); | |||
app.UseWebApi(config); | |||
|
|||
config.MapHttpAttributeRoutes(); | |||
config.Routes.MapHttpRoute( | |||
name: "DefaultApi", | |||
routeTemplate: "api/{controller}/{id}", | |||
defaults: new { id = RouteParameter.Optional } | |||
); | |||
config.EnsureInitialized(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,30 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
|
|||
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 --> | |||
|
|||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> | |||
<!-- | |||
In the example below, the "SetAttributes" transform will change the value of | |||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator | |||
finds an attribute "name" that has a value of "MyDB". | |||
<connectionStrings> | |||
<add name="MyDB" | |||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" | |||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> | |||
</connectionStrings> | |||
--> | |||
<system.web> | |||
<!-- | |||
In the example below, the "Replace" transform will replace the entire | |||
<customErrors> section of your web.config file. | |||
Note that because there is only one customErrors section under the | |||
<system.web> node, there is no need to use the "xdt:Locator" attribute. | |||
<customErrors defaultRedirect="GenericError.htm" | |||
mode="RemoteOnly" xdt:Transform="Replace"> | |||
<error statusCode="500" redirect="InternalError.htm"/> | |||
</customErrors> | |||
--> | |||
</system.web> | |||
</configuration> |
@@ -0,0 +1,31 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
|
|||
<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 --> | |||
|
|||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> | |||
<!-- | |||
In the example below, the "SetAttributes" transform will change the value of | |||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator | |||
finds an attribute "name" that has a value of "MyDB". | |||
<connectionStrings> | |||
<add name="MyDB" | |||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" | |||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> | |||
</connectionStrings> | |||
--> | |||
<system.web> | |||
<compilation xdt:Transform="RemoveAttributes(debug)" /> | |||
<!-- | |||
In the example below, the "Replace" transform will replace the entire | |||
<customErrors> section of your web.config file. | |||
Note that because there is only one customErrors section under the | |||
<system.web> node, there is no need to use the "xdt:Locator" attribute. | |||
<customErrors defaultRedirect="GenericError.htm" | |||
mode="RemoteOnly" xdt:Transform="Replace"> | |||
<error statusCode="500" redirect="InternalError.htm"/> | |||
</customErrors> | |||
--> | |||
</system.web> | |||
</configuration> |

Oops, something went wrong.
0 comments on commit
b83fb18