Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-13014 pull upstream changes #5

Merged
merged 37 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f85abf4
Fix #165
Apr 19, 2023
7ee5140
Merge pull request #166 from Aven30/fix-spec-parser-ignoring-response…
casualjim Apr 22, 2023
b123375
Fix `x-order` not working with number value #162
ChandanChainani Mar 6, 2023
832384d
Merge pull request #163 from ChandanChainani/fix/162/x-order_not_work…
casualjim Apr 22, 2023
32e224f
fixed json unmarshal for BoolOrSchema
fredbi Nov 30, 2023
d8ccc36
ci: re-enacted linting
fredbi Nov 30, 2023
0da2f93
chore: updated linting config, relinted
fredbi Nov 30, 2023
2341568
ci: removed deprecated appveyor CI
fredbi Nov 30, 2023
cc27dbe
Merge pull request #170 from fredbi/chore/update-linting
casualjim Dec 1, 2023
ba7eeb1
Merge pull request #169 from fredbi/ci/reenact-linting
casualjim Dec 1, 2023
8b1afa6
Merge pull request #171 from fredbi/vuln/fix-161
casualjim Dec 1, 2023
95bb41d
Merge pull request #168 from fredbi/fix-148
casualjim Dec 1, 2023
d6c58be
updated go version
fredbi Dec 4, 2023
5762ed3
Removed dependency on bindata
fredbi Dec 4, 2023
b250982
Revert fix #146 (#172)
fredbi Dec 4, 2023
56b7b69
Merge pull request #173 from fredbi/chore/update-go-version
youyuanwu Dec 5, 2023
0bd5b7c
Merge pull request #174 from fredbi/chore/adopt-embedfs
youyuanwu Dec 5, 2023
7d71eda
doc: fixed typo in badge link
fredbi Dec 5, 2023
4df02b2
fixed yet another typo with badges
fredbi Dec 5, 2023
94a1c0d
updated dependencies
fredbi Dec 17, 2023
8789dc3
removed pre-go1.19 code
fredbi Dec 17, 2023
ee158df
chore(deps): updated go-openapi deps
fredbi Dec 22, 2023
b445199
fix(ci): muted warnings in CI runs due to cache conflicts
fredbi Dec 25, 2023
ed00e71
fix(expand): parameters & responses should properly follow remote doc…
fredbi Jan 9, 2024
63dcade
doc(faq): transfered questions to README
fredbi Jan 9, 2024
4c02b81
ci(dependencies): automate dependencies updates
fredbi Feb 1, 2024
7e0aabf
Bump the go-openapi-dependencies group with 1 update
dependabot[bot] Feb 1, 2024
5c52f3d
Bump the development-dependencies group with 3 updates
dependabot[bot] Feb 1, 2024
817cb94
chore(ci): prevents duplicate workflow runs
fredbi Feb 1, 2024
c21b34f
Bump the development-dependencies group with 1 update
dependabot[bot] Feb 2, 2024
a68da9e
ci: remove paths-ignore
fredbi Feb 3, 2024
397f81b
Bump the development-dependencies group with 1 update
dependabot[bot] Feb 16, 2024
c786eed
fix(ci): remove dependency-type from dependabot groups
fredbi Mar 4, 2024
fc76ee8
chore(lint): relinted
fredbi Mar 4, 2024
8937a3d
updated dependencies
fredbi Mar 4, 2024
af9bab8
chore(go): go-openapi requires go.1.20 across the board
fredbi Mar 9, 2024
f58cb47
Merge tag 'v0.21.0' into PMM-7-pull-upstream-changes
BupycHuk Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "friday"
open-pull-requests-limit: 2 # <- default is 5
groups: # <- group all github actions updates in a single PR
# 1. development-dependencies are auto-merged
development-dependencies:
patterns:
- '*'

- package-ecosystem: "gomod"
# We define 4 groups of dependencies to regroup update pull requests:
# - development (e.g. test dependencies)
# - go-openapi updates
# - golang.org (e.g. golang.org/x/... packages)
# - other dependencies (direct or indirect)
#
# * All groups are checked once a week and each produce at most 1 PR.
# * All dependabot PRs are auto-approved
#
# Auto-merging policy, when requirements are met:
# 1. development-dependencies are auto-merged
# 2. golang.org-dependencies are auto-merged
# 3. go-openapi patch updates are auto-merged. Minor/major version updates require a manual merge.
# 4. other dependencies require a manual merge
directory: "/"
schedule:
interval: "weekly"
day: "friday"
open-pull-requests-limit: 4
groups:
development-dependencies:
patterns:
- "github.com/stretchr/testify"

golang.org-dependencies:
patterns:
- "golang.org/*"

go-openapi-dependencies:
patterns:
- "github.com/go-openapi/*"

other-dependencies:
exclude-patterns:
- "github.com/go-openapi/*"
- "github.com/stretchr/testify"
- "golang.org/*"
43 changes: 43 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1

- name: Auto-approve all dependabot PRs
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge dependabot PRs for development dependencies
if: contains(steps.metadata.outputs.dependency-group, 'development-dependencies')
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge dependabot PRs for go-openapi patches
if: contains(steps.metadata.outputs.dependency-group, 'go-openapi-dependencies') && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch')
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Auto-merge dependabot PRs for golang.org updates
if: contains(steps.metadata.outputs.dependency-group, 'golang.org-dependencies')
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

53 changes: 44 additions & 9 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,58 @@
name: Go Test
name: go test

on: [push, pull_request]
on:
push:
tags:
- v*
branches:
- master

pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
check-latest: true
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
only-new-issues: true
skip-cache: true

test:

name: Test
name: Unit tests
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
go_version: ['oldstable', 'stable' ]

- uses: actions/setup-go@v2
steps:
- name: Run unit tests
uses: actions/setup-go@v5
with:
go-version: 1.x
go-version: '${{ matrix.go_version }}'
check-latest: true
cache: true

- uses: actions/checkout@v4

- uses: actions/checkout@v2
- run: go test -v -race -coverprofile="coverage-${{ matrix.os }}.${{ matrix.go_version }}.out" -covermode=atomic -coverpkg=$(go list)/... ./...

- run: go test
- name: Upload coverage to codecov
uses: codecov/codecov-action@v4
with:
files: './coverage-${{ matrix.os }}.${{ matrix.go_version }}.out'
flags: '${{ matrix.go_version }}'
os: '${{ matrix.os }}'
fail_ci_if_error: false
verbose: true
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
secrets.yml
coverage.out
*.out
21 changes: 20 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ linters-settings:
threshold: 200
goconst:
min-len: 2
min-occurrences: 2
min-occurrences: 3

linters:
enable-all: true
Expand Down Expand Up @@ -40,3 +40,22 @@ linters:
- tparallel
- thelper
- ifshort
- exhaustruct
- varnamelen
- gci
- depguard
- errchkjson
- inamedparam
- nonamedreturns
- musttag
- ireturn
- forcetypeassert
- cyclop
# deprecated linters
- deadcode
- interfacer
- scopelint
- varcheck
- structcheck
- golint
- nosnakecase
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# OAI object model
# OpenAPI v2 object model [![Build Status](https://github.com/go-openapi/spec/actions/workflows/go-test.yml/badge.svg)](https://github.com/go-openapi/spec/actions?query=workflow%3A"go+test") [![codecov](https://codecov.io/gh/go-openapi/spec/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/spec)

[![Build Status](https://travis-ci.org/go-openapi/spec.svg?branch=master)](https://travis-ci.org/go-openapi/spec)
<!-- [![Build status](https://ci.appveyor.com/api/projects/status/x377t5o9ennm847o/branch/master?svg=true)](https://ci.appveyor.com/project/casualjim/go-openapi/spec/branch/master) -->
[![codecov](https://codecov.io/gh/go-openapi/spec/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/spec)
[![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/spec/master/LICENSE)
[![Go Reference](https://pkg.go.dev/badge/github.com/go-openapi/spec.svg)](https://pkg.go.dev/github.com/go-openapi/spec)
Expand Down Expand Up @@ -32,3 +29,26 @@ The object model for OpenAPI specification documents.
> This [discussion thread](https://github.com/go-openapi/spec/issues/21) relates the full story.
>
> An early attempt to support Swagger 3 may be found at: https://github.com/go-openapi/spec3

* Does the unmarshaling support YAML?

> Not directly. The exposed types know only how to unmarshal from JSON.
>
> In order to load a YAML document as a Swagger spec, you need to use the loaders provided by
> github.com/go-openapi/loads
>
> Take a look at the example there: https://pkg.go.dev/github.com/go-openapi/loads#example-Spec
>
> See also https://github.com/go-openapi/spec/issues/164

* How can I validate a spec?

> Validation is provided by [the validate package](http://github.com/go-openapi/validate)

* Why do we have an `ID` field for `Schema` which is not part of the swagger spec?

> We found jsonschema compatibility more important: since `id` in jsonschema influences
> how `$ref` are resolved.
> This `id` does not conflict with any property named `id`.
>
> See also https://github.com/go-openapi/spec/issues/23
32 changes: 0 additions & 32 deletions appveyor.yml

This file was deleted.

297 changes: 0 additions & 297 deletions bindata.go

This file was deleted.

8 changes: 4 additions & 4 deletions circular_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package spec

import (
"encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
"time"
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestExpandCircular_Bitbucket(t *testing.T) {

func TestExpandCircular_ResponseWithRoot(t *testing.T) {
rootDoc := new(Swagger)
b, err := ioutil.ReadFile(filepath.Join("fixtures", "more_circulars", "resp.json"))
b, err := os.ReadFile(filepath.Join("fixtures", "more_circulars", "resp.json"))
require.NoError(t, err)

require.NoError(t, json.Unmarshal(b, rootDoc))
Expand Down Expand Up @@ -219,7 +219,7 @@ func TestExpandCircular_SpecExpansion(t *testing.T) {

func TestExpandCircular_RemoteCircularID(t *testing.T) {
go func() {
err := http.ListenAndServe("localhost:1234", http.FileServer(http.Dir("fixtures/more_circulars/remote")))
err := http.ListenAndServe("localhost:1234", http.FileServer(http.Dir("fixtures/more_circulars/remote"))) //#nosec
if err != nil {
panic(err.Error())
}
Expand All @@ -232,7 +232,7 @@ func TestExpandCircular_RemoteCircularID(t *testing.T) {
assertRefResolve(t, jazon, "", root, &ExpandOptions{RelativeBase: fixturePath})
assertRefExpand(t, jazon, "", root, &ExpandOptions{RelativeBase: fixturePath})

assert.NoError(t, ExpandSchemaWithBasePath(root, nil, &ExpandOptions{}))
require.NoError(t, ExpandSchemaWithBasePath(root, nil, &ExpandOptions{}))

jazon = asJSON(t, root)

Expand Down
11 changes: 5 additions & 6 deletions contact_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

const contactInfoJSON = `{
Expand All @@ -36,13 +37,11 @@ var contactInfo = ContactInfo{ContactInfoProps: ContactInfoProps{

func TestIntegrationContactInfo(t *testing.T) {
b, err := json.MarshalIndent(contactInfo, "", "\t")
if assert.NoError(t, err) {
assert.Equal(t, contactInfoJSON, string(b))
}
require.NoError(t, err)
assert.Equal(t, contactInfoJSON, string(b))

actual := ContactInfo{}
err = json.Unmarshal([]byte(contactInfoJSON), &actual)
if assert.NoError(t, err) {
assert.EqualValues(t, contactInfo, actual)
}
require.NoError(t, err)
assert.EqualValues(t, contactInfo, actual)
}
3 changes: 1 addition & 2 deletions debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package spec

import (
"io/ioutil"
"os"
"sync"
"testing"
Expand All @@ -28,7 +27,7 @@ var (
)

func TestDebug(t *testing.T) {
tmpFile, _ := ioutil.TempFile("", "debug-test")
tmpFile, _ := os.CreateTemp("", "debug-test")
tmpName := tmpFile.Name()
defer func() {
Debug = false
Expand Down
17 changes: 17 additions & 0 deletions embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package spec

import (
"embed"
"path"
)

//go:embed schemas/*.json schemas/*/*.json
var assets embed.FS

func jsonschemaDraft04JSONBytes() ([]byte, error) {
return assets.ReadFile(path.Join("schemas", "jsonschema-draft-04.json"))
}

func v2SchemaJSONBytes() ([]byte, error) {
return assets.ReadFile(path.Join("schemas", "v2", "schema.json"))
}
Loading
Loading