From 88b9075bdadfccf8a51853907fb0e12f13850630 Mon Sep 17 00:00:00 2001 From: Reuven Harrison Date: Thu, 7 Dec 2023 13:57:28 +0200 Subject: [PATCH] diff-add-exclude-elements-options (#454) --- .github/workflows/go.yml | 4 ++-- Dockerfile | 2 +- OASDIFF-SERVICE.md | 36 ++++++++++++++++++++++++++++++++++++ README.md | 5 ++--- go.mod | 4 ++-- go.sum | 4 ++-- internal/diff.go | 2 +- 7 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 OASDIFF-SERVICE.md diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d63f9811..381e7d26 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: true matrix: - go: ['1.21.4'] + go: ['1.21.5'] os: - ubuntu-latest - windows-latest @@ -71,7 +71,7 @@ jobs: name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.52.2 + version: v1.55 - id: govulncheck uses: golang/govulncheck-action@v1 diff --git a/Dockerfile b/Dockerfile index 86d18a4b..947b2efa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ### Go get dependecies and build ### -FROM golang:1.21.4 as builder +FROM golang:1.21.5 as builder ENV PLATFORM docker WORKDIR /go/src/app COPY go.mod go.sum ./ diff --git a/OASDIFF-SERVICE.md b/OASDIFF-SERVICE.md new file mode 100644 index 00000000..6545a4c6 --- /dev/null +++ b/OASDIFF-SERVICE.md @@ -0,0 +1,36 @@ +# oasdiff-service + +### Creating a tenant +Create a tenant and get a tenant ID: +``` +curl -d '{"tenant": "my-company", "email": "james@my-company.com"}' https://register.oasdiff.com/tenants +``` +You will get a response with your tenant ID: +``` +{"id": "2ahh9d6a-2221-41d7-bbc5-a950958345"} +``` +### Run diff +``` +curl -X POST \ + -F base=@data/openapi-test1.yaml \ + -F revision=@data/openapi-test3.yaml \ + http://api.oasdiff.com/tenants/{tenant-id}/diff +``` + +### Run breaking-changes +``` +curl -X POST \ + -F base=@data/openapi-test1.yaml \ + -F revision=@data/openapi-test3.yaml \ + https://api.oasdiff.com/tenants/{tenant-id}/breaking-changes +``` + +### Run changelog +``` +curl -X POST \ + -F base=@data/openapi-test1.yaml \ + -F revision=@data/openapi-test3.yaml \ + https://api.oasdiff.com/tenants/{tenant-id}/changelog +``` +### Errors +oasdiff-service uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate a failure with additional information provided (e.g., invalid OpenAPI spec format, a required parameter was missing, etc.). Codes in the 5xx range indicate an error with oasdiff-service servers (these are rare) diff --git a/README.md b/README.md index 142e18ef..d883c9a7 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Copy binaries from [latest release](https://github.com/Tufin/oasdiff/releases/) ## Wrappers - [GitHub Action](https://github.com/oasdiff/oasdiff-action) -- [Cloud Service](#openapi-diff-and-breaking-changes-as-a-service) +- [Cloud Service](#openapi-diff-breaking-changes-and-changelog-as-a-service) - [OpenAPI Sync: Get notified when an API provider breaks the API](https://github.com/oasdiff/sync/) ## Usage Examples @@ -163,8 +163,7 @@ Replace `$(pwd)/data` by the path that contains your files. Note that the spec paths must begin with `/`. ## OpenAPI Diff, Breaking Changes and Changelog as a Service -Oasdiff is also available a service. -See: https://github.com/oasdiff/oasdiff-service +[Oasdiff is also available as a service](OASDIFF-SERVICE.md). ## Diff Output Formats The default diff output format, YAML, provides a full view of all diff details. diff --git a/go.mod b/go.mod index 2c47945b..dbbba7fb 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tufin/oasdiff -go 1.21.4 +go 1.21.5 require ( cloud.google.com/go v0.111.0 @@ -11,7 +11,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/yargevad/filepathx v1.0.0 github.com/yuin/goldmark v1.6.0 - golang.org/x/exp v0.0.0-20231127185646-65229373498e + golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index d5647448..a4c12703 100644 --- a/go.sum +++ b/go.sum @@ -61,8 +61,8 @@ github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5 github.com/yargevad/filepathx v1.0.0/go.mod h1:BprfX/gpYNJHJfc35GjRRpVcwWXS89gGulUIU5tK3tA= github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68= github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/exp v0.0.0-20231127185646-65229373498e h1:Gvh4YaCaXNs6dKTlfgismwWZKyjVZXwOPfIyUaqU3No= -golang.org/x/exp v0.0.0-20231127185646-65229373498e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= +golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/internal/diff.go b/internal/diff.go index 618fcf28..c31c808f 100644 --- a/internal/diff.go +++ b/internal/diff.go @@ -26,7 +26,7 @@ func getDiffCmd() *cobra.Command { cmd.PersistentFlags().BoolVarP(&flags.composed, "composed", "c", false, "work in 'composed' mode, compare paths in all specs matching base and revision globs") enumWithOptions(&cmd, newEnumValue(formatters.SupportedFormatsByContentType(formatters.OutputDiff), string(formatters.FormatYAML), &flags.format), "format", "f", "output format") - cmd.PersistentFlags().VarP(newEnumSliceValue(diff.ExcludeDiffOptions, nil, &flags.excludeElements), "exclude-elements", "e", "comma-separated list of elements to exclude") + enumWithOptions(&cmd, newEnumSliceValue(diff.ExcludeDiffOptions, nil, &flags.excludeElements), "exclude-elements", "e", "comma-separated list of elements to exclude") cmd.PersistentFlags().StringVarP(&flags.matchPath, "match-path", "p", "", "include only paths that match this regular expression") cmd.PersistentFlags().StringVarP(&flags.filterExtension, "filter-extension", "", "", "exclude paths and operations with an OpenAPI Extension matching this regular expression") cmd.PersistentFlags().IntVarP(&flags.circularReferenceCounter, "max-circular-dep", "", 5, "maximum allowed number of circular dependencies between objects in OpenAPI specs")