Replies: 4 comments 10 replies
-
we might want to make this a discussion ..... PUT implies that a new entity will fully replace the current entity. just my thoughts at this point.... |
Beta Was this translation helpful? Give feedback.
-
So, RESTier exposes both PATCH and PUT functionality. Regardless of what functionality we build into RESTier, the OpenAPI should reflect that functionality. If we decide to remove the PUT functionality, we should remove it from OpenAPI. Still, until then, the documentation of what functionality RESTier exposes should be correct. The OpenAPI is generated from the EdmModel, highlighting the fact that we have a bug in the EdmModel RESTier building. It should add an annotation that PUT is supported (PUT is not typically required for OData APIs and is thus not added by default by the convention model builder). The nice thing is that when we fix it in the EdmModel, our OpenAPI document improves, and our |
Beta Was this translation helpful? Give feedback.
-
In this page of the Microsoft site In the Update an entity section, it is stated that OData supports two different semantics for updating an entity: PATCH and PUT. It is stated that the disadvantage of the PUT action is having to specify all the property values of an entity even if all the properties have not changed. Of course, the PATCH action is preferred. But it is well supported by OData as specified in section 11.4.3 of OData V4.0. "Services MAY additionally support PUT, but should be aware of the potential for data-loss in round-tripping properties that the client may not know about in advance, such as open or added properties, or properties not specified in metadata" In my opinion, the PUT method should therefore be present in the Swagger UI. In any case, thank you for your interest in this discussion. Long live Restier. |
Beta Was this translation helpful? Give feedback.
-
So here's my take on everything. Restier is a highly-opinionated framework. It has a very specific way that it does things, and as a core tenet it defaults to being "magical". The documentation @RichySano pointed to clearly demonstrates that PUTs are NOT magical. The default behavior has the potential for significant data loss, including in situations where there are audit fields being persisted to entities. Given the fact that the actual issue is in If you want a different behavior, you can always subclass the And feel free to open an issue in the Microsoft.OpenApi.OData repo if you feel the behavior of Since we pretty much have every feature of ASP.NET Core covered now, moving forward we're going to be pretty exclusively focused on redesigning Restier for v2, unless there are blocking issues or bugs. |
Beta Was this translation helpful? Give feedback.
-
Swagger is well generated but PUT method doesn't appears in swagger UI. But PUT method is working well with POSTMAN for example.
Assemblies affected
Restier RTM 1.1.0
Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRestier(configureApisAction =>
{
configureApisAction.AddRestierApi((routeServices) =>
{
routeServices.AddOptions();
routeServices.AddEFCoreProviderServices((services, options) =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
});
});
}, true);
builder.Services.AddRestierSwagger();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRestierBatching();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
_ = endpoints.Select().Expand().Filter().OrderBy().MaxTop(100).Count().SetTimeZoneInfo(TimeZoneInfo.Utc);
_ = endpoints.MapRestier(builder =>
{
builder.MapApiRoute("", "", true);
});
});
app.UseClaimsPrincipals();
app.UseHttpsRedirection();
app.UseRestierSwagger(true);
app.MapControllers();
app.Run();
Beta Was this translation helpful? Give feedback.
All reactions