Skip to content

Commit

Permalink
fix : error response
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Sep 3, 2023
1 parent 5d3c677 commit fe7eb5d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions parse_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ func (o *OpenAPI) Pass() string {
return o.pass
}

func (o *OpenAPI) Parse(ctx context.Context) []Path {
func (o *OpenAPI) Parse(ctx context.Context) ([]Path, error) {
doc, err := openapi3.NewLoader().LoadFromFile(o.Pass())
if err != nil {
fmt.Println(err)
return nil, fmt.Errorf("failed to load openapi.yaml: %w", err)
}

var paths []Path
Expand All @@ -40,9 +40,7 @@ func (o *OpenAPI) Parse(ctx context.Context) []Path {
var bodys []*openapi3.SchemaRef

if opr.Parameters != nil {
for _, param := range opr.Parameters {
params = append(params, param)
}
params = append(params, opr.Parameters...)
}

if opr.RequestBody != nil {
Expand All @@ -66,5 +64,5 @@ func (o *OpenAPI) Parse(ctx context.Context) []Path {
paths = append(paths, path)

}
return paths
return paths, nil
}

0 comments on commit fe7eb5d

Please sign in to comment.