From 76c9a8a3d4afe58d560fccbc849b0b993f5e9e64 Mon Sep 17 00:00:00 2001 From: spicyfalafel <285574@niuitmo.ru> Date: Thu, 26 Sep 2024 17:56:16 +0300 Subject: [PATCH] fix: generate List as FhirList class --- src/aidbox_sdk/generator/python.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/aidbox_sdk/generator/python.clj b/src/aidbox_sdk/generator/python.clj index dd64b3e..e79983d 100644 --- a/src/aidbox_sdk/generator/python.clj +++ b/src/aidbox_sdk/generator/python.clj @@ -48,13 +48,16 @@ (defn url->resource-name [reference] (last (str/split (str reference) #"/"))) +(defn class-alias [class-name] + (get {"List" "FhirList"} class-name class-name)) + (defn class-name "Generate class name from schema url." [url] (-> url url->resource-name - uppercase-first-letter - (str/replace #"-" "_"))) + ->pascal-case + class-alias)) (defn generate-deps [deps] (->> deps @@ -290,7 +293,7 @@ :content (generate-module :deps (concat [{:module "typing" :members ["Optional" "List"]} {:module "dataclasses" :members ["dataclass"]}] - (map (fn [d] {:module "base" :members [d]}) + (map (fn [d] {:module "base" :members [(class-alias d)]}) (:deps ir-schema))) :classes [(generate-class ir-schema (map generate-class (:backbone-elements ir-schema)))])})