From f8337c3e963a18187144965a3de46b399841aac3 Mon Sep 17 00:00:00 2001 From: Egor Chemokhonenko Date: Thu, 28 Dec 2023 23:59:58 +0200 Subject: [PATCH] Make ref type path more flexible --- lib/generator.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/generator.ml b/lib/generator.ml index 706dff4..ee93f7c 100644 --- a/lib/generator.ml +++ b/lib/generator.ml @@ -15,9 +15,9 @@ let process_int_type schema = | _ -> failwith "int has unextected format" let get_ref (ref : ref_) = - match String.split_on_char '/' ref with - | [ "#"; "components"; "schemas"; type_name ] -> type_name - | _ -> failwith "only OpenAPI refs is supported (#/components/schemas/)" + match ref |> String.split_on_char '/' |> List.rev with + | type_name :: _ -> type_name + | _ -> failwith (Printf.sprintf "%s: can't resolve ref type name" ref) let rec ocaml_value_of_json = function | (`Bool _ | `Float _ | `Int _ | `Null) as json -> Yojson.Basic.to_string json