diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..55cc393 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @speakeasy-api/speakeasy-maintainers \ No newline at end of file diff --git a/.github/assets/speakeasy.png b/.github/assets/speakeasy.png new file mode 100644 index 0000000..4d6566f Binary files /dev/null and b/.github/assets/speakeasy.png differ diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..16b2b2c --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,33 @@ +name: Test + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test-and-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23" + + - name: Install dependencies + run: go mod download + + - name: Run golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + + - name: Run tests + run: go test -v ./... + + - name: Build + run: go build -v ./... diff --git a/README.md b/README.md index 59c4b9f..81f4af3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,59 @@ -# github.com/speakeasy-api/openapi +[![https://www.speakeasy.com](.github/assets/speakeasy.png?raw=true)](https://www.speakeasy.com) + +# [github.com/speakeasy-api/openapi](https://github.com/speakeasy-api/openapi) + +[![Reference](https://godoc.org/github.com/speakeasy-api/openapi?status.svg)](http://godoc.org/github.com/speakeasy-api/openapi) +[![Test](https://github.com/speakeasy-api/openapi/actions/workflows/test.yaml/badge.svg)](https://github.com/speakeasy-api/openapi/actions/workflows/test.yaml) +[![GoReportCard](https://goreportcard.com/badge/github.com/speakeasy-api/openapi)](https://goreportcard.com/report/github.com/speakeasy-api/openapi) +[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) The Speakeasy OpenAPI module provides a set of packages and tools for working with OpenAPI Specification documents. +Used directly in Speakeasy's products it powers our [SDK Generator](https://www.speakeasy.com/docs/create-client-sdks) and [Contract Testing](https://www.speakeasy.com/docs/testing) tools. + Documentation for the packages can be found in the [GoDoc documentation.](https://pkg.go.dev/github.com/speakeasy-api/openapi) ## Main Packages ### [arazzo](./arazzo) -The `arazzo` package provides an API for working with Arazzo documents including reading, creating, mutating, walking and validating them. \ No newline at end of file +The `arazzo` package provides an API for working with Arazzo documents including reading, creating, mutating, walking and validating them. + +## Sub Packages + +This repository also contains a number of sub packages that are used by the main packages to provide the required functionality. The below packages may be moved into their own repository in the future, depending on future needs. + +### [json](./json) + +The `json` package provides utilities for converting between JSON and YAML. + +### [jsonpointer](./jsonpointer) + +The `jsonpointer` package provides an API for working with [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901) compliant JSON Pointers. Providing functionality for validating JSON Pointers, and extracting the target of a JSON Pointer for various Go types and structures. + +### [jsonschema](./jsonschema) + +The `jsonschema` package provides various models for working with the different JSON Schema dialects. + +### [sequencedmap](./sequencedmap) + +The `sequencedmap` package provides a map implementation that maintains the order of keys as they are added. + +## Contributing + +This repository is maintained by Speakeasy, but we welcome and encourage contributions from the community to help improve its capabilities and stability. + +### How to Contribute + +1. **Open Issues**: Found a bug or have a feature suggestion? Open an issue to describe what you'd like to see changed. + +2. **Pull Requests**: We welcome pull requests! If you'd like to contribute code: + - Fork the repository + - Create a new branch for your feature/fix + - Submit a PR with a clear description of the changes and any related issues + +3. **Feedback**: Share your experience using the packages or suggest improvements. + +All contributions, whether they're bug reports, feature requests, or code changes, help make this project better for everyone. + +Please ensure your contributions adhere to our coding standards and include appropriate tests where applicable. diff --git a/arazzo/README.md b/arazzo/README.md index 276c38a..7005bf9 100644 --- a/arazzo/README.md +++ b/arazzo/README.md @@ -1,4 +1,11 @@ -# github.com/speakeasy-api/openapi/arazzo +[![https://www.speakeasy.com](../.github/assets/speakeasy.png?raw=true)](https://www.speakeasy.com) + +# [github.com/speakeasy-api/openapi/arazzo](https://github.com/speakeasy-api/openapi/arazzo) + +[![Reference](https://godoc.org/github.com/speakeasy-api/openapi/arazzo?status.svg)](http://godoc.org/github.com/speakeasy-api/openapi/arazzo) +[![Test](https://github.com/speakeasy-api/openapi/actions/workflows/test.yaml/badge.svg)](https://github.com/speakeasy-api/openapi/actions/workflows/test.yaml) +[![GoReportCard](https://goreportcard.com/badge/github.com/speakeasy-api/openapi)](https://goreportcard.com/report/github.com/speakeasy-api/openapi) +[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) The Arazzo package provides an API for working with Arazzo documents including reading, creating, mutating, walking and validating them. @@ -199,3 +206,22 @@ func main() { } } ``` + +## Contributing + +This repository is maintained by Speakeasy, but we welcome and encourage contributions from the community to help improve its capabilities and stability. + +### How to Contribute + +1. **Open Issues**: Found a bug or have a feature suggestion? Open an issue to describe what you'd like to see changed. + +2. **Pull Requests**: We welcome pull requests! If you'd like to contribute code: + - Fork the repository + - Create a new branch for your feature/fix + - Submit a PR with a clear description of the changes and any related issues + +3. **Feedback**: Share your experience using the packages or suggest improvements. + +All contributions, whether they're bug reports, feature requests, or code changes, help make this project better for everyone. + +Please ensure your contributions adhere to our coding standards and include appropriate tests where applicable. diff --git a/arazzo/expression/expression.go b/arazzo/expression/expression.go index 8fa348d..44082fe 100644 --- a/arazzo/expression/expression.go +++ b/arazzo/expression/expression.go @@ -229,7 +229,7 @@ func getType(expression string) ([]string, ExpressionType) { return expressionParts, typ } -// TODO the spec is currently ambiguous on how to handle any additional dot seperated parts after the name so just treat as a name for now +// TODO the spec is currently ambiguous on how to handle any additional dot separated parts after the name so just treat as a name for now // TODO there is probably something required to handle dots within a key name func validateName(expression, name, referenceType string) error { parts := strings.Split(name, ".") diff --git a/errors/errors.go b/errors/errors.go index 308ce66..40ea525 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -7,8 +7,8 @@ import ( "strings" ) -// ErrSeperator is used to seperate the message from the cause in the error message -const ErrSeperator = " -- " +// ErrSeparator is used to separate the message from the cause in the error message +const ErrSeparator = " -- " // Error provides a string based error type allowing the definition of const errors in packages type Error string @@ -17,12 +17,12 @@ func (s Error) Error() string { return string(s) } -// Is checks if targer error is equivelant to Error +// Is checks if target error is equivalent to Error func (s Error) Is(target error) bool { - return s.Error() == target.Error() || strings.HasPrefix(target.Error(), s.Error()+ErrSeperator) + return s.Error() == target.Error() || strings.HasPrefix(target.Error(), s.Error()+ErrSeparator) } -// As will set target errors value to equal Error if they are equivelant +// As will set target errors value to equal Error if they are equivalent func (s Error) As(target interface{}) bool { v := reflect.ValueOf(target).Elem() if v.Type().Name() == "Error" && v.CanSet() { @@ -44,7 +44,7 @@ type wrappedError struct { func (w wrappedError) Error() string { if w.cause != nil { - return fmt.Sprintf("%s%s%v", w.msg, ErrSeperator, w.cause) + return fmt.Sprintf("%s%s%v", w.msg, ErrSeparator, w.cause) } return w.msg } @@ -63,12 +63,12 @@ func (w wrappedError) Unwrap() error { // The below are just wrappers as we are stealing the namespace of the errors package -// Is checks if err is equivelant to target +// Is checks if err is equivalent to target func Is(err error, target error) bool { return errors.Is(err, target) } -// As will set target errors value to equal Error if they are equivelant +// As will set target errors value to equal Error if they are equivalent func As(err error, target any) bool { return errors.As(err, target) }