Browse Source
Merge pull request #21307 from abpframework/OptionalAttribute
Remove `secondaryIds` from path if its `Optional`.
pull/21346/head
Engincan VESKE
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
2 additions and
1 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalRouteBuilder.cs
|
|
|
@ -2,6 +2,7 @@ |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using Microsoft.AspNetCore.Mvc.ApplicationModels; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
@ -63,7 +64,7 @@ public class ConventionalRouteBuilder : IConventionalRouteBuilder, ITransientDep |
|
|
|
//Add secondary Id
|
|
|
|
var secondaryIds = action.Parameters |
|
|
|
.Where(p => p.ParameterName.EndsWith("Id", StringComparison.Ordinal)).ToList(); |
|
|
|
if (secondaryIds.Count == 1) |
|
|
|
if (secondaryIds.Count == 1 && !secondaryIds[0].Attributes.Any(x => x is OptionalAttribute)) |
|
|
|
{ |
|
|
|
url += $"/{{{NormalizeSecondaryIdNameCase(secondaryIds[0], configuration)}}}"; |
|
|
|
} |
|
|
|
|