Skip to content
Draft
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
1 change: 1 addition & 0 deletions docs/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ nav:
- index.md
- introduction.md
- setup
- testing
- endpoints
- serializers
- link-handling
Expand Down
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ TypedRest helps you build type-safe, fluent-style REST API clients. Common REST
[Setup](setup/index.md)
: How do I use TypedRest in my projects?

[Testing](testing/index.md)
: How to write unit tests for your TypedRest endpoint classes.

[Endpoints](endpoints/index.md)
: Documentation for all endpoint types provided by TypedRest.

Expand Down
57 changes: 53 additions & 4 deletions docs/setup/dotnet.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,60 @@
# .NET

## Dependencies
## Getting started

Add one or more of the following NuGet packages to your project:
### 1. Install the dependency

[TypedRest](https://www.nuget.org/packages/TypedRest/)
The main TypedRest library.
Add the [TypedRest](https://www.nuget.org/packages/TypedRest/) NuGet package to your project:

```bash
dotnet add package TypedRest
```

### 2. Create an entry endpoint

Create an `EntryEndpoint` pointing at your API:

```csharp
using TypedRest;

var client = new EntryEndpoint(new Uri("https://example.com/api/"));
```

### 3. Define your client class

Extend `EntryEndpoint` and expose your API's resources as properties:

```csharp
class MyClient(Uri uri) : EntryEndpoint(uri)
{
public CollectionEndpoint<Contact> Contacts => new(this, relativeUri: "./contacts");
}
```

### 4. Use the client

Use your client to interact with the API:

```csharp
var client = new MyClient(new Uri("https://example.com/api/"));

// Read all contacts
List<Contact> contacts = await client.Contacts.ReadAllAsync();

// Create a new contact
ContactEndpoint newContact = await client.Contacts.CreateAsync(new Contact { Name = "Smith" });

// Read a specific contact
Contact contact = await newContact.ReadAsync();
```

### 5. Next steps

- Read the [Introduction](../introduction.md) for the full conceptual walkthrough
- Explore all available [Endpoints](../endpoints/index.md) types
- Check out the [API documentation](https://dotnet.typedrest.net/) for detailed reference

## Additional packages

[TypedRest.Reactive](https://www.nuget.org/packages/TypedRest.Reactive/)
Adds support for streaming with [ReactiveX (Rx)](http://reactivex.io/) to TypedRest.
Expand Down
120 changes: 116 additions & 4 deletions docs/setup/java.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,123 @@
# Java / Kotlin

## Dependencies
## Getting started

Add one or more of the following Maven artifacts to your project:
### 1. Install the dependency

[typedrest](https://central.sonatype.com/artifact/net.typedrest/typedrest)
The main TypedRest library.
Add the [typedrest](https://central.sonatype.com/artifact/net.typedrest/typedrest) Maven artifact to your project.

=== "Maven"

```xml
<dependency>
<groupId>net.typedrest</groupId>
<artifactId>typedrest</artifactId>
<version>VERSION</version>
</dependency>
```

=== "Gradle"

```groovy
implementation 'net.typedrest:typedrest:VERSION'
```

### 2. Create an entry endpoint

Create an `EntryEndpoint` pointing at your API:

=== "Java"

```java
import net.typedrest.EntryEndpoint;
import java.net.URI;

EntryEndpoint client = new EntryEndpoint(URI.create("https://example.com/api/"));
```

=== "Kotlin"

```kotlin
import net.typedrest.EntryEndpoint
import java.net.URI

val client = EntryEndpoint(URI.create("https://example.com/api/"))
```

### 3. Define your client class

Extend `EntryEndpoint` and expose your API's resources as methods or properties:

=== "Java"

```java
import net.typedrest.CollectionEndpoint;
import net.typedrest.CollectionEndpointImpl;

class MyClient extends EntryEndpoint {
public MyClient(URI uri) {
super(uri);
}

public CollectionEndpoint<Contact> getContacts() {
return new CollectionEndpointImpl<>(this, "./contacts", Contact.class);
}
}
```

=== "Kotlin"

```kotlin
import net.typedrest.CollectionEndpoint
import net.typedrest.CollectionEndpointImpl

class MyClient(uri: URI) : EntryEndpoint(uri) {
val contacts: CollectionEndpoint<Contact>
get() = CollectionEndpointImpl(this, "./contacts", Contact::class.java)
}
```

### 4. Use the client

Use your client to interact with the API:

=== "Java"

```java
MyClient client = new MyClient(URI.create("https://example.com/api/"));

// Read all contacts
List<Contact> contacts = client.getContacts().readAll();

// Create a new contact
ElementEndpoint<Contact> newContact = client.getContacts().create(new Contact("Smith"));

// Read a specific contact
Contact contact = newContact.read();
```

=== "Kotlin"

```kotlin
val client = MyClient(URI.create("https://example.com/api/"))

// Read all contacts
val contacts: List<Contact> = client.contacts.readAll()

// Create a new contact
val newContact: ElementEndpoint<Contact> = client.contacts.create(Contact("Smith"))

// Read a specific contact
val contact: Contact = newContact.read()
```

### 5. Next steps

- Read the [Introduction](../introduction.md) for the full conceptual walkthrough
- Explore all available [Endpoints](../endpoints/index.md) types
- Check out the [API documentation](https://java.typedrest.net/) for detailed reference

## Additional packages

[typedrest-reactive](https://central.sonatype.com/artifact/net.typedrest/typedrest-reactive)
Adds support for streaming with [ReactiveX (Rx)](http://reactivex.io/).
Expand Down
57 changes: 54 additions & 3 deletions docs/setup/typescript.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,61 @@
# TypeScript

## Dependencies
## Getting started

Add the `typescript` NPM package to your project:
### 1. Install the dependency

npm install typedrest --save
Add the `typedrest` NPM package to your project:

```bash
npm install typedrest --save
```

### 2. Create an entry endpoint

Create an `EntryEndpoint` pointing at your API:

```typescript
import {EntryEndpoint} from 'typedrest';

const client = new EntryEndpoint(new URL("https://example.com/api/"));
```

### 3. Define your client class

Extend `EntryEndpoint` and expose your API's resources as properties:

```typescript
import {EntryEndpoint, CollectionEndpoint} from 'typedrest';

class MyClient extends EntryEndpoint {
get contacts() {
return new CollectionEndpoint<Contact>(this, "./contacts");
}
}
```

### 4. Use the client

Use your client to interact with the API:

```typescript
const client = new MyClient(new URL("https://example.com/api/"));

// Read all contacts
const contacts: Contact[] = await client.contacts.readAll();

// Create a new contact
const newContact = await client.contacts.create({name: "Smith"});

// Read a specific contact
const contact: Contact = await newContact.read();
```

### 5. Next steps

- Read the [Introduction](../introduction.md) for the full conceptual walkthrough
- Explore all available [Endpoints](../endpoints/index.md) types
- Check out the [API documentation](https://typescript.typedrest.net/) for detailed reference

## See also

Expand Down
Loading