Skip to content

Commit

Permalink
feat : parse openapi paths
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Aug 11, 2023
1 parent f1f9666 commit 6c5f353
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions parse_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ func (o *OpenAPI) Pass() string {
return o.pass
}

func (o *OpenAPI) Parse(ctx context.Context) {
func (o *OpenAPI) Parse(ctx context.Context) []Path {
doc, err := openapi3.NewLoader().LoadFromFile(o.Pass())
if err != nil {
fmt.Println(err)
}

var paths []Path

_ = doc.Validate(ctx)
for _, pathItem := range doc.Paths.InMatchingOrder() {
oprs := doc.Paths.Find(pathItem).Operations()

var paths []Method
var mtds []Method

for mtd, opr := range oprs {
var params openapi3.Parameters
Expand All @@ -54,7 +56,15 @@ func (o *OpenAPI) Parse(ctx context.Context) {
params: params,
bodys: bodys,
}
paths = append(paths, path)
mtds = append(mtds, path)
}

path := Path{
path: pathItem,
method: mtds,
}
paths = append(paths, path)

}
return paths
}

0 comments on commit 6c5f353

Please sign in to comment.