Giter VIP home page Giter VIP logo

Comments (17)

rbeauchamp avatar rbeauchamp commented on August 30, 2024

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.

darewreck54 avatar darewreck54 commented on August 30, 2024

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.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

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.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

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.

darewreck54 avatar darewreck54 commented on August 30, 2024

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.

darewreck54 avatar darewreck54 commented on August 30, 2024

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.

 avatar commented on August 30, 2024

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.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

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.

darewreck54 avatar darewreck54 commented on August 30, 2024

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.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

You should be able to see it now. Sometimes it takes a while to index the NuGet package...

from swashbuckle.odata.

darewreck54 avatar darewreck54 commented on August 30, 2024

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.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

Thanks, yeah the enablequery issue was documented today in #37.

from swashbuckle.odata.

darewreck54 avatar darewreck54 commented on August 30, 2024

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.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

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.

darewreck54 avatar darewreck54 commented on August 30, 2024

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.

rbeauchamp avatar rbeauchamp commented on August 30, 2024

ok, thanks for the problem investigation. and thanks for the unit test above.

from swashbuckle.odata.

 avatar commented on August 30, 2024

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)

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.