31 lines
637 B
Go
31 lines
637 B
Go
package restapi
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/getkin/kin-openapi/openapi3"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPublicOpenAPISpecValidates(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
_, thisFile, _, ok := runtime.Caller(0)
|
|
require.True(t, ok)
|
|
|
|
specPath := filepath.Join(filepath.Dir(thisFile), "..", "..", "openapi.yaml")
|
|
ctx := context.Background()
|
|
|
|
loader := openapi3.NewLoader()
|
|
doc, err := loader.LoadFromFile(specPath)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, doc)
|
|
require.NotNil(t, doc.Info)
|
|
require.Equal(t, "v1", doc.Info.Version)
|
|
|
|
require.NoError(t, doc.Validate(ctx))
|
|
}
|