Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonrichardson/betwixt
Documenting endpoints via testing...
https://github.com/simonrichardson/betwixt
documentation markdown meshuggah plaintext testing
Last synced: 22 days ago
JSON representation
Documenting endpoints via testing...
- Host: GitHub
- URL: https://github.com/simonrichardson/betwixt
- Owner: SimonRichardson
- License: mit
- Created: 2017-06-12T09:19:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-01T16:23:16.000Z (almost 7 years ago)
- Last Synced: 2024-06-20T03:30:00.131Z (5 months ago)
- Topics: documentation, markdown, meshuggah, plaintext, testing
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# betwixt
Betwixt is a documentation tool to help API integration with external sources,
whilst development is ongoing. By placing the betwixt middleware between serving
API and clients it's possible to use integration API tests to output up to date
documentation for all.This middleware is not router aligned so it integrates best with the standard
library, otherwise adapters can be created for usage with external routers.## Output
Betwixt comes with three output formats; plaintext, markdown and Apiary
flavoured markdown. Alternative outputs can be easily added if required (json,
xml etc).### Plaintext
To create plaintext output middleware:
```go
handler := http.DefaultServeMux
handler.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("content-type", "application/json")
bytes, _ := json.Marshal(map[string]string{
"hello": "world",
})
w.WriteHeader(http.StatusOK)
w.Write(bytes)
})var buffer bytes.Buffer
outputs := []betwixt.Output{
output.NewPlaintext(output.MakeWriter(&buffer)),
}
capture := betwixt.New(handler, outputs)
server := httptest.NewServer(capture)...
if err := capture.Output(); err != nil {
log.Fatal(err)
}fmt.Println(buffer.String())
```Example output for plaintext:
```
Output:
GET 200 - /hello
- Parameters:
・ possible 2 (optional)
・ random 2 (optional)
- Request Headers:
・ Accept-Encoding gzip
・ User-Agent Go-http-client/1.1
・ Header Value (optional)
- Response Headers:
・ Content-Type application/json
- Response Body:{"hello":"world"}
```