This section builds upon the quick start. If you haven’t completed the quick start yet, you can find it here or to the right.
|Read: 5 minutes||Code: 10 minutes|
Add an OpenAPI Definition
Add a new file named kuno.json to configure the API and point the schema reference to http://cdn.kuno.io/schemas/application.json. Add a title, description and version. The resulting file should look something like the following:
Run the application and navigate to http://localhost:5000/swagger. You should see the additional information in the definition.
You can continue to update the Open API definition to add contact, terms of service, etc.
Add Comments and Metadata
You must first go the Project Properties and then find the Build tab. Make sure that the “XML documentation file” checkbox is checked. You can leave the default location.
Add summary comments to the HelloWorld class and value comments to the Name property of the HelloWorldRequest class. Also update the endpoint attribute to specify the method and add tags.
Run the application and navigate to http://localhost:5000/swagger. You should see the comments that you have added on the endpoint and model.
Add Code Analysis
Install the Kuno.CodeAnalysis NuGet package. This will install the analyzer. In the Package Managaer Console run the following command:
Notice that the
HelloWorldRequest has an error. The information for the error can be found in the Error List window.
Click the K1001 error and navigate to the rule page.
Fix the request so that it looks like the following.
Deploy the API
The easiest way to deploy the API is directly in Visual Studio. First we will need to turn the console app into a web app so that we get the publishing features enabled. Right-click on the project in solution explorer and then click on “Edit HelloWorldService.csproj”. In the project file you will want to change the Sdk to Microsoft.NET.Sdk.Web.
Do not change the version of Kuno that you are using.
You will notice that the project icon in Solution Explorer has changed to the web project icon. Look for a file named launchSettings.json under Properties. We need to re-configure the web to use our port and startup location. The updated file should look like the following.
Run the project which should now open the web. If the web looks fine, right-click on the project in solution explorer and then click “Publish”. Select “Microsoft Azure App Service” and “Create New” then click “Publish”. Make sure you are signed in then enter the information to create you new site. See the images below for an example. When finished filling this out, click “Create”. It will take a couple minutes to create the site and when finished the browser will open to your new site. Add /swagger to the end of the URL and test the site. You have successfuly deployed you API.
More content can be found in the Learn More section. There you can find specifics on logging, data access, integration, best practices and more.