Comments (17)
Thanks Derek for the detailed analysis and explanation. I always ensure that the tests pass before releasing, so it's a matter of building enough scenario coverage. I'll include your project and investigate.
from swashbuckle.odata.
The project I included is just the modified sample of 2.0.0. It seems like you did a lot of changes up to 2.6.1. I just used my example to prove the issue since the newest sample wasn't really working.
Also just curious, does the swashbuckle.odata code make some assumption on the routing and convention? Does it leverage off the select controller and select action methods?
Thanks
Derek
Sent from my iPhone
On Dec 20, 2015, at 11:54 AM, Richard Beauchamp [email protected] wrote:
Thanks Derek for the detailed analysis and explanation. I always ensure that the tests pass before releasing, so it's a matter of building enough scenario coverage. I'll include your project and investigate.
—
Reply to this email directly or view it on GitHub.
from swashbuckle.odata.
does the swashbuckle.odata code make some assumption on the routing and convention?
It basically works like this: it generates a set of potential paths based upon the entity data model (and custom routes). It then verifies these against the actual controllers/actions by simulating a real HTTP request. The request locates the controller/action by going through the WebApi/OData infrastructure like a real request would. Once it locates a controller and action it generates an ApiDescription that is expected/leveraged by Swashbuckle. From that point on Swashbuckle infrastructure takes over.
from swashbuckle.odata.
And in terms of development/deployment, the latest sample website always runs against the latest code base in master. And whenever a commit occurs to master the code is automatically built and the tests are run. For example, see the latest CI build for the v2.6.1 tagged sample. The "Try it out!" sample website automatically gets deployed for each commit to master. So when you say "the newest sample wasn't really working.", I'm not sure what you are referring to.
from swashbuckle.odata.
Oo I meant that I do 2.6.1, ran the sample from my machine (at the time the code didn't compile) so I made fixes to make it compile. When I started the swagger ui, it would never render and keep trying to load. It was also late, so I can try it again.
Sent from my iPhone
On Dec 20, 2015, at 5:52 PM, Richard Beauchamp [email protected] wrote:
And in terms of development/deployment, the latest sample website always runs against the latest code base in master. And whenever a commit occurs to master the code is automatically built and the tests are run. For example, see the latest CI build for the v2.6.1 tagged sample. The "Try it out!" sample website automatically gets deployed for each commit to master. So when you say "the newest sample wasn't really working.", I'm not sure what you are referring to.
—
Reply to this email directly or view it on GitHub.
from swashbuckle.odata.
I did some investigating why i had issue with building and running the sample:
So when you load up the project, I get a complaint with:
"Swashbuckle.OData.Nuget\Swashbuckle.OData.NuGet.nuproj: The application which this project type is based on was not found. Please try this link for further information: http://go.microsoft.com/fwlink/?LinkID=299083&projecttype=FF286327-C783-4F7A-AB73-9BCBAD0D4460"
So the errors is a result of which visual studio you use. If you use 2013, there are some operations that aren't valid:
Doesn't recognize "nameOf"
- throw new ArgumentOutOfRangeException(nameof(parameter), parameter, null);
or $
- throw new Exception($"Could not determine .NET type for parameter type {type} and format 'null'");
In 2015, those operators are recognizable.
You also have to install https://visualstudiogallery.msdn.microsoft.com/1ec7db13-3363-46c9-851f-1ce455f66970 and enable static checking on the Sample project to get it to run successfully.
from swashbuckle.odata.
Yes, it's developed with VS 2015 and uses the new C# 6.0 features. And the NuGet packages need to be restored before loading the NuGet project (which is an anomaly of the NuGet project type. Probably need to add the NuGet targets to source control). I'll add some development notes to the README for future devs.
EDIT:
I've now added a Development section to the README and have added the tools required to load the Swashbuckle.OData.Nuget project.
from swashbuckle.odata.
Hey @darewreck54, maybe the issues have been fixed between v2.6.1 and v2.8.0, but I have written unit tests in v2.8.0 to reproduce your issues and they are all passing. Please give v2.8.0 a try and let me know of you still have any issues. If you do, please update the unit tests to reproduce your issue(s). Will re-open if your issues still exist. Thanks!
from swashbuckle.odata.
l only see 2.7.2 to dl. Not v2.8.0.
Date: Sat, 26 Dec 2015 15:04:11 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [Swashbuckle.OData] Controllers not being rendered depending on what functions defined (issue started the transition from 2.0.0 to 2.1.0) (#28)
Hey @darewreck54, maybe the issues have been fixed between v2.6.1 and v2.8.0, but I have written unit tests in v2.8.0 to reproduce your issues and they are all passing. Please give v2.8.0 a try and let me know of you still have any issues. If you do, please update the unit tests to reproduce your issue(s). Will re-open if your issues still exist. Thanks!
—
Reply to this email directly or view it on GitHub.
from swashbuckle.odata.
You should be able to see it now. Sometimes it takes a while to index the NuGet package...
from swashbuckle.odata.
I found a minor issue when testing.
If you were to add:
OrdersController.cs
[EnableQuery]
public async Task Get([FromODataUri] int customerId, ODataQueryOptions queryOptions)
{
throw new NotImplementedException();
}
Config:
config.AddCustomSwaggerRoute(customODataRoute, "/Customers({Id})/Orders")
.Operation(HttpMethod.Get)
.PathParameter<int>("Id");
The "EnableQuery" doesn't get picked up by the Swashbuckle.OData. As a result, when you use the swagger UI, you are not presented the option to add OData Query params such as expand.
I also notice that if you have two Get methods:
- GetCustomer(..)
- Get(..)
Naturally either WebAPI or OData will choose GetCustomer to execute first vs. the Get method. I'm not sure how priority works in this case.
Unit test for you:
[Test]
public async Task It_allows_definition_of_custom_get_routes_and_has_all_optional_odata_query_parameters()
{
using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(OrdersController))))
{
// Arrange
var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);
// Act
var swaggerDocument = await httpClient.GetJsonAsync<SwaggerDocument>("swagger/docs/v1");
// Assert
PathItem pathItem;
swaggerDocument.paths.TryGetValue("/odata/Customers({Id})/Orders)", out pathItem);
pathItem.get.parameters.Where(parameter => parameter.name.StartsWith("$")).Should().OnlyContain(parameter => parameter.required == false);
await ValidationUtils.ValidateSwaggerJson();
}
}
I think that's how it should look.
Thanks,
D
from swashbuckle.odata.
Thanks, yeah the enablequery issue was documented today in #37.
from swashbuckle.odata.
do you know how the priority works for the question on:
I also notice that if you have two Get methods:
GetCustomer(..)
Get(..)
Either WebAPI or OData will choose GetCustomer to execute first vs. the Get method. I'm not sure how priority works in this case.
Thanks,
Derek
from swashbuckle.odata.
Typically WebApi and OData have different base paths and the methods are in different controllers so they should both be captured and available on the swagger ui. I don't think any priority comes into play. does that answer your question?
from swashbuckle.odata.
Actually found a problem....
If you go to the customercontroller, and comment out all the Get Methods and only have:
[EnableQuery]
public Task<IHttpActionResult> Get(ODataQueryOptions<Customer> queryOptions)
{
throw new NotImplementedException();
}
The swagger UI will only load one controller which is the client. It won't load the customer controller at all and any other controllers after customer.
However, If you include a GET for a specific customer then it works:
[EnableQuery]
public Task Get(ODataQueryOptions queryOptions)
{
throw new NotImplementedException();
}
[EnableQuery]
public Task Get(int key)
{
throw new NotImplementedException();
}
from swashbuckle.odata.
ok, thanks for the problem investigation. and thanks for the unit test above.
from swashbuckle.odata.
The scenario above:
comment out all the Get Methods and only have:
is now fixed in v2.8.5. Thanks for finding the issue!
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.