Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/replace asp versioning #17

Merged
merged 6 commits into from
Apr 11, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update templates to generate new api version attributes
GabrielBoceanu committed Apr 10, 2024
commit 15eaad050240faaea315e610034f2d4528dd73f8
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System.CodeDom.Compiler;
using {{ProjectNamespace}}.Generated.Common;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Versioning;
using Asp.Versioning;
using Microsoft.Extensions.DependencyInjection;
using NSwag.Generation.AspNetCore;
using System.CodeDom.Compiler;
using {{ProjectNamespace}}.Generated.Common;

namespace {{ProjectNamespace}}.Generated.StartupConfiguration
{
@@ -16,25 +15,20 @@ namespace {{ProjectNamespace}}.Generated.StartupConfiguration
string versionHeaderName = "version",
string infoTitle = "API",
IApiVersionReader versionReader = null,
IErrorResponseProvider errorResponseProvider = null,
ApiVersion defaultVersion = null,
bool assumeDefaultVersionWhenUnspecified = true,
bool reportApiVersions = true)
{
services.AddApiVersioning(options =>
{
options.AssumeDefaultVersionWhenUnspecified = assumeDefaultVersionWhenUnspecified;
options.DefaultApiVersion = defaultVersion ?? ApiVersion.Default;
options.ApiVersionReader = versionReader ?? new HeaderApiVersionReader(versionHeaderName);
options.ReportApiVersions = reportApiVersions;

if (errorResponseProvider != null)
services
.AddApiVersioning(options =>
{
options.ErrorResponses = errorResponseProvider;
}
});

services.AddVersionedApiExplorer();
options.AssumeDefaultVersionWhenUnspecified = assumeDefaultVersionWhenUnspecified;
options.DefaultApiVersion = defaultVersion ?? ApiVersion.Default;
options.ApiVersionReader = versionReader ?? new HeaderApiVersionReader(versionHeaderName);
options.ReportApiVersions = reportApiVersions;
})
.AddMvc()
.AddApiExplorer();

foreach (var apiVersion in ApiConstants.ApiVersions)
{
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Asp.Versioning;
using System;
using System.CodeDom.Compiler;
using Microsoft.AspNetCore.Mvc;

namespace {{ProjectNamespace}}.Generated.Http
{