Skip to content

Commit 22cbfed

Browse files
hf-kkleinKonstantin
andauthored
Replace format: UUID RFC4122 with format: uuid (.yml) and UUID instead of str (.py) (#8)
* Replace `format: UUID RFC4122` with `format: uuid` (.yml) and `UUID` instead of `str` (.py) * Update README.md --------- Co-authored-by: Konstantin <konstantin.klein+github@hochfrequenz.de>
1 parent a8021ac commit 22cbfed

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Most of the classes are autogenerated from the [`openapi.yml`](openapi/openapi.y
4747
Note that we fixed some errors in the official OpenAPI spec.
4848
Our changes are mentioned at the beginning of the [`openapi.yml`](openapi/openapi.yml) file.
4949

50-
https://github.com/Hochfrequenz/malo-ident-python-models/blob/fe41321c74773336984a3517adc79b3ac4f43349/openapi/openapi.yml#L4-L8
50+
https://github.com/Hochfrequenz/malo-ident-python-models/blob/2e1784c93d000bb7503a9688f1c648059481c2fc/openapi/openapi.yml#L4-L9
5151

5252
After updating the `openapi.yml` file, use
5353

openapi/openapi.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# b) there is a typo: 'nonActice' should be 'nonActive'
77
# 2. Some yaml parsers fail, because: Multi-line double-quoted strings are not sufficiently indented (can be found with prettier in CI)
88
# 3. Datetimes are poorly designed. Instead of using the OpenAPI format:date-time, a regex with good intentions is used. This leads to code-generators using type string instead of datetime.
9+
# 4. 'format: UUID RFC4122' may not be recognized but is valid: "Formats such as "email", "uuid", and so on, MAY be used even though undefined by this specification".
910

1011
openapi: 3.0.0
1112
servers:
@@ -481,7 +482,7 @@ components:
481482
initialTransactionId:
482483
type: string
483484
description: Zur Angabe des Idempodenzschlüssel im Falle eines Retry.
484-
format: UUID RFC4122
485+
format: uuid # ERROR-4
485486
example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
486487

487488
lotNumber:
@@ -727,7 +728,7 @@ components:
727728
referenceId:
728729
type: string
729730
description: Externe Vorgangsreferenz zur eindeutigen Identifikation des ursprünglichen Vorgangs
730-
format: UUID RFC4122
731+
format: uuid # ERROR-4
731732
example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
732733
resultNegative:
733734
description: Hier wird bei einer neagtiven Antwort der Entscheidungsbaum und der entsprechende Antwortcode aus dem Entscheidungsbaumdiagramm angegeben. Wenn sich die Marktlokation nicht mehr im Netzgebiet befindet ist die MP-ID des NB als "networkOperator" anzugeben, an den die Marktlokation abgegeben wurde.
@@ -827,7 +828,7 @@ components:
827828
transactionId:
828829
type: string
829830
description: Externe Transaktionsnummer zur eindeutigen Identifikation des Vorgangs des sendenden Marktpartners
830-
format: UUID RFC4122
831+
format: uuid # ERROR-4
831832
example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
832833
trId:
833834
pattern: "D[A-Z\\d]{9}\\d"

src/maloident/_autogenerated.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# generated by datamodel-codegen:
22
# filename: openapi.yml
3-
# timestamp: 2024-10-02T11:39:11+00:00
3+
# timestamp: 2024-10-02T11:57:20+00:00
44

55
from __future__ import annotations
66

77
from enum import Enum
88
from typing import List, Optional
9+
from uuid import UUID
910

1011
from pydantic import AwareDatetime, BaseModel, Field, RootModel, constr
1112

@@ -104,8 +105,8 @@ class IdentificationDateTime(RootModel[AwareDatetime]):
104105
)
105106

106107

107-
class InitialTransactionId(RootModel[str]):
108-
root: str = Field(
108+
class InitialTransactionId(RootModel[UUID]):
109+
root: UUID = Field(
109110
...,
110111
description="Zur Angabe des Idempodenzschlüssel im Falle eines Retry.",
111112
examples=["f81d4fae-7dec-11d0-a765-00a0c91e6bf6"],
@@ -235,8 +236,8 @@ class ResponseCode(RootModel[constr(pattern=r"A[A-Z\d]{2}")]):
235236
)
236237

237238

238-
class ReferenceId(RootModel[str]):
239-
root: str = Field(
239+
class ReferenceId(RootModel[UUID]):
240+
root: UUID = Field(
240241
...,
241242
description="Externe Vorgangsreferenz zur eindeutigen Identifikation des ursprünglichen Vorgangs",
242243
examples=["f81d4fae-7dec-11d0-a765-00a0c91e6bf6"],
@@ -291,8 +292,8 @@ class TrancheSupplier(BaseModel):
291292
executionTimeUntil: Optional[ExecutionTimeUntil] = None
292293

293294

294-
class TransactionId(RootModel[str]):
295-
root: str = Field(
295+
class TransactionId(RootModel[UUID]):
296+
root: UUID = Field(
296297
...,
297298
description="Externe Transaktionsnummer zur eindeutigen Identifikation des Vorgangs des sendenden Marktpartners",
298299
examples=["f81d4fae-7dec-11d0-a765-00a0c91e6bf6"],

0 commit comments

Comments
 (0)