GithubHelp home page GithubHelp logo

wvlet / sbt-airframe Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 83 KB

A sbt plugin for generating Airframe RPC clients and OpenAPI spec

Home Page: https://wvlet.org/airframe/docs/airframe-rpc

License: Apache License 2.0

Scala 56.46% Shell 39.50% Ruby 4.04%
scala airframe grpc rpc rest-client finagle openapi

sbt-airframe's Introduction

โš ๏ธ This project has moved to a sub-folder of the Airframe repository: https://github.com/wvlet/airframe/tree/master/sbt-airframe

sbt-airframe plugin

A sbt plugin for generating Airframe RPC clients

sbt-airframe plugins supports generating HTTP clients for making RPC calls. sbt-airframe supports generating async, sync, or Scala.js HTTP clients.

maven central

Add the following plugin settings:

project/plugins.sbt

addSbtPlugin("org.wvlet.airframe" % "sbt-airframe" % "(version)")

To generate HTTP clients, add airframeHttpClients setting to your build.sbt. You need to specify which API package to use for generating RPC clients. The format is <RPC package name>:<client type>(:<target package name>(.<target class name>)?)?. For example:

build.sbt

enablePlugins(AirframeHttpPlugin)

airframeHttpClients := Seq("hello.api.v1:sync")

// [optional] Specify airframe-http version to use
aifframeHttpVersion := (AIRFRAME_VERSION)

Supported client types are:

  • sync: Create a sync HTTP client (ServiceSyncClient) for Scala (JVM)
  • async: Create an async HTTP client (ServiceClient) for Scala (JVM) using Future abstraction (F). The F can be scala.concurrent.Future or twitter-util's Future.
  • scalajs: Create an RPC client (ServiceClientJS)
  • grpc: Create gRPC client factory (ServiceGrpc: SyncClient, AsyncClient)

To support other types of clients, see the examples of HTTP code generators . This code reads a Router definition of RPC interfaces, and generate client code for calling RPC endpoints. Currently, we only supports generating HTTP clients for Scala. In near future, we would like to add Open API spec generator so that many programming languages can be used with Airframe RPC.

The generated client code can be found in target/scala-2.12/src_managed/(api package)/ folder.

sbt-airframe commands

# Regenerate the generated client code.Use this if RPC interface has changed
> airframeHttpReload

# Generating RPC clients manually
> airframeHttpGenerateClients

# Clean the generated code
> airframeHttpClean

Open API

sbt-airframe plugin also supports generating Open API specification from Airframe RPC interfaces. To generate OpenAPI spec from RPC definition, add airframeHttpOpenAPIPackages configuration to your build.sbt:

// [Required] RPC packages to use for generating Open API specification
airframeHttpOpenAPIPackages := Seq("hello.api")
// [Optional] Specify target directory to generate openapi.yaml. The default is target directory
airframeHttpOpenAPITargetDir := target.value
// [Optional] Additional configurations (e.g., title, version, etc.)
airframeHttpOpenAPIConfig := OpenAPIConfig(
  title = "My API", // default is project name
  version = "1.0.0", // default is project version,
  format = "yaml", // yaml (default) or json
  filePrefix = "openapi" // Output file name: (filePrefix).(format)
)

With this configuration, Open API spec will be generated when running package task:

> package

It will generate target/openapi.yaml file.

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.