Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseArtifactsOutput>true</UseArtifactsOutput>
<VersionPrefix>10.1.8</VersionPrefix>
<VersionPrefix>10.2.0</VersionPrefix>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
</PropertyGroup>
<PropertyGroup Condition=" '$(GITHUB_ACTIONS)' != '' AND '$(DEPENDABOT_JOB_ID)' == '' ">
Expand Down
4 changes: 2 additions & 2 deletions docs/configure-and-customize-redoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ app.UseReDoc(options =>
> [!TIP]
> To get started, you should base your custom `index.html` on the [default version](../src/Swashbuckle.AspNetCore.ReDoc/index.html).

[redoc-options]: https://github.com/Redocly/redoc/blob/main/docs/deployment/html.md#the-redoc-object

## Use `MapReDoc` with endpoint routing

`MapReDoc` is an endpoint-routing alternative to `UseReDoc`. The options API is the same, so all customization examples on this page also apply when using `MapReDoc`.
Expand Down Expand Up @@ -167,3 +165,5 @@ app.MapReDoc("redoc-auth")
<sup><a href='/test/WebSites/WebApi.Map/Program.cs#L37-L40' title='Snippet source file'>snippet source</a> | <a href='#snippet-Redoc-MapReDoc-RequireAuthorization' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
<!-- markdownlint-enable MD031 MD033 -->

[redoc-options]: https://github.com/Redocly/redoc/blob/main/docs/deployment/html.md#the-redoc-object
4 changes: 2 additions & 2 deletions docs/configure-and-customize-swaggerui.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ app.UseSwaggerUI(options =>
<!-- endSnippet -->
<!-- markdownlint-enable MD031 MD033 -->

[swagger-ui]: https://github.com/swagger-api/swagger-ui

## Use `MapSwaggerUI` with endpoint routing

`MapSwaggerUI` is an endpoint-routing alternative to `UseSwaggerUI`. The options API is the same, so all customization examples on this page also apply when using `MapSwaggerUI`.
Expand Down Expand Up @@ -277,3 +275,5 @@ app.MapSwaggerUI("swagger-auth")
<sup><a href='/test/WebSites/WebApi.Map/Program.cs#L26-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-SwaggerUI-MapSwaggerUI-RequireAuthorization' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
<!-- markdownlint-enable MD031 MD033 -->

[swagger-ui]: https://github.com/swagger-api/swagger-ui
16 changes: 8 additions & 8 deletions src/Swashbuckle.AspNetCore.ReDoc/ReDocBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ public static class ReDocBuilderExtensions
/// Register the Redoc middleware with provided options
/// </summary>
public static IApplicationBuilder UseReDoc(this IApplicationBuilder app, ReDocOptions options)
{
return app.UseMiddleware<ReDocMiddleware>(options);
}
=> app.UseMiddleware<ReDocMiddleware>(options);

/// <summary>
/// Register the Redoc middleware with optional setup action for DI-injected options
Expand All @@ -23,6 +21,7 @@ public static IApplicationBuilder UseReDoc(
Action<ReDocOptions> setupAction = null)
{
var options = ResolveOptions(app.ApplicationServices, setupAction);

EnsureDefaultSpecUrl(options);

return app.UseReDoc(options);
Expand All @@ -41,11 +40,12 @@ public static IEndpointConventionBuilder MapReDoc(
Action<ReDocOptions> setupAction = null)
{
var options = ResolveOptions(endpoints.ServiceProvider, setupAction);

if (routePrefix != null)
{
options.RoutePrefix = routePrefix;
}

if (routePrefix != null)
{
options.RoutePrefix = routePrefix;
}

EnsureDefaultSpecUrl(options);

var pipeline = endpoints.CreateApplicationBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public static IEndpointConventionBuilder MapSwaggerUI(
{
var options = ResolveOptions(endpoints.ServiceProvider, setupAction);

if (routePrefix != null)
{
options.RoutePrefix = routePrefix;
}
if (routePrefix != null)
{
options.RoutePrefix = routePrefix;
}

var hostingEnv = endpoints.ServiceProvider.GetRequiredService<IWebHostEnvironment>();

EnsureDefaultUrl(options, hostingEnv.ApplicationName);

var pipeline = endpoints.CreateApplicationBuilder()
Expand All @@ -66,7 +67,9 @@ private static SwaggerUIOptions ResolveOptions(IServiceProvider serviceProvider,
{
using var scope = serviceProvider.CreateScope();
var options = scope.ServiceProvider.GetRequiredService<IOptionsSnapshot<SwaggerUIOptions>>().Value;

setupAction?.Invoke(options);

return options;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ await Verify(swagger)
[InlineData(typeof(TopLevelSwaggerDoc.Program), "/swagger/v1.json")]
[InlineData(typeof(WebApi.Program), "/swagger/v1/swagger.json")]
[InlineData(typeof(WebApi.Aot.Program), "/swagger/v1/swagger.json")]
[InlineData(typeof(WebApi.Map.Program), "/swagger/v1/swagger.json")]
public async Task Swagger_IsValidJson_No_Startup(
Type entryPointType,
string swaggerRequestUri)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"openapi": "3.0.4",
"info": {
"title": "WebApi",
"version": "v1"
},
"paths": {
"/weatherforecast": {
"get": {
"tags": [
"WebApi.Map"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Forecast"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Forecast": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date-time"
},
"temperatureC": {
"type": "integer",
"format": "int32"
},
"summary": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
},
"tags": [
{
"name": "WebApi.Map"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"openapi": "3.0.4",
"info": {
"title": "WebApi",
"version": "v1"
},
"paths": {
"/weatherforecast": {
"get": {
"tags": [
"WebApi.Map"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Forecast"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Forecast": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date-time"
},
"temperatureC": {
"type": "integer",
"format": "int32"
},
"summary": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
},
"tags": [
{
"name": "WebApi.Map"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"openapi": "3.0.4",
"info": {
"title": "WebApi",
"version": "v1"
},
"paths": {
"/weatherforecast": {
"get": {
"tags": [
"WebApi.Map"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Forecast"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Forecast": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date-time"
},
"temperatureC": {
"type": "integer",
"format": "int32"
},
"summary": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
},
"tags": [
{
"name": "WebApi.Map"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// <auto-generated/>
#pragma warning disable CS0618
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions;
using Microsoft.Kiota.Serialization.Form;
using Microsoft.Kiota.Serialization.Json;
using Microsoft.Kiota.Serialization.Multipart;
using Microsoft.Kiota.Serialization.Text;
using Swashbuckle.AspNetCore.IntegrationTests.KiotaTests.Weatherforecast;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using System;
namespace Swashbuckle.AspNetCore.IntegrationTests.KiotaTests
{
/// <summary>
/// The main entry point of the SDK, exposes the configuration and the fluent API.
/// </summary>
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
public partial class KiotaOpenApiClient : BaseRequestBuilder
{
/// <summary>The weatherforecast property</summary>
public global::Swashbuckle.AspNetCore.IntegrationTests.KiotaTests.Weatherforecast.WeatherforecastRequestBuilder Weatherforecast
{
get => new global::Swashbuckle.AspNetCore.IntegrationTests.KiotaTests.Weatherforecast.WeatherforecastRequestBuilder(PathParameters, RequestAdapter);
}
/// <summary>
/// Instantiates a new <see cref="global::Swashbuckle.AspNetCore.IntegrationTests.KiotaTests.KiotaOpenApiClient"/> and sets the default values.
/// </summary>
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
public KiotaOpenApiClient(IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}", new Dictionary<string, object>())
{
ApiClientBuilder.RegisterDefaultSerializer<JsonSerializationWriterFactory>();
ApiClientBuilder.RegisterDefaultSerializer<TextSerializationWriterFactory>();
ApiClientBuilder.RegisterDefaultSerializer<FormSerializationWriterFactory>();
ApiClientBuilder.RegisterDefaultSerializer<MultipartSerializationWriterFactory>();
ApiClientBuilder.RegisterDefaultDeserializer<JsonParseNodeFactory>();
ApiClientBuilder.RegisterDefaultDeserializer<TextParseNodeFactory>();
ApiClientBuilder.RegisterDefaultDeserializer<FormParseNodeFactory>();
}
}
}
#pragma warning restore CS0618
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// <auto-generated/>
#pragma warning disable CS0618
using Microsoft.Kiota.Abstractions.Extensions;
using Microsoft.Kiota.Abstractions.Serialization;
using System.Collections.Generic;
using System.IO;
using System;
namespace Swashbuckle.AspNetCore.IntegrationTests.KiotaTests.Models
{
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
#pragma warning disable CS1591
public partial class Forecast : IParsable
#pragma warning restore CS1591
{
/// <summary>The date property</summary>
public DateTimeOffset? Date { get; set; }
/// <summary>The summary property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? Summary { get; set; }
#nullable restore
#else
public string Summary { get; set; }
#endif
/// <summary>The temperatureC property</summary>
public int? TemperatureC { get; set; }
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <returns>A <see cref="global::Swashbuckle.AspNetCore.IntegrationTests.KiotaTests.Models.Forecast"/></returns>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static global::Swashbuckle.AspNetCore.IntegrationTests.KiotaTests.Models.Forecast CreateFromDiscriminatorValue(IParseNode parseNode)
{
if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode));
return new global::Swashbuckle.AspNetCore.IntegrationTests.KiotaTests.Models.Forecast();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
/// <returns>A IDictionary&lt;string, Action&lt;IParseNode&gt;&gt;</returns>
public virtual IDictionary<string, Action<IParseNode>> GetFieldDeserializers()
{
return new Dictionary<string, Action<IParseNode>>
{
{ "date", n => { Date = n.GetDateTimeOffsetValue(); } },
{ "summary", n => { Summary = n.GetStringValue(); } },
{ "temperatureC", n => { TemperatureC = n.GetIntValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public virtual void Serialize(ISerializationWriter writer)
{
if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer));
writer.WriteDateTimeOffsetValue("date", Date);
writer.WriteStringValue("summary", Summary);
writer.WriteIntValue("temperatureC", TemperatureC);
}
}
}
#pragma warning restore CS0618
Loading
Loading