Skip to content

Commit

Permalink
Update README and add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wafflespeanut committed Jun 12, 2019
1 parent 2cf1de1 commit 1a6d4aa
Show file tree
Hide file tree
Showing 5 changed files with 690 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Paperclip

[![Build Status](https://api.travis-ci.org/wafflespeanut/paperclip.svg?branch=master)](https://travis-ci.org/wafflespeanut/paperclip)
[![API docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://paperclip.waffles.space/paperclip_openapi)
[![API docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://paperclip.waffles.space/paperclip)

WIP OpenAPI code generator for type-safe compile-time checked HTTP APIs in Rust.

Expand All @@ -11,7 +11,7 @@ The following features are supported at the moment:

- Generates API objects from schemas in an OpenAPI v2 spec.
- Generates builder structs for the API objects and HTTP operations.
- Fulfilled builder structs send API calls and return response futures (only `application/json` is supported as of now).
- Fulfilled builder structs send API calls and return response futures (only `https` and `application/json` is supported as of now).

See the [projects](https://github.com/wafflespeanut/paperclip/projects) for tracking the features in queue.

Expand Down Expand Up @@ -195,4 +195,4 @@ at your option.
I don't think proc macros are the right way to go for REST APIs. We need to be able to **see** the generated code somehow to identify names, fields, supported methods, etc. ([like this](https://paperclip.waffles.space/tests/test_k8s/api/)). With proc macros, you sorta have to guess.

This doesn't mean you can't generate APIs in compile-time. The only difference is that you'll be using [build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html) instead and `include!` the relevant code. That said, [we're using proc-macros](./macros) for other things.
This doesn't mean you can't generate APIs in compile-time. The only difference is that you'll be using [build scripts](#build-script-example) instead and `include!` the relevant code. That said, [we're using proc-macros](./macros) for other things.
1 change: 1 addition & 0 deletions openapi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2018"
failure = "0.1.5"
failure_derive = "0.1.5"
heck = { version = "0.3.1", optional = true }
itertools = "0.8.0"
lazy_static = "1.3.0"
log = "0.4.6"
paperclip-macros = { path = "../macros" }
Expand Down
2 changes: 1 addition & 1 deletion openapi/src/v2/codegen/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ where
.try_for_each(|field| {
if let Some(ParameterIn::Query) = field.param_loc {
if !query.is_empty() {
query.push_str(", ");
query.push_str(",");
}

write!(query, "\n (\"{}\", self.", &field.name)?;
Expand Down
3 changes: 2 additions & 1 deletion openapi/src/v2/codegen/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::object::ApiObject;
use failure::Error;
use heck::CamelCase;
use itertools::Itertools;

use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -53,7 +54,7 @@ impl EmitterState {
mod_path.push("mod.rs");

let mut contents = String::new();
for child in children {
for child in children.iter().sorted_by(|a, b| a.name.cmp(&b.name)) {
writeln!(
contents,
"
Expand Down
Loading

0 comments on commit 1a6d4aa

Please sign in to comment.