Code Monkey home page Code Monkey logo

openapi-boilerplate's Introduction

alt text

OpenAPI Boilerplate

build License: MIT

A template for OpenAPI Specification projects.

This project breaks the Swagger Petstore example from the official documentation into smaller files. It also adds some handy commands to build, lint, and preview the OpenAPI specification from the command-line.

Either if you want to create a new OpenAPI document from scratch or you already have it defined, you can use this template as a guide to structuring your project.

Features

  • Multi-file Support: Define the OpenAPI document in different files.
  • Merge OpenAPI files: Merge all the separate files into one with swagger-cli
  • Specification Validation: Validate and lint the OAS document with spectral
  • Reference Documentation: Generate API Reference documentation with ReDoc
  • GitHub Pages Support: Publish the API Reference on GitHub Pages

Getting Started

Requirements

  • Node.js 14 LTS

Installation

  1. Clone the repository.
git clone https://github.com/dgarcia360/openapi-boilerplate.git
  1. Install the project dependencies.
npm install
  1. Edit openapi.yaml to fit your API definition. If you are not familiar with the OpenAPI Specification, it's worth taking a look first to the documentation.

Useful Commands

Build

The command bundles the spec as one .yaml file.

npm run build

The minified document is stored in _build/openapi.yaml.

Test

The command checks if the document follows the OpenAPI 3.0 Specification.

npm run test

Preview

The command builds a docs site so that you can view the rendering on your local browser.

npm run preview

The server starts on http://127.0.0.1:8080

Ready-to-Use Workflows

The project uses GitHub Actions for Continous Integration.

On every new pull request, the OpenAPI document is linted with spectral. If there are changes that introduce errors, the bot will highlight them replying to the pull request.

When the default branch (master) receives an update, a workflow automatically publishes the API reference documentation site to GitHub Pages. The site is generated with ReDoc.

See .github/workflows to customize the available workflows. If you don't plan to use GitHub to host your spec or prefer to keep docs private, delete the .github folder.

Contributing

Contributions are welcome and appreciated! If you want to enhance the boilerplate, please read CONTRIBUTING.md file first.

License

Copyright (c) 2019-present David Garcia (@dgarcia360). Licensed under the MIT License.

The PetStore example used is derived from OAI/OpenAPI-Specification, Copyright The Linux Foundation, Licensed under the Apache License, Version 2.0.

openapi-boilerplate's People

Contributors

dgarcia360 avatar mikeralphson 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.