Skip to content

Commit

Permalink
Merge pull request RicoSuter#2520 from RicoSuter/master
Browse files Browse the repository at this point in the history
Release v13.1.4
  • Loading branch information
RicoSuter committed Nov 13, 2019
2 parents 46ec023 + d2dab16 commit fd9cd3a
Show file tree
Hide file tree
Showing 94 changed files with 1,721 additions and 1,401 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.1.2.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v10.0.0.0))",
"x-generator": "NSwag v13.1.4.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v10.0.0.0))",
"swagger": "2.0",
"info": {
"title": "My Title",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.1.2.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.1.4.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v11.0.0.0))",
"swagger": "2.0",
"info": {
"title": "My Title",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.1.2.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.1.4.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v11.0.0.0))",
"swagger": "2.0",
"info": {
"title": "My Title",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.1.2.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.1.4.0 (NJsonSchema v10.0.27.0 (Newtonsoft.Json v11.0.0.0))",
"swagger": "2.0",
"info": {
"title": "My Title",
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.Annotations/NSwag.Annotations.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.0;net45;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.1.3</Version>
<Version>13.1.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2019</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>NSwag.ApiDescription.Client</id>
<version>13.1.3</version>
<version>13.1.4</version>
<authors>Rico Suter</authors>
<owners>Rico Suter</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand All @@ -15,8 +15,8 @@
<repository type="git" url="https://github.com/RicoSuter/NSwag.git"/>
<developmentDependency>true</developmentDependency>
<dependencies>
<dependency id="Microsoft.Extensions.ApiDescription.Client" version="0.3.0-preview7.19365.7" />
<dependency id="NSwag.MSBuild" version="13.1.3" />
<dependency id="Microsoft.Extensions.ApiDescription.Client" version="3.0.0" />
<dependency id="NSwag.MSBuild" version="13.1.4" />
</dependencies>
<references />
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Command Condition="! %(FirstForGenerator)">%(Command) /GenerateExceptionClasses:false</Command>
</CurrentOpenApiReference>
<CurrentOpenApiReference>
<Command>%(Command) /input:%(FullPath) /output:%(OutputPath) %(Options)</Command>
<Command>%(Command) /input:"%(FullPath)" /output:"%(OutputPath)" %(Options)</Command>
</CurrentOpenApiReference>
</ItemGroup>

Expand All @@ -37,7 +37,7 @@
<Command>$(_NSwagCommand) swagger2tsclient /className:%(ClassName) /namespace:%(Namespace)</Command>
</CurrentOpenApiReference>
<CurrentOpenApiReference>
<Command>%(Command) /input:%(FullPath) /output:%(OutputPath) %(Options)</Command>
<Command>%(Command) /input:"%(FullPath)" /output:"%(OutputPath)" %(Options)</Command>
</CurrentOpenApiReference>
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net45</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.1.3</Version>
<Version>13.1.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2019</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
1 change: 1 addition & 0 deletions src/NSwag.AspNet.Owin/SwaggerUi3/oauth2-redirect.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html>
<html lang="en-US">
<title>Swagger UI: OAuth2 Redirect</title>
<body onload="run()">
</body>
</html>
Expand Down
26 changes: 13 additions & 13 deletions src/NSwag.AspNet.Owin/SwaggerUi3/swagger-ui-bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/NSwag.AspNet.Owin/SwaggerUi3/swagger-ui.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/NSwag.AspNet.Owin/SwaggerUi3/swagger-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net45</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.1.3</Version>
<Version>13.1.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2019</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PlatformTarget>x86</PlatformTarget>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<Version>13.1.3</Version>
<Version>13.1.4</Version>
<Authors>Rico Suter</Authors>
<Company>Rico Suter</Company>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PlatformTarget Condition="'$(TargetFramework)'=='net461'">x64</PlatformTarget>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<Version>13.1.3</Version>
<Version>13.1.4</Version>
<Authors>Rico Suter</Authors>
<Company>Rico Suter</Company>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
Expand Down
39 changes: 39 additions & 0 deletions src/NSwag.AspNetCore/ApiverseUiSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//-----------------------------------------------------------------------
// <copyright file="ApiverseUiSettings.cs" company="NSwag">
// Copyright (c) Rico Suter. All rights reserved.
// </copyright>
// <license>https://github.com/RicoSuter/NSwag/blob/master/LICENSE.md</license>
// <author>Rico Suter, [email protected]</author>
//-----------------------------------------------------------------------

using Microsoft.AspNetCore.Http;

namespace NSwag.AspNetCore
{
/// <summary>
/// The Apiverse.io UI settings.
/// </summary>
public class ApiverseUiSettings : SwaggerUiSettingsBase
{
/// <summary>Initializes a new instance of the <see cref="ApiverseUiSettings"/> class.</summary>
public ApiverseUiSettings()
{
DocumentPath = "swagger/v1/swagger.json";
}

/// <summary>
/// Gets or sets the global document ID to compare with.
/// </summary>
public string CompareWith { get; set; }

/// <summary>
/// Gets or sets the Apiverse.io instance URL.
/// </summary>
public string ApiverseUrl { get; set; } = "https://apiverse.io";

internal override string TransformHtml(string html, HttpRequest request)
{
return html;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,75 @@ public static IApplicationBuilder UseSwaggerUi(
return app;
}

/// <summary>Adds a redirect to the Apiverse.io user interface to the pipeline (default route: /apiverse).</summary>
/// <remarks>The settings.GeneratorSettings property does not have any effect.</remarks>
/// <param name="app">The app.</param>
/// <param name="configure">Configure the UI settings.</param>
/// <returns>The app builder.</returns>
public static IApplicationBuilder UseApiverse(
this IApplicationBuilder app,
Action<ApiverseUiSettings> configure = null)
{
var settings = configure == null ? app.ApplicationServices.GetService<IOptions<ApiverseUiSettings>>()?.Value : null ?? new ApiverseUiSettings();
settings.Path = "/apiverse";
configure?.Invoke(settings);

var path = settings.Path;
var compareToIds = (string.IsNullOrEmpty(settings.CompareWith) ? "local:local:0:0:0:latest" : settings.CompareWith).Split(':');
app.Use(async (context, next) =>
{
if (context.Request.Path.HasValue &&
string.Equals(context.Request.Path.Value.Trim('/'), path.Trim('/'), StringComparison.OrdinalIgnoreCase))
{
context.Response.Headers["Content-Type"] = "text/html; charset=utf-8";
context.Response.StatusCode = 200;
await context.Response.WriteAsync(@"<!DOCTYPE html>
<html lang=""en"">
<head>
<meta charset=""UTF-8"">
<meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
<meta http-equiv=""X-UA-Compatible"" content=""ie=edge"">
<title>NSwag to Apiverse.to</title>
</head>
<body>
<form id='myForm' method='post' action='" + settings.ApiverseUrl +
@"/api/endpoints/local?organizationName=" + compareToIds[0] +
@"&projectName=" + compareToIds[1] +
@"&serviceId=" + compareToIds[2] +
@"&endpointId=" + compareToIds[3] +
@"&environmentId=" + compareToIds[4] +
@"&documentId=" + (compareToIds[5] == "latest" ? "" : compareToIds[5]) + @"'>
<input type=""text"" name=""data"" id=""myData"" style=""display: none"" />
</form>
Please wait...
<script>
fetch('" + settings.DocumentPath + @"').then(function (response) {
return response.text();
}, function() { alert(""Could not downlaod '" + settings.DocumentPath + @"'."") }).then(function (text) {
var form = document.getElementById('myForm');
var data = document.getElementById('myData');
data.value = btoa(text);
var key = 'upload_" + settings.ApiverseUrl + @"';
if (window.localStorage.getItem(key) == 'ok' ||
confirm(""Do you want to view the specification on '" + settings.ApiverseUrl + @"'?\nThis choice will stored and not asked again."")) {
window.localStorage.setItem(key, 'ok');
form.submit();
}
});
</script>
</body>
</html>
");
}
else
{
await next();
}
});

return app;
}

private static void UseSwaggerUiWithDocumentNamePlaceholderExpanding(IApplicationBuilder app,
SwaggerUiSettingsBase settings,
Action<string, string> register,
Expand Down
4 changes: 2 additions & 2 deletions src/NSwag.AspNetCore/NSwag.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net451;netstandard1.6;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.1.3</Version>
<Version>13.1.4</Version>
<PackageTags>Swagger Documentation AspNetCore NetCore TypeScript CodeGen</PackageTags>
<Copyright>Copyright © Rico Suter, 2019</Copyright>
<PackageLicenseUrl>https://github.com/RicoSuter/NSwag/blob/master/LICENSE.md</PackageLicenseUrl>
Expand All @@ -21,7 +21,7 @@
<MicrosoftAspNetCoreMvcCorePackageVersion>1.0.3</MicrosoftAspNetCoreMvcCorePackageVersion>
<MicrosoftAspNetCoreMvcFormattersJsonPackageVersion>1.0.3</MicrosoftAspNetCoreMvcFormattersJsonPackageVersion>
<MicrosoftAspNetCoreStaticFilesPackageVersion>1.0.2</MicrosoftAspNetCoreStaticFilesPackageVersion>
<MicrosoftExtensionsApiDescriptionServerPackageVersion>0.3.0-preview7.19365.7</MicrosoftExtensionsApiDescriptionServerPackageVersion>
<MicrosoftExtensionsApiDescriptionServerPackageVersion>3.0.0</MicrosoftExtensionsApiDescriptionServerPackageVersion>
<MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>1.0.1</MicrosoftExtensionsFileProvidersEmbeddedPackageVersion>
<NETStandardLibraryPackageVersion>1.6.1</NETStandardLibraryPackageVersion>
<SystemIOFileSystemPackageVersion>4.3.0</SystemIOFileSystemPackageVersion>
Expand Down
3 changes: 3 additions & 0 deletions src/NSwag.AspNetCore/OAuth2ClientSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ public class OAuth2ClientSettings

/// <summary>Gets or sets the additional query string parameters.</summary>
public IDictionary<string, string> AdditionalQueryStringParameters { get; } = new Dictionary<string, string>();

/// <summary>Proof Key for Code Exchange. Only applies to `accessCode` flow. Supported in SwaggerUI 3.</summary>
public bool UsePkceWithAuthorizationCodeGrant { get; set; }
}
}
3 changes: 2 additions & 1 deletion src/NSwag.AspNetCore/SwaggerUi3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
realm: "{Realm}",
appName: "{AppName}",
scopeSeparator: "{ScopeSeparator}",
additionalQueryStringParams: {AdditionalQueryStringParameters}
additionalQueryStringParams: {AdditionalQueryStringParameters},
usePkceWithAuthorizationCodeGrant: {UsePkceWithAuthorizationCodeGrant}
});
}

Expand Down
1 change: 1 addition & 0 deletions src/NSwag.AspNetCore/SwaggerUi3/oauth2-redirect.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html>
<html lang="en-US">
<title>Swagger UI: OAuth2 Redirect</title>
<body onload="run()">
</body>
</html>
Expand Down
26 changes: 13 additions & 13 deletions src/NSwag.AspNetCore/SwaggerUi3/swagger-ui-bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/NSwag.AspNetCore/SwaggerUi3/swagger-ui.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/NSwag.AspNetCore/SwaggerUi3/swagger-ui.js

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/NSwag.AspNetCore/SwaggerUi3Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,18 @@ internal override string TransformHtml(string html, HttpRequest request)
foreach (var property in oauth2Settings.GetType().GetRuntimeProperties())
{
var value = property.GetValue(oauth2Settings);
html = html.Replace("{" + property.Name + "}", value is IDictionary ? JsonConvert.SerializeObject(value) : value?.ToString() ?? "");
if (value is IDictionary dictionary)
{
html = html.Replace("{" + property.Name + "}", JsonConvert.SerializeObject(dictionary));
}
else if (value is bool boolean)
{
html = html.Replace("{" + property.Name + "}", boolean.ToString().ToLowerInvariant());
}
else
{
html = html.Replace("{" + property.Name + "}", value?.ToString() ?? "");
}
}

html = html.Replace("{Urls}", !SwaggerRoutes.Any() ?
Expand Down
5 changes: 2 additions & 3 deletions src/NSwag.AspNetCore/build/NSwag.AspNetCore.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<Project>
<PropertyGroup>
<!--
Disable document generation by default in NSwag.AspNetCore.targets. These settings help distinguish user settings
from changes made in Microsoft.Extensions.ApiDescription.Server.targets.
Disable document generation on build if property maintains this value into NSwag.AspNetCore.targets. This setting
helps distinguish user settings from changes made in Microsoft.Extensions.ApiDescription.Server.targets.
-->
<OpenApiGenerateDocuments Condition=" '$(OpenApiGenerateDocuments)' == '' ">default-false</OpenApiGenerateDocuments>
<OpenApiGenerateDocumentsOnBuild
Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == '' ">default-false</OpenApiGenerateDocumentsOnBuild>

Expand Down
17 changes: 8 additions & 9 deletions src/NSwag.AspNetCore/build/NSwag.AspNetCore.targets
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project>
<PropertyGroup Condition=" '$(OpenApiGenerateDocuments)' == 'default-false' ">
<PropertyGroup Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == 'default-false' ">
<!--
If user changed $(OpenApiDocumentsDirectory) but not $(OpenApiGenerateDocuments), enable document generation.
Otherwise, disable document generation.
Disable document generation on build by default. If user changed $(OpenApiDocumentsDirectory) but not
$(OpenApiGenerateDocumentsOnBuild) and feature is supported, enable document generation on build.
Changing $(OpenApiDocumentsDirectory) does nothing when $(OpenApiGenerateDocuments) is false.
-->
<OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>
<OpenApiGenerateDocuments
Condition=" '$(OpenApiDocumentsDirectory)' != '$(BaseIntermediateOutputPath)' ">true</OpenApiGenerateDocuments>
</PropertyGroup>
<PropertyGroup Condition=" '$(OpenApiGenerateDocumentsOnBuild)' == 'default-false' ">
<OpenApiGenerateDocumentsOnBuild>$(OpenApiGenerateDocuments)</OpenApiGenerateDocumentsOnBuild>
<OpenApiGenerateDocumentsOnBuild>false</OpenApiGenerateDocumentsOnBuild>
<OpenApiGenerateDocumentsOnBuild
Condition=" '$(OpenApiDocumentsDirectory)' != '$(BaseIntermediateOutputPath)' ">$(OpenApiGenerateDocuments)</OpenApiGenerateDocuments>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net451;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.1.3</Version>
<Version>13.1.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2019</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Loading

0 comments on commit fd9cd3a

Please sign in to comment.