How to build an xml REST API f# type provider?

205 views Asked by At

I want to build an f# type provider for a web site (let's say Teamcity) with a REST API:

type teamcity = TeamCity<"host", port, "user", "password">
let context = teamcity.GetContext()
printfn "%d" context.Server.VersionMajor
for p in context.Server.Projects do
  printfn "%s" p.Name
(* ... *)

Please tell me if this is the way to go :

  • I cannot use XmlProvider as it requires samples, and it's hard to generate complete samples for the full API. For completeness, I have generated an xsd schema with the rest-api.jar and JAXB.
  • I can generate ProvidedTypeDefinitions parsing the xsd.
  • For each REST API call : I get an xml. The xml root element gives me the name of the ProvidedTypeDefinition. I create an instance of the ProvidedTypeDefinition with the xml as parameter (or some Runtime type with xml data like an array)
  • I do not need to implement in my Runtime assembly a record type for each REST API type (Server/Build/Project/etc.) as I can create instances with ProvidedTypeDefinitions.

Also, are there any wheel in FSharp.Data I can reuse?

Thanks in advance for your help!

0

There are 0 answers