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.
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);
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:
- 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 benonActive
- It's missing the
- 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 typeinteger
(together with a\d{13}
pattern) was used, althoughstring
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 typeint
, but the 13-digit number is too large for a plain/default int32, so we should useformat: int64
additionally.
- For datetimes, instead of using the obvious and easy choice - the dedicated
format: uuid
is better understood thanformat: UUID RFC4122
- (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
We also maintain a Python version of this data model.
You are very welcome to contribute to this template repository by opening a pull request against the main branch.