- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.3k
          Add support for JsonPolymorphic and JsonDerivedType attributes to Swashbuckle.AspNetCore.Annotations for .NET7 and later
          #2671
        
          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
Conversation
JsonPolymorphic and JsonDerivedType attributes to Swashbuckle.AspNetCore.Annotations for .NET7 and later
      929b810    to
    8995799      
    Compare
  
    | To fix the appveyor build, tests should be upgraded to net7 first. I'll rebase after related PR has been merged: #2672 | 
| This change would be great! @schnerring | 
| Thanks for contributing - if you'd like to continue with this pull request, please rebase against the default branch to pick up our new CI. We'd also need tests for these new scenarios. | 
| This pull request is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further changes are made. | 
8995799    to
    66cb005      
    Compare
  
    | I rebased the PR against the current master branch. The "test" (more of a sample) of the obsolete functionality is in here: test/WebSites/NswagClientExample/Controllers/AnimalsController.cs I've adjusted this to also include the new attributes. Integration tests would be nice, but I'm not sure how to do that from scratch and would appreciate some input. We basically need to test if the OpenAPI spec is generated correctly. Is there a test harness inside the code base I could reuse? | 
        
          
                src/Swashbuckle.AspNetCore.Annotations/SwaggerDiscriminatorAttribute.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                test/WebSites/NswagClientExample/Controllers/AnimalsController.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
 If you look at the Swashbuckle.AspNetCore.IntegrationTests project, it validates things through the sites in the WebSites folder. There are also verification tests associated with generated schemas here. | 
| any progress? | 
| to anyone interested, it's possible to "manually" do what this PR does on your own code, until it gets merged: https://codeberg.org/KittyShopper/outpost/src/commit/3d8f0af997d3963ba552efe7ef9aec9b81d61a05/Outpost/Core/Util/OpenApi.cs#L135-L155 | 
| 
 As I'm currently not using Swashbuckle and I'm busy with other things, I don't really have the time to dig into the code base and figure out how to test this. Any help would be appreciated. | 
| The preferred approach is to add a controller/endpoint to one of the test websites and then add appropriate verification tests to the integration test project to verify that the expected OpenAPI document is produced. There's various examples of that approach here. | 
…attribute support to `Swashbuckle.AspNetCore.Annotations`
…or .NET 7 or greater
…eritance attributes
41527d6    to
    7196c12      
    Compare
  
    7196c12    to
    a6d72db      
    Compare
  
    | Sorry @martincostello, I didn't want you to have to repeat yourself. You already told me earlier where to find the integration tests. But as far as I can tell, the old polymorphism feature is also untested, so there is no way for me to copy any tests and work from there. I also added a (failing) test case for the  However, I implemented your other code review suggestions and rebased it to the current master. So maybe someone with more Swashbuckle expertise can pick up this PR in the future. | 
| 
 Yes, it works, could you fix and merge the PR please? | 
| Superseded by #3170. | 
Beginning with .NET 7, System.Text.Json supports polymorphic type hierarchy serialization and deserialization with attribute annotations.
This PR adds support for
JsonPolymorphicandJsonDerivedTypeattributes toSwashbuckle.AspNetCore.Annotationsfor .NET 7 and later.Fixes #2571