Skip to content

Add Getting Started guides to setup pages and new Testing section#7

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/enhance-setup-pages-and-testing
Draft

Add Getting Started guides to setup pages and new Testing section#7
Copilot wants to merge 3 commits intomasterfrom
copilot/enhance-setup-pages-and-testing

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Setup pages previously only listed package dependencies. This adds comprehensive Getting Started guides showing how to actually use TypedRest, plus a new Testing section explaining how to write unit tests for custom endpoint classes.

Changes

Extended Setup Pages

Added step-by-step Getting Started guides to all setup pages:

  • Installation - Package manager commands
  • Entry endpoint creation - Minimal code to connect to an API
  • Client class definition - Pattern for extending EntryEndpoint with resource properties
  • Usage examples - Reading collections, creating elements, accessing individuals
  • Next steps - Links to Introduction, Endpoints, and API docs

Java/Kotlin page uses tabbed syntax for both languages (Maven/Gradle, Java/Kotlin examples).

Before:

## Dependencies
Add one or more of the following NuGet packages...

After:

## Getting started

### 1. Install the dependency
Add the TypedRest NuGet package...

### 2. Create an entry endpoint
var client = new EntryEndpoint(new Uri("https://example.com/api/"));

### 3. Define your client class
class MyClient(Uri uri) : EntryEndpoint(uri)
{
    public CollectionEndpoint<Contact> Contacts => new(this, "./contacts");
}
...

New Testing Section

Created docs/testing/index.md with:

  • General testing approach (mock HTTP layer, create entry endpoint, instantiate child endpoint, assert)
  • Test infrastructure patterns for C#, Java, Kotlin, TypeScript (tabbed)
  • Complete examples testing ElementEndpoint.read()
  • Complete examples testing custom endpoint classes
  • Links to implementation test suites

Navigation

  • Updated docs/.pages to include testing section after setup
  • Updated docs/index.md to add Testing link in documentation list

Screenshots

Homepage with new Testing section:
Homepage

Testing page with tabbed examples:
Testing

Setup page with Getting Started guide:
Java Setup

Original prompt

Overview

The documentation needs two enhancements:

  1. Extend the Setup pages with more comprehensive "Getting started" guides
  2. Add a new "Testing" section to the documentation

Part 1: Extend Setup Pages

The existing setup pages (docs/setup/dotnet.md, docs/setup/java.md, docs/setup/typescript.md) are currently very bare-bones, only listing package dependencies. Each should be extended with a concise "Getting started" guide that shows the essential steps to begin using TypedRest. Keep the content focused and essential. Prefer linking to existing documentation (like the Introduction, Endpoints, Entry Endpoint, etc.) over duplicating content.

For each platform, add a "Getting started" section that covers:

  1. Install the dependency (keep existing dependency info)
  2. Create an entry endpoint — show the minimal code to create an EntryEndpoint pointing at an API
  3. Define your client class — show a short example of extending EntryEndpoint and exposing a collection endpoint via a property/method (as shown in the Introduction)
  4. Use the client — show basic usage: reading a collection, creating an element, reading an individual element
  5. Next steps — link to the Introduction for the full conceptual walkthrough, Endpoints for all available endpoint types, and the platform's API documentation

Platform-specific notes:

C#/.NET (docs/setup/dotnet.md):

  • The main package is TypedRest from NuGet
  • EntryEndpoint takes a Uri
  • Uses async/await pattern
  • Keep the existing Dependency Injection section
  • Keep existing "See also" section

Java (docs/setup/java.md):

  • The main package is typedrest from Maven Central
  • EntryEndpoint takes a URI
  • Synchronous API
  • The Impl suffix is used for implementation classes (e.g., CollectionEndpointImpl)
  • Show both Java and Kotlin examples using the === "Java" / === "Kotlin" tab syntax that the docs already use (see docs/introduction.md for examples)
  • Keep existing "See also" section

TypeScript (docs/setup/typescript.md):

  • The package is typedrest from NPM
  • EntryEndpoint takes a URL
  • Uses async/await pattern
  • Keep existing "See also" section

Part 2: Add Testing Section

Create a new docs/testing/ directory with an index.md file that explains how to write unit tests for custom endpoint classes built with TypedRest.

Testing patterns from the actual implementations:

C#/.NET (from TypedRest/TypedRest-DotNet):

  • Uses xUnit with [Fact] attributes
  • Uses an EndpointTestBase abstract class that provides a MockHttpMessageHandler (from the RichardSzalay.MockHttp package) and an EntryEndpoint wired to it
  • The MockHttpMessageHandler is used to set up expected HTTP requests and responses: Mock.Expect(HttpMethod.Get, "http://localhost/endpoint").Respond(JsonMime, """{"id":5,"name":"test"}""");
  • Uses FluentAssertions for assertions
  • Tests verify that endpoints send the correct HTTP requests and deserialize responses correctly
  • EndpointTestBase disposes the mock and verifies no outstanding expectations
  • Key file: src/UnitTests/Endpoints/EndpointTestBase.cs:
public abstract class EndpointTestBase : IDisposable
{
    public const string JsonMime = "application/json";
    protected readonly MockHttpMessageHandler Mock = new();
    protected readonly IEndpoint EntryEndpoint;
    protected EndpointTestBase(MediaTypeFormatter? serializer = null)
    {
        EntryEndpoint = new MockEntryEndpoint(Mock, serializer);
    }
    public void Dispose() => Mock.VerifyNoOutstandingExpectation();
    private class MockEntryEndpoint(HttpMessageHandler messageHandler, MediaTypeFormatter? serializer)
        : EntryEndpoint(new HttpClient(messageHandler), new Uri("http://localhost/"), serializer);
}

Java/Kotlin (from TypedRest/TypedRest-Java):

  • Uses Kotlin Test with @Test annotation
  • Uses an AbstractEndpointTest abstract class that provides a MockWebServer (from OkHttp) and an EntryEndpoint wired to it
  • The MockWebServer queues mock responses: server.enqueue(MockResponse().setJsonBody("""{"id":5,"name":"test"}"""))
  • After invoking the endpoint, assertions verify the recorded request: server.assertRequest(HttpMethod.GET) and .withJsonBody(...), .withHeader(...)
  • Key file: typedrest/src/test/kotlin/net/typedrest/endpoints/AbstractEndpointTest.kt:
abstract class AbstractEndpointTest {
    protected var server: MockWebServer = MockWebServer()
    protected var entryEndpoint: EntryEndpoint = EntryEndpoint(server.url("/").toUri())
    @AfterTest
    fun after() = server.close()
}
  • Helper extensions are in typedrest/src/test/kotlin/net/typedrest/tests/MockWebServerExtensions.kt providing setJsonBody, assertRequest, withJsonBody, withHeader

TypeScript (from `TypedRest/TypedRest-Typ...

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 17, 2026 17:20
Co-authored-by: bastianeicher <414366+bastianeicher@users.noreply.github.com>
Co-authored-by: bastianeicher <414366+bastianeicher@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance documentation with getting started guides and testing section Add Getting Started guides to setup pages and new Testing section Feb 17, 2026
Copilot AI requested a review from bastianeicher February 17, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants