Giter VIP home page Giter VIP logo

nix-openapi-generator's Introduction

OpenAPI generator for Nix

This Nix library allows you to incorporate generation of client/server libraries from OpenAPI specification to your build process using OpenAPI generator

Examples

Building the library

For some generators such as c or cpp-qt-client, this flake allows you to compile a binary library:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
    openapi-generator.url = "github:FireFragment/nix-openapi-generator";
  };

  outputs = {
    self,
    flake-utils,
    nixpkgs,
    openapi-generator
  }:
    {
      overlay = import ./overlay.nix;
    }
    // flake-utils.lib.eachDefaultSystem (
      system: let
        pkgs = nixpkgs.legacyPackages.${system};
        openapi-gen = openapi-generator.lib.${system};

        # Use the "cpp-qt-client" generator
        generated = (openapi-gen.getGenerator "cpp-qt-client") {
          specification = pkgs.fetchurl {
            url = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/9df68a1dafd467d9fdbf68653f351b860b4ec6e5/examples/v3.0/petstore.yaml";
            sha256 = "sha256-WYE2y5BOF+ju6tUa4z3Y1AH9/0VdLXTzhpxKpfJ0ImY=";
          };
        };
      in {
        packages.default = generated.binary;
      }
    );
}

It can also generate source code using any generator listed on the OpenAPI generator webpage:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
    openapi-generator.url = "github:FireFragment/nix-openapi-generator";
  };

  outputs = {
    self,
    flake-utils,
    nixpkgs,
    openapi-generator
  }:
    {
      overlay = import ./overlay.nix;
    }
    // flake-utils.lib.eachDefaultSystem (
      system: let
        pkgs = nixpkgs.legacyPackages.${system};
        openapi-gen = openapi-generator.lib.${system};

        # Use the "cpp-qt-client" generator
        generated = (openapi-gen.getGenerator "cpp-qt-client") {
          specification = pkgs.fetchurl {
            url = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/9df68a1dafd467d9fdbf68653f351b860b4ec6e5/examples/v3.0/petstore.yaml";
            sha256 = "sha256-WYE2y5BOF+ju6tUa4z3Y1AH9/0VdLXTzhpxKpfJ0ImY=";
          };
        };
      in {
        packages.default = generated.sourceCode;
      }
    );
}

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.