Bumps [github.com/go-openapi/swag](https://github.com/go-openapi/swag) from 0.23.1 to 0.24.1. - [Commits](https://github.com/go-openapi/swag/compare/v0.23.1...v0.24.1) --- updated-dependencies: - dependency-name: github.com/go-openapi/swag dependency-version: 0.24.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
22 lines
529 B
Go
22 lines
529 B
Go
package loading
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"path/filepath"
|
|
)
|
|
|
|
// JSONMatcher matches json for a file loader.
|
|
func JSONMatcher(path string) bool {
|
|
ext := filepath.Ext(path)
|
|
return ext == ".json" || ext == ".jsn" || ext == ".jso"
|
|
}
|
|
|
|
// JSONDoc loads a json document from either a file or a remote url.
|
|
func JSONDoc(path string, opts ...Option) (json.RawMessage, error) {
|
|
data, err := LoadFromFileOrHTTP(path, opts...)
|
|
if err != nil {
|
|
return nil, errors.Join(err, ErrLoader)
|
|
}
|
|
return json.RawMessage(data), nil
|
|
}
|