Fix your Swagger Definition!



So you created your shiny .NET REST API, and added the NuGet package Swashbuckle.Core which generated the SwaggerConfig.cs file in the App_Start of your API project.

All good, now you can browse your API definition and even test your API operations!

So you think you have a OpenAPI Specification file now... well, hold your horses!

Turns out that the .NET implementation with the SwaggerConfig.cs is not so strict on enforcing the Specification, and will produce a JSON that contains errors when checked for compliancy.

To make sure that your Swagger definition is indeed OpenAPI Specification compliant, you can download your generated Swagger JSON and upload it to either SwaggerHub or Swagger Editor.

If any error shows up there after parsing your JSON into YAML, you first have some work to do to fix those.

You might see errors such as "Semantic error at paths ... Equivalent paths are not allowed.", "Schema error at paths ... should NOT have additional properties", "Schema error at paths ... should be equal to one of the allowed values: ...", and so on.

You can easily troubleshoot those, and find all answers you need in order to fix them (Stackoverflow as usual will help you a lot).




Comments

Popular posts from this blog

Cloud Computing using Microsoft Azure for Dummies

RabbitMQ on Kubernetes Container Cluster in Azure

AD vs AAD (Active Directory vs Azure Active Directory)