GithubHelp home page GithubHelp logo

isabella232 / reslang Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liveramp/reslang

0.0 0.0 0.0 13.01 MB

A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.

License: Apache License 2.0

JavaScript 0.26% TypeScript 89.97% Shell 1.44% Dockerfile 0.10% PEG.js 8.23%

reslang's Introduction

Reslang: API definitions made easy

Reslang is a simple language for describing resource-oriented APIs & turning them into Swagger. It produces Swagger/OpenAPI which is fully aligned with LiveRamp's API standards.

It can also generate an AsyncAPI specification, describing events, from the same spec. Recently we have added the ability to generate JSON schema from the Reslang spec too.

Release notes

Reslang is licensed under Apache V2

Docs

Topic Description
Why reslang? Why do we need this tool and what does it offer?
Intro tutorial Describes making a toy API for manipulating files and directories.
The API paradigm What is the Reslang paradigm and how does it relate to REST, OO and RPC
Event intro tutorial Describes a simple example of how to generate AsyncAPI to describe events
Sections This explains how to reorder / group the presentation of your resources
Direct2Dist API This is a more complex example which recreates the entire Direct2Dist API.
MULTI verbs Describes MULTI- verbs such as MULTIPOST, MULTIPATCH etc
Reference manual This describes the syntax and features in more depth.
Server blocks This explains how to define servers for REST and events APIs
JSON schema generation This explains how to generate JSON schema definitions from Reslang code
Internal System Design Explains how Reslang is structured as a typescript application, and how the transpiler works
VSCode Syntax highlighting Explains how to install VSCode syntax highlighting. Hint search extensions for Reslang!

Installation

For local use

  1. ensure node & yarn are installed

(This is the node.js stack - please see here for installation instructions: node.js & yarn)

  1. clone the reslang repo
  2. yarn install
  3. ./install-reslang

Note that step 4 installs it as a command line tool using "yarn link"

Running

Test it out by typing:

reslang

This should bring up the options.

Click to see Installation options

Running in Docker (for internal LiveRamp users only)

Individuals who do not want to build Reslang from scratch are free to use the reslang-docker script which provides convenient, but limited, functionality with a reslang container. This script outputs the generated swagger to STDOUT and requires an absolute path to function.

    bash ./reslang-docker.sh $PWD/models/distribution

Creating & viewing the Swagger / OpenAPI

To create swagger, you first create a reslang file. Then you simply ask the reslang program to turn this into swagger.

Note that the models directory has a set of example definitions.

The following copies the swagger to the clipboard and opens the ReDoc browser for you.

reslang models/simple-resource --open

If you want just want to print to stdout use:

reslang models/simple-resource --stdout

Viewing Swagger / OpenAPI in Swagger editor

If you want to use the Swagger editor, add --web to the cmd line:

reslang models/simple-resource --open --web

Then paste the clipboard into the left window pane of the editor.

Creating a graphical view

Reslang can generate dotviz output, which provides a nice graphical view of the resources.

The following command will copy the dotviz output to the clipboard.

reslang models/simple-resource --open --diagram main

This will open your browser at a nice graphviz online editor. Paste the clipboard into the editor and you will get your graphical view of your API - a resource diagram.

Viewing events via AsyncAPI

Reslang can generate AsyncAPI, describing the events a REST API can generate. It also provides an "event" keyword which you can use to describe adhoc events.

reslang models/eventing --open --events

If instead you wish to view the events in the AsyncAPI Playgrounder for editing, please add the --web option.

reslang models/eventing --open --events --web

Note that the AsyncAPI spec has been copied to the clipboard - you will need to paste it into the opened editor, on the left.

Pretty Printing - Stripping out the comments for review

Reslang can produce a nice pretty-printed, stripped down version of the Reslang in html. It is often easier to review this form, as it removes the comments and error structures.

reslang models/resources --stripped --open

Will open a browser on the stripped down file. If you just want plain text, add --plain

Requesting new features

New features and enhancements that involve changing LiveRamp's API standards will not be considered until the API standards proposal process is complete.

Other enhancements should be requested by opening a GitHub Issue using the appropriate issue template or by opening a Pull Request and having your changes reviewed by the API Squad.

reslang's People

Contributors

andrewmcv avatar bobisme avatar cjea avatar dependabot[bot] avatar jacobcrofts avatar joshlang232 avatar nhtzr avatar njaczko avatar sagarrbatchu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.