Skip to content

Hochfrequenz/malo-ident-net-models

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nuget Package License: MIT

MaLo Ident .NET Models

This repository contains the nuget package MaLoIdentModels which contains C# model classes with System.Text.Json attributes for the Marktlokation Identification API by EDI@Energy.

Installation and Use

Install it from nuget MaLoIdentModels:

dotnet add package MaLoIdentModels

Then use it

using MaLoIdentModels;
// ...
var myNegativeResponse = new ResultNegative()
{
   DecisionTree = "E_0594",
   ResponseCode = "A10",
   Reason = "Ich bin ein Freitext.",
   NetworkOperator = 9900987654321
};
var myJson = System.Text.Json.JsonSerializer.Serialize(myNegativeResponse);
Console.Out.WriteLine(myJson);

Why are only parts of the code autogenerated?

The classes are generally based on the MaLo Ident OpenAPI specification. But although auto-generation of code is theoretically possible, the classes are not autogenerated for multiple reasons:

  1. The OpenAPI spec as of 2024-07-03 v1.0.0 contains obvious errors in the marketLocationProperty:
    • It's missing the measured valued which is given as example but not part of the enum members (or the example is wrong).
    • there is a typo in a enum member: nonActice should be nonActive
  2. Although the OpenAPI is syntactically valid, it is poorly designed :
    • For datetimes, instead of using the obvious and easy choice - the dedicated date-time format, the OpenApi by EDI@Energy uses wild regex patterns (e.g. creationDateTime: 20(\\d{2}(\\-(0[13578]|1[02])\\-(0[1-9]|[12]\\d|3[01])|\\-02\\-(0[1-9]|1\\d|2[0-8])|\\-(0[469]|11)\\-(0[1-9]|[12]\\d|30))|([02468][048]|[13579][26])\\-02\\-(29))T([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(\\.[\\d]{1,4})?Z - are you serious?).
    • For the property marketPartnerId, the type integer (together with a \d{13} pattern) was used, although string would be the right choice (for the same reasons as you don't use integer for Postleitzahlen or MaLo-IDs). As a consequence, the autogenerated code uses type int, but the 13-digit number is too large for a plain/default int32, so we should use format: int64 additionally.
  3. format: uuid is better understood than format: UUID RFC4122
  4. (Technical) We wanted to use System.Text.Json in .NET8 (and not Newtonsoft in .NET6) and did not find a a working code generator.

We maintain a better version of the openapi.yml without all the shortcomings in the Python version: Hochfrequenz/malo-ident-python-models/openapi/openapi.yml

See also

We also maintain a Python version of this data model.

Contributing

You are very welcome to contribute to this template repository by opening a pull request against the main branch.