Creating Basic WebAPI
Options
• Configure for HTTPS: This option configures the [Link] Core application
to use HTTPS (Hypertext Transfer Protocol Secure) by default.
• HTTPS ensures that the communication between the client and server is
encrypted, enhancing security.
• When this option is selected, Visual Studio sets up the necessary SSL
(Secure Sockets Layer) certificates and configures the application to listen
on an HTTPS endpoint.
• Enable Docker Support: Selecting this option adds a Dockerfile to the
project and configures it for Docker containerization.
• Docker is a platform used for developing, shipping, and running
applications inside containers.
Options
• Use Controllers: This option structures the Web API project to use MVC
(Model-View-Controller) controllers.
• Controllers are classes that handle incoming HTTP requests and return
responses.
• Enable OpenAPI Support: OpenAPI, also known as Swagger, is a
specification for building APIs.
• Enabling OpenAPI support automatically generates documentation for the
API, provides a UI for testing API methods, and helps with client
generation.
Features of Swagger
• API Documentation: Swagger automatically generates interactive API
documentation, known as Swagger UI, based on the [Link] Core Web API
Project.
• This documentation includes details about endpoints, parameters, request
and response schemas, and even allows users to try out API calls directly
from the documentation interface.
• Standardization: Swagger uses the OpenAPI Specification (OAS), which is a
widely adopted industry standard for documenting RESTful APIs.
• Testing and Debugging: Through Swagger UI, developers can send requests
to the API, view the responses, and effectively test API functionality in a
user-friendly web interface.
Folders and Files in WebAPI
Folders and Files in WebAPI
• Connected Services:
• This section within the Solution Explorer in Visual Studio allows user
to easily connect to external services such as Azure, Office 365, or
third-party REST API services.
• Dependencies:
• The Dependencies folder contains all the packages and SDKs installed
into the project.
• It contains three files (Analyzers, Frameworks, and Packages).
Folders and Files in WebAPI
• Analyzers:
• Analyzers are tools that inspect the code for issues, style violations, or
other problems.
• They help maintain code quality by providing suggestions or warnings
directly within the IDE.
• Frameworks:
• Frameworks within the Dependencies folder refer to the core libraries and
components on which the [Link] Core Web API project depends.
• This includes the [Link] Core framework itself, along with any additional
frameworks or runtime libraries required by the project.
Folders and Files in WebAPI
• Packages:
• Packages in the Dependencies folder contain all external libraries and tools
that the project utilizes.
• Packages are managed via NuGet, allows user to easily add, update, or
remove dependencies as the project evolves.
• Properties:
• The Properties Folder in the [Link] Core Web API Application, by default,
contains one JSON file called [Link] file.
• This [Link] file contains configuration settings for launching
the application, such as environment variables and application URLs that
will be used by .NET Core Framework.
Folders and Files in WebAPI
• Controllers Folder:
• The [Link] Core Web API is a Controller-Based Approach.
• All the controllers of [Link] Core Web API Application should and must
reside inside the Controllers folder.
• These classes handle incoming HTTP requests, execute the appropriate
logic, and return HTTP responses.
• Each controller typically corresponds to a resource or a set of related
endpoints. By default, a sample WeatherForecastController is included,
demonstrating how to build API endpoints.
• [Link] file:
• This file is used for configuration settings such as connection strings, API
keys, logging settings, and custom configurations.
Folders and Files in WebAPI
• [Link] Class File:
• This is the entry point of the application.
• It contains the Main method where the application is configured and
started.
• Here, it sets up the [Link] Core host, configures services, and the
middleware pipeline settings for your application.
• [Link] class file:
• This is the model class. The model represents the structure and shape of
data.