Open Api -> Hydra Parser Part 1

Vaibhav Chellani
openapi-hydra-parser-gsoc2018
2 min readMay 26, 2018

I enthusiastically started with the first implementation of the parser with the following plan in mind . We have some very obvious markings namely , hydra class -> OAS definition(where ever object is defined) , hydraClass.supportedProps -> OAS definition.schema , hydraClass.supportedOps -> OAS path object .

The way to parse this from the top of my head which was fairly simplistic was as follows :

  • Parse the ‘definitions’ object (here i wrongly assumed that objects can only be defined in the definitions object , will come back to this mistake soon) and get class name , description , schema , properties and defined hydra class and supported properties using that .
  • Make a global list for storing all class names and append to list as we parse in the above step
  • Make a global dict for mapping class names with the currently defined class definition , we add more stuff to this class definition in the below step and finally add this definition to the doc .
  • Parse the ‘paths’ object for and when the path name matches one of the class names in the global list we parse the methods defined and convert them to hydraClass supported ops object .
  • We attach the newly found supported ops to the class definition using the global dictionary .
  • Finally we add all the classes to the doc and generate an entrypoint for the application .

Overall this implementation was pretty basic and we assumed a lot of things for example :

  • We assumed there are no collections , so by default collection = “false”
  • We assumed there all classes have endpoints , so by default enpoint = “true”
  • We assumed the HYDRA classes or OAS definitions can only be defined in ‘definitions’ object .

But thankfully this parser would work with a lot of standard OAS specifications and worked pretty good , but we cannot have any assumptions at all so lets move to ‘Open Api -> Hydra Parser Part 2’ .

Here is the [PR](https://github.com/HTTP-APIs/hydrus/pull/197) for this work

--

--