Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Sep 8, 2023
1 parent e1b69a4 commit 7f1dbd5
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

- Rest API
- [List stubs](api-stubs-list)
- [List unused stubs](api-unused-stubs-list)
- [Add stub](api-stubs-add)
- [Delete stub](api-stubs-delete)
- [Search stub](api-stubs-search)
Expand Down
11 changes: 10 additions & 1 deletion docs/api-stubs-delete.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Rest API. Stubs Delete

!> The delete functionality is under development. It is planned to be implemented in the near future.
Stubs Delete — endpoint removes stub by ID.

Enough to knock on the handle `DELETE /api/stubs/{uuid}`:
```bash
curl -X DELETE http://127.0.0.1:4771/api/stubs/6c85b0fa-caaf-4640-a672-f56b7dd8074d
```

The endpoint will respond with code 204, the stub has been removed.

It worked!
31 changes: 30 additions & 1 deletion docs/api-stubs-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,36 @@ Enough to knock on the handle POST /api/stubs/search:

Response:
```json
["6c85b0fa-caaf-4640-a672-f56b7dd8074d"]
{
"data":{
"message": "World",
"return_code": 0
},
"error": ""
}
```

## Find by ID

Enough to knock on the handle `POST /api/stubs/search`:
```bash
curl -X POST -d '{ \
"id": "6c85b0fa-caaf-4640-a672-f56b7dd8074d", \
"service": "Gripmock", \
"method": "SayHello", \
"data":{} \
}' http://127.0.0.1:4771/api/stubs/search
```

Response:
```json
{
"data":{
"message": "World",
"return_code": 0
},
"error": ""
}
```

## Input Matching
Expand Down
77 changes: 77 additions & 0 deletions docs/api-unused-stubs-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
## Rest API. Stubs Unused List

Stubs Unused List — endpoint returns a list of unused stubs (all stubs that were not accessed through search).
A very useful method that helps find dead stubs in the code.

Let's imagine that our contract `simple.proto` looks something like this:
```protobuf
syntax = "proto3";
option go_package = "github.com/bavix/gripmock/protogen/example/simple";
package simple;
service Gripmock {
rpc SayHello (Request) returns (Reply);
}
message Request {
string name = 1;
}
message Reply {
string message = 1;
int32 return_code = 2;
}
```

Enough to knock on the handle `GET /api/stubs/unused`:
```bash
curl http://127.0.0.1:4771/api/stubs/unused
```

Response:
```json
[
{
"id": "6c85b0fa-caaf-4640-a672-f56b7dd8074d",
"service": "Gripmock",
"method": "SayHello",
"input": {
"equals": {
"name": "gripmock"
},
"contains": null,
"matches": null
},
"output": {
"data": {
"message": "Hello GripMock",
"return_code": 42
},
"error": ""
}
}
]
```

Find stub by ID. Enough to knock on the handle `POST /api/stubs/search`:
```bash
curl -X POST -d '{ \
"id": "6c85b0fa-caaf-4640-a672-f56b7dd8074d", \
"service": "Gripmock", \
"method": "SayHello", \
"data":{} \
}' http://127.0.0.1:4771/api/stubs/search
```

Now the stub is marked as used. Let's try to get a list of unused stubs.
```bash
curl http://127.0.0.1:4771/api/stubs/unused
```

Response:
```json
[]
```

It worked!
4 changes: 2 additions & 2 deletions docs/static-stubs-benefits-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ You can read more details here: https://github.com/goccy/go-yaml#2-reference-ele
input:
equals:
name: tokopedia
traceID: &traceID 0ad1348f1403169275002100356696
code: &code 0ad1348f1403169275002100356696
output:
data: &result
message: Hello Tokopedia
Expand All @@ -87,7 +87,7 @@ You can read more details here: https://github.com/goccy/go-yaml#2-reference-ele
input:
equals:
name: world
traceID: *traceID
code: *code
output:
data: *result
```
Expand Down

0 comments on commit 7f1dbd5

Please sign in to comment.