Giter VIP home page Giter VIP logo

Comments (14)

rbeauchamp avatar rbeauchamp commented on August 30, 2024

Hey @stimpy77, I'll re-open after you provide more detail. Thanks!

from swashbuckle.odata.

stimpy77 avatar stimpy77 commented on August 30, 2024

It's caused by our having a custom route. Still want to provide a gist but perhaps it's easily repro'd by just declaring a custom route. I don't know, I didn't write this code.

from swashbuckle.odata.

 avatar commented on August 30, 2024

Looks like it has something to do with a route that takes an array of URL parameters. Do you see such a route?

from swashbuckle.odata.

stimpy77 avatar stimpy77 commented on August 30, 2024

Yeah I found out from my lead that he found that array types aren't even handled, it was a one-liner in a file I don't know what he was fussing with but it was a list of type handlers in either one of the libs (swashbuckle or *.odata), don't know which. Sorry, I still don't have gist for you, I've just been busy.

from swashbuckle.odata.

stimpy77 avatar stimpy77 commented on August 30, 2024

It was in ODataApiExplorer.cs, under case null:, switch (type), add case "array": return "[]";

from swashbuckle.odata.

stimpy77 avatar stimpy77 commented on August 30, 2024

Sorry, the context of that last comment is in Swashbuckle.OData.Descriptions.ParameterExtensions in GenerateSamplePathParameterValue(), not ODataApiExplorer

from swashbuckle.odata.

 avatar commented on August 30, 2024

Thanks @stimpy77 !

from swashbuckle.odata.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

@stimpy77 Fix is available in v2.7.2. Please try it out and let me know if you find any issues. Thanks!

from swashbuckle.odata.

stimpy77 avatar stimpy77 commented on August 30, 2024

Thanks. New error related to parameters, not related to array. In my copy of the codebase I had to add null propagating operator and null support in multiple places to get this to complete. I don't know what object graph causes this.

NullReferenceException

   at Swashbuckle.OData.Descriptions.ParameterExtensions.GetEntityTypeForBodyParameter(Parameter parameter)
   at Swashbuckle.OData.Descriptions.ParameterExtensions.GetClrType(Parameter parameter)
   at Swashbuckle.OData.Descriptions.MapToDefault.Map(Parameter swaggerParameter, Int32 parameterIndex, HttpActionDescriptor actionDescriptor)
   at Swashbuckle.OData.Descriptions.SwaggerOperationMapper.<>c__DisplayClass6_0.<GetHttpParameterDescriptor>b__0(IParameterMapper mapper)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Swashbuckle.OData.Descriptions.SwaggerOperationMapper.GetHttpParameterDescriptor(Parameter parameter, Int32 index, HttpActionDescriptor actionDescriptor)
   at Swashbuckle.OData.Descriptions.SwaggerOperationMapper.GetParameterDescription(Parameter parameter, Int32 index, HttpActionDescriptor actionDescriptor)
   at Swashbuckle.OData.Descriptions.SwaggerOperationMapper.<>c__DisplayClass4_0.<CreateParameterDescriptions>b__0(Parameter parameter, Int32 index)
   at System.Linq.Enumerable.<SelectIterator>d__5`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Swashbuckle.OData.Descriptions.SwaggerOperationMapper.CreateParameterDescriptions(Operation operation, HttpActionDescriptor actionDescriptor)
   at Swashbuckle.OData.Descriptions.SwaggerOperationMapper.Map(ODataActionDescriptor oDataActionDescriptor)
   at Swashbuckle.OData.Descriptions.ODataApiExplorer.<>c__DisplayClass7_0.<GetApiDescriptions>b__2(IODataActionDescriptorMapper mapper)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Swashbuckle.OData.Descriptions.ODataApiExplorer.<GetApiDescriptions>b__7_1(ODataActionDescriptor oDataActionDescriptor)
   at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
   at System.Linq.Enumerable.<DistinctIterator>d__63`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Swashbuckle.OData.CollectionExtentions.ToCollection[T](IEnumerable`1 source)
   at Swashbuckle.OData.Descriptions.ODataApiExplorer.GetApiDescriptions()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at Swashbuckle.OData.Descriptions.ODataApiExplorer.get_ApiDescriptions()
   at Swashbuckle.OData.ODataSwaggerProvider.GetApiDescriptionsFor(String apiVersion)
   at Swashbuckle.OData.ODataSwaggerProvider.GetSwagger(String rootUrl, String apiVersion)
   at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Web.Http.Cors.CorsMessageHandler.<>n__FabricatedMethod3(HttpRequestMessage , CancellationToken )
   at System.Web.Http.Cors.CorsMessageHandler.<SendAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Owin.PassiveAuthenticationMessageHandler.<SendAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()

from swashbuckle.odata.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

Hey Jon, So I understand: you added null propagation to Swashbuckle.OData to fix this issue?

from swashbuckle.odata.

stimpy77 avatar stimpy77 commented on August 30, 2024

The particular method where the exception is occurring has a single line of code that is the culprit, and one of the properties it is querying a property of is null. I added null propagation, which moved the exception downstream. I followed this downstream further at least a couple times until the exceptions went away. But I still don't know what this particular function was reading.

from swashbuckle.odata.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

any chance can you forward the changes you made? :) Could help even if we don't know the particular cause. Thanks.

from swashbuckle.odata.

stimpy77 avatar stimpy77 commented on August 30, 2024

sorry, it wasn't a fork, I just copied all the .cs files from the swashbuckle.odata and swashbuckle projects directly into our project (rather than pull the project in) so that we didn't have nuget dependencies, so I can't diff at this point, and even if I could I had to strip out all the C#6 syntax as we're using a C#5 compiler in TFS. Since I put everything in the same project I quickly lost track of my changes, I just wanted to get a complete and valid .json emitted as quickly as possible.

I'm sorry I'm not as immediately helpful as I should be. I might follow up though.

FWIW, here's the Swagger and Swagger.OData combined I have (attached).
Swashbuckle.zip

from swashbuckle.odata.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

Gotcha. OK, thanks for the heads up and the attachment.

from swashbuckle.odata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.