Comments (10)
Hey would you mind throwing together a gist so I can reproduce the issue? Or point me to your code or unit test? Not sure I fully understand your scenario.
from swashbuckle.odata.
Sure thing, I'll try to modify the provided example and send you It.
Derek
Sent from my iPhone
On Dec 16, 2015, at 8:12 PM, Richard Beauchamp [email protected] wrote:
Hey would you mind throwing together a gist so I can reproduce the issue? Or point me to your code or unit test? Not sure I fully understand your scenario.
—
Reply to this email directly or view it on GitHub.
from swashbuckle.odata.
DL the project: https://onedrive.live.com/redir?resid=30915BBAD31877D9!423&authkey=!AOY-QGFbUmbyJu4&ithint=file%2czip
With a restful client, trigger the following request:
POSTURL: http://localhost:4073/odata/Customers(1)/OrdersPayload: { "OrderName": "323"}
This request is to create a Order under Customer 1.
Put a break point in OrdersController.cs :
public Task Post([FromODataUri] int CustomerID, Order patch) { throw new NotImplementedException(); }
Notice that in this call, the custom routing will trigger OrdersController instead of the CustomersController. It will trigger a Post Action. So the flow works as expected.
However, when you look at http://localhost:4073/swagger/ui/index#/ and look at the Customer or Order controller the path does not exist.
So I would expect to see Under OrderController or CustomerController:
/odata/Customer({key})/Orders
Questions:Are there attribute that I can add to the function that swagger would recognize and display the path in the swagger UII imagine that the swashbuckle.odata code would look at all the signature function and recognize that there is a Post function that takes in a customerID in the URL and is a post action. But it also accounts for the custom routing. Is that possible?
Let me know if that make sense?Thanks,
Derek
From: [email protected]
Subject: Re: [Swashbuckle.OData] Custom Routing with OData (#21)
Date: Thu, 17 Dec 2015 03:43:40 -0800
To: [email protected]
CC: [email protected]
Sure thing, I'll try to modify the provided example and send you It.
Derek
Sent from my iPhone
On Dec 16, 2015, at 8:12 PM, Richard Beauchamp [email protected] wrote:
Hey would you mind throwing together a gist so I can reproduce the issue? Or point me to your code or unit test? Not sure I fully understand your scenario.
—
Reply to this email directly or view it on GitHub.
from swashbuckle.odata.
Hey Derek, thank you for posting the example code. I've downloaded it and am able to reproduce the issue. I'll investigate and get back to you.
from swashbuckle.odata.
Hey @darewreck54, support for custom routes is now available in release v2.6.0. Here's the new documentation. Give it a try and let me know how it works for you.
from swashbuckle.odata.
Thank. I took a look and tried out the fix. It looks like it works. Great work!
I haven't had a chance to really take a look at the inner workings of the swashbuckle.OData code base, so please bear with me. Here are some suggestions (not sure how difficult or complex it would be):
The extra steps that you require the user to define the custom route seems a bit much. The reason being is that the user would have to do this for every single route at this point because of the injected custom route class. From my understanding the key appeal of swagger/swashbuckle is that it automatically scans the code with little additional work on the user side to display the endpoints. If that is true, here are some suggestions:If you choose this method, is it possible to trigger off special OData attribute similar to Route(" ") on top of every function in the controller for custom routes. This will make the code more readable/maintainable. If the function has say a special attribute "[ODataCustomRoute("")] then trigger off that. By doing this, you wouldn't have to specify the Controller or even the parameters in the config file since you have all that info from being in the Controller class and the attribute would be connected to the function signature where you can attract the params. If that is too complicated, you can just have the user associate the attributes at the controller level. Another possible way to resolve the issue, is it possible to take advantage of the return functions of the custom route class. The custom route class overrides two functions. SelectAction & SelectController. When the application starts up & swagger OData starts scanning the code for endpoints, is it possible to use the custom route class to retrieve the Controller (This eliminates the need to specify the controller) and also the action (eliminates the need to specify the action) and then be able to determine the paramaters via function definition in the code.
Please let me know if the suggestions make sense,Thanks,
Derek
Date: Sat, 19 Dec 2015 09:03:52 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [Swashbuckle.OData] Custom Routing with OData (#21)
Hey @darewreck54, support for custom routes is now available in release v2.6.0. Here's the new documentation. Give it a try and let me know how it works for you.
—
Reply to this email directly or view it on GitHub.
from swashbuckle.odata.
Glad it works! I'll investigate your suggestions. Probably after I get through the other recent issues. Thanks for your feedback; I see how defining a custom route for every action could be cumbersome.
from swashbuckle.odata.
Can you open this up for possible enhancement in terms of using the definition instead of having to directly do AddCustomeRoute() Or should I create another issue just for enhancement?
from swashbuckle.odata.
A new issue would be good. One that describes exactly how you think it should work.
from swashbuckle.odata.
And when I say 'how you think it should work' I mean from a user perspective. Thanks.
from swashbuckle.odata.
Related Issues (20)
- EnableQueryFilter.ReturnsCollection() throws NullReferenceException for return type void
- 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
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.