-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Asp.Versioning.Http
package support
#352
Comments
as for our existing implementation of versioning, will look in to the possibility of adding header support as soon as i get a chance. if someone reading this wants to have a crack at adding header support to our versioning, please go ahead and submit a PR. thanks! |
Asp.Versioning.Http
package support
The main point though is, that the versioning needs to support the HeaderApiVersionReader. |
Is there anything new on this front? Versioning by header would be my goto solution as well. How should it work in regards to the EDIT: How would you envision the contribution to look like? In what "form" should |
ideally we should look at providing header support for our existing versioning system instead of relying on a third-party package which is not even maintained by microsoft anymore. so if you wanna have crack at implenting that, do go ahead... |
This comment was marked as outdated.
This comment was marked as outdated.
Thanks! This looks awesome, still have to look at the actual implementation that you chose, I had planned to give it a go on the weekend but now more time for other projects. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Good to see some work being done on this area ! Well done ! |
@candoumbe no tests yet. i'm trying to wrap up this functionality into a |
Yeah of course, I was talking about tests for the "current" implementation of Versioning (and not the one in |
@candoumbe integration tests like these are dispersed throught 🤐 FastEndpoints/Tests/IntegrationTests/FastEndpoints.IntegrationTests/WebTests/AdminTests.cs Lines 65 to 108 in fbe3c7a
as well as swagger snapshot tests such as these: FastEndpoints/Tests/IntegrationTests/FastEndpoints.Swagger.IntegrationTests/SwaggerDocTests.cs Lines 20 to 66 in fbe3c7a
if someone has the time, a more comprehensive test suite would be welcome 😉 |
okay... i have some progress... using Asp.Versioning;
using Asp.Versioning.Conventions;
using FastEndpoints;
using FastEndpoints.AspVersioning;
using FastEndpoints.Swagger;
VersionSets.CreateApi(">>Orders<<", v => v
.HasApiVersion(1.0)
.HasApiVersion(2.0));
VersionSets.CreateApi(">>Inventory<<", v =>
{
v.HasApiVersion(1.0);
v.HasApiVersion(1.1);
});
var builder = WebApplication.CreateBuilder();
builder.Services
.AddFastEndpoints()
.AddVersioning(o =>
{
o.DefaultApiVersion = new(1.0);
o.AssumeDefaultVersionWhenUnspecified = true;
o.ApiVersionReader = new HeaderApiVersionReader("X-Api-Version");
})
.SwaggerDocument(o =>
{
o.DocumentSettings = x =>
{
x.DocumentName = "version one";
x.ApiVersion(new(1.0));
};
o.AutoTagPathSegmentIndex = 0;
})
.SwaggerDocument(o =>
{
o.DocumentSettings = x =>
{
x.DocumentName = "version one point one";
x.ApiVersion(new(1.1));
};
o.AutoTagPathSegmentIndex = 0;
})
.SwaggerDocument(o =>
{
o.DocumentSettings = x =>
{
x.DocumentName = "version two";
x.ApiVersion(new(2.0));
};
o.AutoTagPathSegmentIndex = 0;
});
var app = builder.Build();
app.UseAuthorization()
.UseFastEndpoints()
.UseSwaggerGen();
app.Run();
public class GetInvoices_v1 : EndpointWithoutRequest
{
public override void Configure()
{
Get("invoices");
AllowAnonymous();
Options(x => x
.WithVersionSet(">>Orders<<")
.MapToApiVersion(1.0));
}
public override async Task HandleAsync(CancellationToken c)
{
await SendAsync("v1 - orders");
}
}
public class GetInvoices_v2 : EndpointWithoutRequest
{
public override void Configure()
{
Get("invoices");
AllowAnonymous();
Options(x => x
.WithVersionSet(">>Orders<<")
.MapToApiVersion(2.0));
}
public override async Task HandleAsync(CancellationToken c)
{
await SendAsync("v2 - orders");
}
}
public class GetStockItems_v1 : EndpointWithoutRequest
{
public override void Configure()
{
Get("stock-items");
AllowAnonymous();
Options(x => x
.WithVersionSet(">>Inventory<<")
.MapToApiVersion(1.0));
}
public override async Task HandleAsync(CancellationToken c)
{
await SendAsync("v1 - inventory");
}
}
public class GetStockItems_v1_1 : EndpointWithoutRequest
{
public override void Configure()
{
Get("stock-items");
AllowAnonymous();
Options(x => x
.WithVersionSet(">>Inventory<<")
.MapToApiVersion(1.1));
}
public override async Task HandleAsync(CancellationToken c)
{
await SendAsync("v1.1 - inventory");
}
} |
HI
Thanks for the awesome package. Its awesome.
we add versions to our Apis via api header:
The API versioning on https://fast-endpoints.com/docs/api-versioning#deprecate-an-endpoint uses a path for the versioning.
For fast endpoints we are also using the "Configure()" override. How can we utilize our version header for apis and using the Configure option. The "Version()" override does not appear to work :-/
Would be awesome if it fastendpoints could support https://github.com/dotnet/aspnet-api-versioning
Thanks again..
The text was updated successfully, but these errors were encountered: