REST-API-Endpoint-Generator

Welcome! This is a simple project that Automatically generates REST API Endpoints from the component definitions of an OpenAPI schema.

What it does

When defining an API under the OpenAPI specification, functions have a common pattern. With CRUD operations all around the same components referenced, so that functions have consistency in their format, in their inputs, outputs, etc, one realizes that much of this can be auto-generated.

When the underlying component schemas for an OpenAPI doc are defined, the functions are mostly straightforward to create. The idea here is to easily do that - define your component schemas, then autogenerate your endpoints.

In the process, one can auto-fill much of the rest of the OpenAPI doc: establishing security rules, pagination for lists, and errors. These are provided as well in this project.

View Working Demo

How it Works - Demo App

The page allows you to copy an OpenAPI Schema in JSON format, containing only components (no paths need to be defined). Simply paste the JSON of the schema in the designated text area, and press “Create Functions.”

You may also choose a few options:

You can choose to receive the output in JSON or YAML format.

You may also run the demo file programmatically by loading it with query parameters:

How it Works - Code

test.html

This contains two unique functions:

APIFunctionMaker.js

The main function here is createRESTFunction, which accepts a JSON representation of an OpenAPI schema and generates a JSON object returning the updated OpenAPI schema, with custom settings.

Issues and feature enhancements

Files:

Dependencies: