Comments (14)
Hey @stimpy77, I'll re-open after you provide more detail. Thanks!
from swashbuckle.odata.
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.
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.
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.
It was in ODataApiExplorer.cs, under case null:, switch (type), add case "array": return "[]";
from swashbuckle.odata.
Sorry, the context of that last comment is in Swashbuckle.OData.Descriptions.ParameterExtensions in GenerateSamplePathParameterValue(), not ODataApiExplorer
from swashbuckle.odata.
Thanks @stimpy77 !
from swashbuckle.odata.
@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.
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.
Hey Jon, So I understand: you added null propagation to Swashbuckle.OData to fix this issue?
from swashbuckle.odata.
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.
any chance can you forward the changes you made? :) Could help even if we don't know the particular cause. Thanks.
from swashbuckle.odata.
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.
Gotcha. OK, thanks for the heads up and the attachment.
from swashbuckle.odata.
Related Issues (20)
- SchemaRegistryExtensions.GetPropertyNameForEdmModel returns wrong Edm Property name HOT 2
- Calling for Maintainers HOT 6
- Swagger generation resulting in error. Error thrown from SwaggerRouteStrategy.cs line 62
- AdjustRelativePathForStringParams is not working case-insensitive (param names)
- Method not found: 'Flurl.Url Flurl.Url.AppendPathSegment(System.Object)' HOT 1
- Precondition Failure
- Swagger docs don't have type information for Get method when it returns IHttpActionResult HOT 2
- Add custom property resolver to 4.0.0
- Unbound actions generate invalid swagger HOT 2
- Entity bound actions can have ODataActionParameters type parameters only
- Custom type parameters for OData functions HOT 1
- Exploring different version at the same time throw an error.
- Support for Microsoft.AspNet.OData 7? HOT 10
- Swashbuckle.OData.Core throws Specified argument was out of the range of valid values exception and failing to generate swagger ui HOT 1
- Need Help OData V4 REST Web API Documentation HOT 4
- Swashbuckle.OData.Core is too slow, consume 60% memory while open swagger in chrome browser HOT 4
- OData Web API Controller Summary not showing in swagger
- Swashbuckle.OData compatibility with OData V3 Controllers HOT 1
- Swagger generation fails for Entities having DataContractAttribute fails with "Sequence contains no matching element" when used in OData Actions. HOT 1
- Accurate OData response schema
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swashbuckle.odata.