Skip to content

Commit

Permalink
Layout Refactor and Add gherkin tool (#3)
Browse files Browse the repository at this point in the history
* 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
jbsmith7741 authored Feb 5, 2024
1 parent 2fd253b commit b46f484
Show file tree
Hide file tree
Showing 19 changed files with 2,870 additions and 749 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.18.x, 1.19.x]
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
go-version: 1.21.x
- name: Checkout code
uses: actions/checkout@v2
- name: Test
Expand Down
17 changes: 3 additions & 14 deletions .gitignore
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
45 changes: 45 additions & 0 deletions README.md
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">
Loading

0 comments on commit b46f484

Please sign in to comment.