Skip to content

Commit

Permalink
Replace format: UUID RFC4122 with format: uuid (.yml) and UUID
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
hf-kklein and Konstantin authored Oct 2, 2024
1 parent a8021ac commit 22cbfed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Most of the classes are autogenerated from the [`openapi.yml`](openapi/openapi.y
Note that we fixed some errors in the official OpenAPI spec.
Our changes are mentioned at the beginning of the [`openapi.yml`](openapi/openapi.yml) file.

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

After updating the `openapi.yml` file, use

Expand Down
7 changes: 4 additions & 3 deletions openapi/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# b) there is a typo: 'nonActice' should be 'nonActive'
# 2. Some yaml parsers fail, because: Multi-line double-quoted strings are not sufficiently indented (can be found with prettier in CI)
# 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.
# 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".

openapi: 3.0.0
servers:
Expand Down Expand Up @@ -481,7 +482,7 @@ components:
initialTransactionId:
type: string
description: Zur Angabe des Idempodenzschlüssel im Falle eines Retry.
format: UUID RFC4122
format: uuid # ERROR-4
example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6

lotNumber:
Expand Down Expand Up @@ -727,7 +728,7 @@ components:
referenceId:
type: string
description: Externe Vorgangsreferenz zur eindeutigen Identifikation des ursprünglichen Vorgangs
format: UUID RFC4122
format: uuid # ERROR-4
example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
resultNegative:
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.
Expand Down Expand Up @@ -827,7 +828,7 @@ components:
transactionId:
type: string
description: Externe Transaktionsnummer zur eindeutigen Identifikation des Vorgangs des sendenden Marktpartners
format: UUID RFC4122
format: uuid # ERROR-4
example: f81d4fae-7dec-11d0-a765-00a0c91e6bf6
trId:
pattern: "D[A-Z\\d]{9}\\d"
Expand Down
15 changes: 8 additions & 7 deletions src/maloident/_autogenerated.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# generated by datamodel-codegen:
# filename: openapi.yml
# timestamp: 2024-10-02T11:39:11+00:00
# timestamp: 2024-10-02T11:57:20+00:00

from __future__ import annotations

from enum import Enum
from typing import List, Optional
from uuid import UUID

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

Expand Down Expand Up @@ -104,8 +105,8 @@ class IdentificationDateTime(RootModel[AwareDatetime]):
)


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


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


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

0 comments on commit 22cbfed

Please sign in to comment.