Skip to content
Devin Smith edited this page Aug 13, 2021 · 1 revision

PIMS API

The PIMS API provides an RESTful interface (developed in .NET Core 3.1) to interact with the configured data-source (MSSQL Server 2020).

The API is configured to run in a Docker container and has the following dependencies with other containers; database, keycloak.

More information here.

Table of Contents

Title Description
Data Access Layer Data Access Layer (DAL) information.
Database How to manage the database and data migrations.
Versioning Version information.

Swagger

The API is documented with Open API.

Swagger UI

API Endpoint Versioning

Versioning is supported through route paths.

See Microsoft's AspNet Api Versioning plugin here.

Health Checks UI

The API is monitored through an internal healthcheck library. The project HealthChecks.UI is a minimal UI interface that stores and shows the health checks results from the configured HealthChecks uris.

See Microsoft AspNet Diagnostics Health Checks here.

Health checks are configured to run against /api/live and /api/ready endpoints. These correspond to the kubernetes concepts of liveliness and readiness, see here.

Health Checks UI is a UI wrapper around the above health check endpoints. Configuration is provided within appsettings.json. The webhook URI should be provided separately as an environment variable HealthChecksUI__Webhooks__0__Uri. See here for more information about the structure of the Payload and RestorePayload configuration options.

Health Check UI - Uptime Robot

Static Code Analysis with SonarQube

SonarQube is an open-source automatic code review tool to detect bugs, vulnerabilities and code smells in your code. It can integrate with your existing workflow to enable continuous code inspection across your project branches and pull requests.

What does analysis produce?

SonarQube can perform analysis on up to 27 different languages. The outcome of this analysis will be quality measures and issues (instances where coding rules were broken).

PIMS SonarQube dashboard is available here

Installing SonarScanner for MSBuild

There are several options to install SonnarScanner for MSBuild.

The simplest way is to install it as global tool for .NET Core;

dotnet tool install --global dotnet-sonarscanner

Triggering a manual scan on the NET Core backend API

Follow the commands below to trigger a manual scan of PIMS API.

When the scan is completed the results will be available on PIMS SonarQube Dashboard

cd backend

dotnet sonarscanner begin -k:"bcgov_PIMS_API" \
  -d:sonar.host.url="https://sonarqube-jcxjin-tools.pathfinder.gov.bc.ca" \
  -d:sonar.login="{token}"
  
dotnet build --no-incremental

dotnet sonarscanner end -d:sonar.login="{token}"