diff --git a/bin/openapi_cli.ml b/bin/openapi_cli.ml index f3bd547..6959ee7 100644 --- a/bin/openapi_cli.ml +++ b/bin/openapi_cli.ml @@ -28,7 +28,11 @@ let with_spec spec_path f = if is_yaml_file spec_path spec_content then begin Logs.info (fun m -> m "Detected YAML format"); let codec = Yaml_json.of_json Openapi.Spec.jsont in - Yaml.decode_string codec spec_content + match Yaml.of_string codec spec_content with + | Ok [spec] -> Ok spec + | Ok [] -> Error "YAML stream contains no documents" + | Ok _ -> Error "YAML stream contains multiple documents; expected one" + | Error e -> Error (Yaml.Error.to_string e) end else Openapi.Spec.of_string spec_content in