This tool is under active development and must be considered alpha. It's API may be changed in a breaking way until a 1.0 version is released. Submit issues to the Github issue tracker if found.
go-spectral is a Go wrapper for stoplightio/spectral using the pure Go
ECMAScript 5.1 implementation Goja with Node support
using goja_nodejs. The additional Node system calls are translated (roughly) to
either no-op's (if the function during preliminary testing was not used) or the respective Go SDK methods.
$ go get github.com/Emptyless/go-spectral@latest
package main
import (
"fmt"
"github.com/Emptyless/go-spectral"
)
func main() {
output, err := gospectral.Lint([]string{"./openapi.yaml"}, "./.spectral.yaml")
if err != nil {
panic(err)
}
fmt.Println(output)
}To customise the behavior of Lint, additional options can be supplied:
WithWorkingDirectory: sets the working directory used to load system files (e.g. .spectral.yaml)WithFS: sets theConfig.FSto load documents and rulesets from. This can be useful when using e.g.embed.FSas a means to bundle specs/rulesets.WithDist: sets theConfig.Distto a custom supplied value. This can be useful for using a specific version of the source and/or bundling it on your own.WithScript: sets theConfig.Scriptto a custom valueWithBeforeModule: is evaluated before any module is enabled and can be used to change e.g. the Loader. If a non-nilEnable.Fnis returned, it is used instead of the provided EnableWithAfterModule: is evaluated after any module is enabled and can be used to change the current runtime state
- get basic structure of the wrapper working
- add tests
- stoplightio/spectral: JSON/YAML linter with support for OpenAPI
- dop251/goja: Go ECMAScript 5.1 Implementation
- dop251/goja_nodejs: Goja implementations of NodeJS packages
See ./NOTICE for the NOTICE as produced by the webpack-license-plugin for dist/built.js