Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jenky committed Feb 1, 2024
1 parent 42edc61 commit b0c8469
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/advanced/index.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
label: Digging Deeper
icon: diamond
icon: north-star
5 changes: 5 additions & 0 deletions docs/advanced/middleware.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
order: 500
icon: mirror
---

Middleware provide a convenient mechanism for inspecting and modifying HTTP requests before sending.

Additional middleware can be written to perform a variety of tasks. For example, a logging middleware might log all outgoing requests and responses.
Expand Down
1 change: 1 addition & 0 deletions docs/advanced/response-decoder.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
label: Response Decoder
icon: git-pull-request
---

HTTP response is a crucial aspect of web development, and it is essential to decode the response body to extract the necessary information. However, the response body is typically returned in a string format as JSON or XML, which can be challenging to work with. This is where a response decoder comes in handy. A response decoder can convert the HTTP response body from a string format to a more manageable format, such as an array. This conversion enables developers to extract the relevant information from the response quickly.
Expand Down
1 change: 1 addition & 0 deletions docs/advanced/retrying-requests.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
label: Retrying Requests
icon: arrow-switch
---

Sometimes you may deal with APIs that fail frequently because of network issues or temporary server errors. Fansipan has a useful built-in feature that allows you to send a request and retry multiple times.
Expand Down
15 changes: 15 additions & 0 deletions docs/advanced/sdk.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
label: SDK
icon: pulse
---

![](../static/sdk-hero.png)
Expand Down Expand Up @@ -204,3 +205,17 @@ $repos = $github->org('github')->repos();

$docs = $github->org('github')->repo('docs');
```

## SDK Generator

[Mist](https://github.com/phanxipang/mist) is a generation tool designed to automate the generation of SDKs based on the OpenAPI specification (OAS).

[!ref icon="cloud" target="blank" text="Mist"](https://github.com/phanxipang/mist)

The tool assists in generating code that establishes the basic foundation for interacting with an API based on the OpenAPI specification. This includes generating connector methods, request stubs, data models, and handling basic request/response functionality. However, it may not cover all possible use cases or provide all the advanced features required for a fully functional SDK.

It's important to note that while the Mist provides a starting point, developers will still need to review and modify the generated code according to their project's requirements, coding standards, and best practices. This customization process ensures that the SDK aligns with the specific needs of the application and the API being integrated.

!!!
As the tool is in the early alpha stage, it's essential to carefully evaluate its generated code and thoroughly test it to ensure it meets the desired functionality and quality standards before using it in a production environment.
!!!
4 changes: 4 additions & 0 deletions docs/advanced/testing.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
icon: beaker
---

When testing HTTP clients, it is often necessary to simulate specific scenarios such as returning a successful response, returning an error, or returning specific responses in a certain order. However, hitting an actual remote API is not a good idea for unit tests as they need to be predictable, easy to bootstrap, and fast. This is because it can make your test run slower, waste rate limiting and even result in getting blocked by remote API.

Thanks to the [PSR-18 Client](https://www.php-fig.org/psr/psr-18/) and Fansipan being client agnostic, testing has become much easier. You can now simply replace the underlying client with a mock client, eliminating the need to hit an actual remote API. Fansipan provides a dedicated mock client for testing purposes, and you can find the full document on [Fansipan Mock Client](https://github.com/phanxipang/mock-client).
Expand Down
1 change: 1 addition & 0 deletions docs/basic/connectors.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
order: 500
icon: plug
---

From the [Quick start](../getting-started/quickstart.md#creating-request) guide, you have learned how to send a request without defining an HTTP client. However in real world use cases, typically you need to customize your HTTP client with options such as custom authorization header, timeout, etc...
Expand Down
1 change: 1 addition & 0 deletions docs/basic/requests.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
order: 400
icon: telescope
---

Requests are classes that store all the information required to make a request. Within a request, you can define the HTTP Method (GET, POST, etc.) and the endpoint that you would like to make a request. You can also define default headers and query parameters. Traditionally, you would write your HTTP requests each time you need to, but this way, you can write a request class once and use it multiple times in your application.
Expand Down
1 change: 1 addition & 0 deletions docs/basic/responses.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
order: 300
icon: trophy
---

All requests will return an instance of `Fansipan\Response`, which is a wrapper of `Psr\Http\Message\ResponseInterface` that provides a variety of convenience methods to inspect the response:
Expand Down
1 change: 1 addition & 0 deletions docs/getting-started/installation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
order: 90
icon: package-dependencies
---

You can install the package via composer:
Expand Down
3 changes: 2 additions & 1 deletion docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
order: 80
icon: zap
---

In this quickstart, we'll guide you through the most important functionalities of the package and how to use them.

First, you should [install the package](./installation.md).
[!ref](./installation.md)

## Create a Connector

Expand Down
1 change: 1 addition & 0 deletions docs/getting-started/requirements.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
order: 100
icon: checklist
---

This package requires:
Expand Down
2 changes: 1 addition & 1 deletion docs/retype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ url: phanxipang.github.io/fansipan

branding:
title: Fansipan
label: 1.0-RC
label: 1.0

edit:
repo: https://github.com/phanxipang/fansipan
Expand Down

0 comments on commit b0c8469

Please sign in to comment.