Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme #134

Merged
merged 7 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 87 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,86 @@
# Wirespec
Type safe wires made easy
Readable contracts and typesafe wires made easy

## Introduction
Wirespec is a typesafe language to specify data transfer models which are exchanged between services. These models can be transformed into bindings for a specific language (Typescript, Java, Kotlin, Scala).
Wirespec is a typesafe language to specify data transfer models which are exchanged between services. These models can be transformed into bindings for a specific language (Typescript, Java, Kotlin, Scala). Wirespec is 💯 compatible with OpenApiSpecification (OAS).

![overview](images/overview.png)

## Syntax
Wirespec language has four type of deffinitions: `refined`, `enum`, `type`, `refined`.

```
refined DEFINITION /REGEX/g

enum DEFINITION {
ENTRY, ENTRY, ...
}

type DEFINITION {
IDENTIFIER: REFERENCE
}

endpoint DEFINITION METHOD [INPUT_REFERENCE] PATH [? QUERY] [# HEADER] -> {
STATUS -> REFERENCE
}

```

## Example

`todo.ws`
```wirespec
refined UUID /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/g

type Todo {
id: UUID,
name: String,
done: Boolean
}

type TodoInput {
name: String,
done: Boolean
}

type Error {
code: String,
description: String
}

endpoint GetTodoById GET /todos/{id:UUID} -> {
200 -> Todo[]
404 -> Error
}

endpoint GetTodos GET /todos ? {done:Boolean?} # {limit:Integer, offset:Integer} -> {
200 -> Todo[]
404 -> Error
}

endpoint CreateTodo POST TodoInput /todos -> {
200 -> Todo
404 -> Error
}

endpoint UpdateTodo PUT TodoInput /todos/{id:UUID} -> {
200 -> Todo
404 -> Error
}

endpoint DeleteTodo DELETE /todos/{id:UUID} -> {
200 -> Todo
404 -> Error
}
```

## Usage

Wirespec files can be transformed into language specific binding by using the cli

```shell
wirespec ./todo.ws -o ./tmp -l Kotlin
```

## Dependencies
* JDK 17
Expand Down Expand Up @@ -36,24 +114,26 @@ Options:
#### Linux
```
curl -L https://github.com/flock-community/wirespec/releases/latest/download/linuxX64.kexe -o wirespec
chmod +x wirespec
sudo mv ./wirespec /usr/local/bin/wirespec
```

#### macOS
```
curl -L https://github.com/flock-community/wirespec/releases/latest/download/macosX64.kexe -o wirespec
chmod +x wirespec
sudo mv ./wirespec /usr/local/bin/wirespec
```

#### macOS Arm
```
curl -L https://github.com/flock-community/wirespec/releases/latest/download/macosArm64.kexe -o wirespec
```

```
chmod +x wirespec
sudo mv ./wirespec /usr/local/bin/wirespec
```

## Maven

## Maven Plugin
Example how to use the maven plugin
For a full example click [here](examples/spring-boot-maven-plugin)
It is also possible to create your custom emitter and run with the plugin[here](examples/spring-boot-custom-maven-plugin)
Expand Down Expand Up @@ -127,7 +207,7 @@ It is also possible to create your custom emitter and run with the plugin[here](
</project>
```

## Gradle
## Gradle Plugin
Example how to use the gradle plugin
For a full example click [here](examples/spring-boot-gradle-plugin)
```kotlin
Expand Down
Binary file added images/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading