Giter VIP home page Giter VIP logo

Comments (10)

rbeauchamp avatar rbeauchamp commented on July 26, 2024

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.

darewreck54 avatar darewreck54 commented on July 26, 2024

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.

darewreck54 avatar darewreck54 commented on July 26, 2024

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.

rbeauchamp avatar rbeauchamp commented on July 26, 2024

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.

rbeauchamp avatar rbeauchamp commented on July 26, 2024

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.

darewreck54 avatar darewreck54 commented on July 26, 2024

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.

rbeauchamp avatar rbeauchamp commented on July 26, 2024

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.

darewreck54 avatar darewreck54 commented on July 26, 2024

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.

rbeauchamp avatar rbeauchamp commented on July 26, 2024

A new issue would be good. One that describes exactly how you think it should work.

from swashbuckle.odata.

rbeauchamp avatar rbeauchamp commented on July 26, 2024

And when I say 'how you think it should work' I mean from a user perspective. Thanks.

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.