Search code examples
unit-testingautomated-testsswaggerintegration-testing

What are some ways to automatically test Swagger endpoints?


Building a C# .NET Core API, I want to automatically test the endpoints in the documentation that is generated by Swagger as part of my build.

Are there some prebuilt packages or tools I can use to do this easily?


Solution

  • No more outdated API documentation.

    This is the promise Dredd makes. So should be able to help you with

    automatically test the endpoints in the documentation that is generated by Swagger as part of my build

    I've used it in one project, it reads the description and step by step validates whether your API implementation replies with responses as they are described. There is a catch, though. It doesn't scale to live up to a real testing framework that can help you cover complex (chained) user journeys through your backend. It will introduce huge overhead, if you go down this path. But, in case you need simple docs validation - it works just fine. It can easily be your first line of defence, stage of the CICD pipeline.