OCPI Contracts

The package contains a number of classes which are used to represent OCPI objects. You can see the full list of contract models here.

Validation

The package contains a collection of validators which you can use to validate incoming OCPI requests. To use a validator, call the OcpiValidate method of the OcpiController class. The method only allows validating OCPI models from the OCPI.Contracts namespace. In case of invalid request, further request handling will be aborted, and the error response will be returned to the client.

[OcpiEndpoint(OcpiModule.Locations, "Receiver", "2.2.1")]
[Route("2.2.1/locations")]
[OcpiAuthorize]
public class OcpiLocationsReceiverController : OcpiController
{
    [HttpPut("{countryCode}/{partyId}/{locationId}")]
    public IActionResult Put(
        [FromRoute] string countryCode,
        [FromRoute] string partyId,
        [FromRoute] string locationId,
        [FromBody] OcpiLocation location)
    {
        // Use a built-in OCPI validator
        OcpiValidate(location);

        // Your Location PUT logic

        Return OcpiOk(result);
    }

    // Other endpoint methods...
}

Validation functionality is built on top of FluentValidation nuget package.