Skip to content

Commit

Permalink
feat: openapi3: add ReadSchemaFile()
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Oct 20, 2022
1 parent f0cc311 commit 6109af6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions openapi3/schemas.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package openapi3

import (
"os"
"strings"

oas3 "github.com/getkin/kin-openapi/openapi3"
"github.com/grokify/mogo/encoding/jsonutil"
)

Expand All @@ -21,3 +23,13 @@ func SchemaPointerExpand(prefix, schemaName string) string {
}
return pointer
}

func ReadSchemaFile(filename string) (*oas3.Schema, error) {
data, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
sch := oas3.NewSchema()
err = sch.UnmarshalJSON(data)
return sch, err
}

0 comments on commit 6109af6

Please sign in to comment.