ASP.NET Core 6 Succinctly by Dirk Strauss
Author:Dirk Strauss
Language: eng
Format: epub, mobi
Tags: An introduction to ASP.NET Core 6 web development.
Publisher: Syncfusion, Inc.
Figure 47: The Weather Forecast in Chrome
I like using Postman to test my APIs, but you can also use your browser to make the GET request, as seen in Figure 47. Minimal APIs also have full Swagger support, as seen in Code Listing 27, higher up in the Program file.
Go back to your properties and click to modify the Launch Profile for IIS Express, as shown in Figure 48. Select the option Launch browser.
Figure 48: Select to Launch the Browser
Figure 49: Viewing Your API in Swagger
Running your API again, you will see the browser launch and the Swagger page displayed for your weather forecast API. Under the MinAPI name at the top of our page, click the link https://localhost:44349/swagger/v1/swagger.json to view the Swagger JSON file. This file is shown in Code Listing 28.
The file displays the details of the minimal API based on the OpenAPI specification. You can see the details we set in the WithName method in Code Listing 27 show up in the operationId in the Swagger JSON file in Code Listing 28.
Other extension methods, such as WithTags, are available for use in your API to add metadata, so have a look at what there is on offer.
Code Listing 28: The Swagger JSON File
{
"openapi": "3.0.1",
"info": {
"title": "MinAPI",
"version": "1.0"
},
"paths": {
"/weatherforecast": {
"get": {
"tags": [
"MinAPI"
],
"operationId": "GetWeatherForecast",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/WeatherForecast"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"WeatherForecast": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date-time"
},
"temperatureC": {
"type": "integer",
"format": "int32"
},
"summary": {
"type": "string",
"nullable": true
},
"temperatureF": {
"type": "integer",
"format": "int32",
"readOnly": true
}
},
"additionalProperties": false
}
}
}
}
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12517)
Hello! Python by Anthony Briggs(9864)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9754)
The Mikado Method by Ola Ellnestam Daniel Brolund(9744)
Dependency Injection in .NET by Mark Seemann(9290)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8255)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7738)
Grails in Action by Glen Smith Peter Ledbrook(7664)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7513)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(6736)
Microservices with Go by Alexander Shuiskov(6499)
Practical Design Patterns for Java Developers by Miroslav Wengner(6402)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6378)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6375)
Angular Projects - Third Edition by Aristeidis Bampakos(5755)
The Art of Crafting User Stories by The Art of Crafting User Stories(5290)
NetSuite for Consultants - Second Edition by Peter Ries(5233)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5049)
Kotlin in Action by Dmitry Jemerov(5016)
