-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Layout Refactor and Add gherkin tool (#3)
* refactor * Add gherkin helper app * add overview image * move unneeded structs * use builder pattern * fix marsheling bugs * work on schema object and parsing * update unit tests * Refactor media/examples - Add title to schema - fix unit tests * addPathParam method * support multiple param types * tests for adding request/response * Added query paths, requests and responses to output * add compile and reorg files * more edge cases * unit tests and fixes for Compile() * Params: Add desc and custom Example * add NamedExample option * generate hashed title for maps * update overview * add go workspace and refactor param calls * modules update * limit support to go 1.20+
- Loading branch information
1 parent
2fd253b
commit b46f484
Showing
19 changed files
with
2,870 additions
and
749 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,15 +1,4 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
*.json | ||
*.toml | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
gherkin |
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,2 +1,47 @@ | ||
# GoOpenAPI | ||
A Go Lang SDK to help create OpenApi 3.0.3 Spec | ||
|
||
[OpenAPI spec](https://swagger.io/specification/) | ||
|
||
[![codecov](https://codecov.io/gh/hydronica/go-openapi/graph/badge.svg?token=E3I51BL34W)](https://codecov.io/gh/hydronica/go-openapi) | ||
|
||
## Getting Started | ||
|
||
``` go | ||
import ( | ||
_ "embed" | ||
|
||
"github.com/hydronica/go-openapi" | ||
) | ||
|
||
// go:embed base.json | ||
var base string | ||
func main() { | ||
|
||
// create doc from base template | ||
doc, err := openapi.NewFromJson(base) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// create doc from scratch | ||
doc = openapi.New("title", "v1.0.0", "all about this API") | ||
|
||
doc.AddRoute( | ||
openapi.NewRoute("/path/v1", "GET"). | ||
AddResponse( | ||
openapi.Resp{Code: 200, Desc:"valid response"}.WithJSONString('{"status":"ok"}' | ||
). | ||
AddRequest( | ||
openapi.Req{MType: "application/json", Desc:"pull data"}. | ||
WithParams(myStruct) | ||
) | ||
) | ||
|
||
// print generated json document | ||
fmt.Println(string(doc.JSON())) | ||
} | ||
``` | ||
|
||
### Overview | ||
<img src="docs/chart.drawio.svg"> |
Oops, something went wrong.