Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nice Work! Would global routes help eliminate path magic string? #2

Closed
joshbooker opened this issue Nov 24, 2015 · 12 comments · Fixed by #3
Closed

Nice Work! Would global routes help eliminate path magic string? #2

joshbooker opened this issue Nov 24, 2015 · 12 comments · Fixed by #3

Comments

@joshbooker
Copy link

First this is great work. I hope WebAPI OData team will work their implementation into swashbuckle like this - out of the box.

OData/WebApi#302
OData/WebApi#520
OData/WebApi#552

I wonder if you can get global ODataRoutes to eliminate the '/odata' magic string:
something like:

var odataRoutes = GlobalConfiguration.Configuration.Routes.Where(a=>a.GetType() == typeof(ODataRoute)).ToList();
if (!odataRoutes.Any()) return;
var route = odataRoutes.FirstOrDefault() as ODataRoute;
var path = "/" + route.RoutePrefix;
c.CustomProvider(defaultProvider => new ODataSwaggerProvider(path, edmModel));

Or better yet, maybe do it in ODataSwaggerProvider so you don't need to pass edm through SwaggerConfig.

PS - side question: have you tested to see whether swashbuckle filters work to post-modify swagger output? CUrious if IOperationFilter works for custom ISwaggerProvider.

Keep up the great work!

@ghost ghost assigned rbeauchamp Nov 24, 2015
@ghost ghost added the enhancement label Nov 24, 2015
@ghost
Copy link

ghost commented Nov 24, 2015

@joshbooker Thanks Josh! I'll try your idea to see if we can get rid of the hardcoded/magic string.

PS, No, I haven't tested yet whether filters are applied after setting the custom ISwaggerProvider.

@ghost ghost assigned ghost and unassigned rbeauchamp Nov 24, 2015
@ghost ghost mentioned this issue Nov 25, 2015
@ghost ghost closed this as completed in #3 Nov 25, 2015
@ghost
Copy link

ghost commented Nov 25, 2015

@joshbooker Now determining the route prefix in the ODataSwaggerProvider. This significantly simplified the configuration steps. Thanks for your suggestion!

@ghost
Copy link

ghost commented Nov 25, 2015

Fix is available in this pre-release NuGet package

@joshbooker
Copy link
Author

That's perfect! One line in swagger.config and done. Great work. You really need to submit this as pull request to webapi odata. As you know they've been very responsive to issue 302 in recent days. If submitted now, your provider code might just make v5.8

@joshbooker
Copy link
Author

Must try this with RESTier tomorrow. Thanks again for sharing.

@joshbooker
Copy link
Author

Richard, I got an email from OData PM Mark Stafford, says they'll look at this next week and update github after holiday.

PS You may want to change readme to install nuget prerelease:
Install-Package Swashbuckle.OData -pre

@ghost
Copy link

ghost commented Nov 25, 2015

@joshbooker Hey Josh, Ok, thanks for the OData PM update. Sure, I'll change the readme. Thanks!

@joshbooker
Copy link
Author

Thanks again. PS works great with https://github.com/OData/RESTier too. Happy happy

@ghost
Copy link

ghost commented Nov 25, 2015

Cool!

@joshbooker
Copy link
Author

@rbeauchamp FYI discussion about adding this to System.Web.OData is ongoing here:
OData/WebApi#520

@ghost
Copy link

ghost commented Dec 2, 2015

@joshbooker OK. Thanks for the update.

FYI, Item 3) from your comment is not implemented at this time. See my comment in #5.

@joshbooker
Copy link
Author

@rbeauchamp-lendingtree I was going to test IOperationFilter in SwaggerConfig.cs and find if it affects swagger output. The swashbuckle docs don't clarify this. Are you saying you did so and it does not post- modify? nevermind, I see SwaggerGeneratorOptions is not implemented so filters don't get applied.
https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Core/Swagger/SwaggerGenerator.cs
Thanks.

will-chan-sage added a commit to SageNADev/Swashbuckle.OData that referenced this issue Dec 5, 2016
…OdataUpdates

Microsoft.AspNet.*.Versioning unit tests added.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants