rbeauchamp / Swashbuckle.OData

Extends Swashbuckle with OData v4 support!
Other
129 stars 96 forks source link

Unbound Functions Path Issue #156

Closed Diraekt closed 4 years ago

Diraekt commented 7 years ago

Our Definition:

[ODataRoutePrefix("people")]
    public class PersonsController : ODataController
{
  [EnableQuery]
  [ODataRoute("Competences")]
  public IQueryable<string> GetCompetences()
  {
    return m_entityService.GetDistinctTokens(x => x.Kompetenz);
   }
}

This will generate:

GET /odata/v{apiVersion}/peopleCompetences which is wrong, it should be GET /odata/v{apiVersion}/people/Competences

I fixed this in OdataRouteBuilder.cs => GetEntityKeySegment()

if (!IsNullOrEmpty(template))
            {
                if (!template.StartsWith("(") && !template.StartsWith("/"))
                {
                    template = $"/{template}";
                }
                return template;
            }

May you can fix this also ? :-)

Best Greetings

Cyril