-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters