Skip to content
This repository has been archived by the owner on Nov 12, 2017. It is now read-only.

Bogdanp/cedar

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

cedar PyPI version Build Status Coverage Status Codacy Badge

This is alpha-level stuff.

Cedar is a small web service declaration language. You declare your service using this language and then use that declaration to generate client and server code for a number of programming languages.

Goals

  • A single transport (http) and serialization format (json).
  • Simple, consolidated tooling. All functionality must live under this repository and must be distributed under one package.
  • Aim to be an 85% solution. Be the most simple thing that covers the widest array of use cases. Never add complexity for the sake of covering fringe use cases.
  • Generated source code must be idiomatic to the generated language.
  • Generated source code must be human-readable.

Installation

pip3 install cedar

Languages

Cedar currently targets Elm (clients) and Go (servers) source code.

Go

cedar generate go --help

Requirements

Generated Go code has no external dependencies, but it does require at least Go version 1.6.

Elm

cedar generate elm --help

Requirements

Generated Elm code currently requires Elm 0.17 and the following packages:

The Cedar language

A Cedar specification consists of one or more toplevel declarations. All toplevel declarations must be valid enums, unions, records or fns.

Example

enum Role { User, Mod, Admin }

record User {
  id Int
  email String
  role Role
}

fn getUsers() [User]
fn getUser(id Int) User?
fn deleteUser(id Int) Bool

Types

There are 5 builtin types: Bool, Int, Float, String and Timestamp.

List types are declared using the [t] syntax (eg. [String]), dict types are declared using the {String: t} syntax, and nullable types are declared using the t? syntax.

Enums

enum Status { Ready, Done, Failed }

Enums introduce new types (named after the enum) whose values are constrained to the tags defined in the enum. The tags inside an enum are serialized as strings. For example, a record attribute with the type Status can contain one of the following JSON values: "Ready", "Done" and "Failed".

Unions

union Resource { Post, Comment }

Unions join multiple types under a single new type.

Records

record Post {
  id Int
  title String
  content String
  publishedAt Timestamp
}

Functions

fn createPost(title String, content String, publishedAt Timestamp?) Post

Editor support

About

A web service definition format and source code generator.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages