Skip to content

Commit

Permalink
fix: generate List as FhirList class
Browse files Browse the repository at this point in the history
  • Loading branch information
spicyfalafel committed Sep 26, 2024
1 parent 4360531 commit 76c9a8a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/aidbox_sdk/generator/python.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)))])})
Expand Down

0 comments on commit 76c9a8a

Please sign in to comment.