Fork me on GitHub

Clinical Trials

Create a PHP Script To Generate An OpenAPI Specification From The ClinicalTrials.Gov Database I Created

One of my objectives around importing the data, is to create an API. The first step in creating an API, before we ever get programming anything, is to create an OpenAPI Spec for use as a version 1.0 scaffolding for the clinical trials data we now have stored in a MySQL database.

I sure wasn't going to be hand crafting an OpenAPI Spec for this fairly large data set, so I got to work creating a crude PHP script that would do the heavy lifting for me:

This script loops through all the tables in my clinical trials database, and auto generates the necessary JSON schema for the data structure, combined with OpenAPI Spec for describing the API interface for the clinical trials database. I have the result in a single OpenAPI Spec file, but will most likely be breaking up to make it easier to work with:

This OpenAPI Spec for the clinical trials API gives me a base blueprint I can use to generate server side code, client side code, documentation, and other essential building blocks of the API operations I put in place to support accessing the clinical trials API.

I will be added better descriptions for paths, parameters, schema, and other elements of this in the future, with this definition acting as the contract for the clinical trials API.