Skip to content

An api tool for building rest apis, heavily inspired by GQL syntax.

License

Notifications You must be signed in to change notification settings

Cowboy-coder/yipp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yipp

Use a GQL-inspired syntax to build a schema-first driven REST API.

# schema.yipp

type FieldError {
  field: String!
  message: String!
}

type Error {
  message: String!
  fields: [FieldError!]!
} 

enum UserType {
  admin
  user
}
  
login: POST /login {
  body: {
    username: String!
    password: String!
  }
  200: {
    body: {
      token: String!
    }
  }
  400: {
    body: Error
  }
} 

getUser: GET /users/:id(Int) {
  headers: {
    authorization: String!
  }
  
  200: {
    body: {
      id: Int!
      username: String!
      type: UserType!
    }
  }

  400: {
    body: Error
  }
}

Install and usage

npm install -g yipp
yipp axios-client output.ts schema.yipp

CLI

Can be used to generate different clients, servers, etc.

Example of generators using this schema:

Usage: yipp [options] <type> <output-file> <input-file...>

generate

Arguments:
  type         (choices: "fastify-plugin", "axios-client")
  output-file  generated typescript file
  input-file   One or more api schema files. Will be merged into one schema if several files.

Options:
  -w --watch   watch for changes (default: false)
  -h, --help   display help for command

🐄

About

An api tool for building rest apis, heavily inspired by GQL syntax.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published